From 68a2697acaa81537a36687b9cc65efc3d5c58e28 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sat, 16 Dec 2006 23:55:24 +0000 Subject: [PATCH] =?utf8?q?Termina=20de=20reestructurar=20y=20borrar=20cosa?= =?utf8?q?s=20viejas=20y=20bugfixes=20m=C3=ADnimos=20que=20permiten=20que?= =?utf8?q?=20corra=20la=20simulaci=C3=B3n=20(aunque=20no=20hace=20nada=20p?= =?utf8?q?orque=20los=20sensores=20tienen=20rangos=20muy=20grandes,=20habr?= =?utf8?q?=C3=ADa=20que=20hacerlos=20"binarios").?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- trunk/src/breve/robot/Celdas-2-2.tz | 414 --------------- trunk/src/breve/robot/Celdas-2-3.tz | 429 --------------- trunk/src/breve/robot/Celdas-2-5.tz | 485 ----------------- trunk/src/breve/robot/Celdas-2-6.tz | 526 ------------------- trunk/src/breve/robot/Celdas-2-7.tz | 636 ----------------------- trunk/src/breve/robot/Demo-2wheels2-2.tz | 24 - trunk/src/breve/robot/Demo-2wheels2-3.tz | 24 - trunk/src/breve/robot/Demo-2wheels2-5.tz | 23 - trunk/src/breve/robot/laberintov4.tz | 198 ------- 9 files changed, 2759 deletions(-) delete mode 100644 trunk/src/breve/robot/Celdas-2-2.tz delete mode 100644 trunk/src/breve/robot/Celdas-2-3.tz delete mode 100644 trunk/src/breve/robot/Celdas-2-5.tz delete mode 100644 trunk/src/breve/robot/Celdas-2-6.tz delete mode 100644 trunk/src/breve/robot/Celdas-2-7.tz delete mode 100644 trunk/src/breve/robot/Demo-2wheels2-2.tz delete mode 100644 trunk/src/breve/robot/Demo-2wheels2-3.tz delete mode 100644 trunk/src/breve/robot/Demo-2wheels2-5.tz delete mode 100644 trunk/src/breve/robot/laberintov4.tz diff --git a/trunk/src/breve/robot/Celdas-2-2.tz b/trunk/src/breve/robot/Celdas-2-2.tz deleted file mode 100644 index 3bacaf7..0000000 --- a/trunk/src/breve/robot/Celdas-2-2.tz +++ /dev/null @@ -1,414 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. -@use Drawing. - -@define CELDAS_MAX_VELOCITY 30. - -PhysicalControl : CeldasControl { - % This class is used for building simple vehicle - % simulations. To create a vehicle simulation, - % subclass CeldasControl and use the init method to - % create OBJECT(CeldasObstacle) and - % OBJECT(CeldasVehicle) objects. - - + variables: - floor (object). - floorShape (object). - cloudTexture (object). - - + to init: - self enable-lighting. - #self enable-smooth-drawing. - - floorShape = new Shape. - floorShape init-with-cube size (200, .2, 200). - - floor = new Stationary. - floor register with-shape floorShape at-location (0, 0, 0). - #floor catch-shadows. - - self point-camera at (0, 0, 0) from (3, 3, 24). - - #self enable-shadows. - #self enable-reflections. - - cloudTexture = (new Image load from "images/clouds.png"). - self set-background-color to (.4, .6, .9). - self set-background-texture-image to cloudTexture. - -} - -MultiBody : CeldasLightVehicle (aka CeldasLightVehicles) { - % This object is used in conjunction with OBJECT(CeldasControl) to - % create simple vehicles. - - + variables: - bodyShape (object). - wheelShape (object). - sensorShape (object). - bodyLink (object). - - wheels (list). - sensors (list). - - + to init: - bodyShape = new Shape. - bodyShape init-with-cube size (4.0, .75, 3.0). - - wheelShape = new Shape. - wheelShape init-with-polygon-disk radius ( self get-wheel-radius ) sides 20 height ( self get-wheel-width ). - # 40 - - sensorShape = new Shape. - sensorShape init-with-polygon-cone radius .2 sides 5 height .5. - # 10 - - bodyShape set-density to ( self get-density ). - bodyLink = new Link. - bodyLink set-shape to bodyShape. - bodyLink set-mu to -1.0. - bodyLink set-eT to .8. - - self set-root to bodyLink. - - self move to (0, 0.9, 0). - self set-texture-scale to 1.5. - - - to get-density: - return 1.0. - - - to get-wheel-width: - return 0.1. - - - to get-wheel-radius: - return 0.6. - - + section "Adding Wheels and Sensors to a Vehicle" - - + to add-wheel at location (vector): - % Adds a wheel at location on the vehicle. This method returns - % the wheel which is created, a OBJECT(CeldasWheel). - - wheel, joint (object). - - wheel = new CeldasWheel. - wheel set-shape to wheelShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (1, 0, 0) by 1.5708. - joint link parent bodyLink to-child wheel with-normal (0, 0, 1) - with-parent-point location with-child-point (0, 0, 0). - - wheel set-eT to .8. - wheel set-texture to 0. - wheel set-joint to joint. - joint set-strength-limit to (joint get-strength-hard-limit) / 2. - wheel set-color to (.6, .6, .6). - wheel set-mu to 100000. - - self add-dependency on joint. - self add-dependency on wheel. - - push wheel onto wheels. - - return wheel. - - + to add-sensor at location (vector) with-direction direction = (0,1,0)(vector) : - % Adds a sensor at location on the vehicle. This method returns - % the sensor which is created, a OBJECT(CeldasSensor). - - sensor, joint (object). - - sensor = new CeldasSensor. - sensor set-direction to direction. - - sensor set-shape to sensorShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (0, 0, 1) by -1.57. - joint link parent bodyLink to-child sensor with-normal (1, 0, 0) - with-parent-point location with-child-point (0, 0, 0). - - joint set-double-spring with-strength 300 with-max 0.01 with-min -0.01. - - self add-dependency on joint. - self add-dependency on sensor. - - sensor set-color to (0, 0, 0). - - #push sensor onto sensors. - - return sensor. - - + to destroy: - free sensorShape. - free wheelShape. - free bodyShape. - - super destroy. -} - -CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { - % A heavy duty version of OBJECT(CeldasLightVehicle), this - % vehicle is heavier and harder to control, but more stable - % at higher speeds. - +variables: - lSensor, rSensor, fSensor, bSensor (object). - lWheel,rWheel (object). - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. - - + to set-global-velocity to velocity (float): - rWheel set-velocity to velocity. - lWheel set-velocity to velocity. - - + to get-global-velocity: - return ((rWheel get-velocity) + (lWheel get-velocity)) / 2. - - + to turn-right with-velocity velocity (float): - lWheel set-velocity to velocity. - rWheel set-velocity to -velocity. - - + to turn-left with-velocity velocity (float): -# vehicle rotate around-axis (0,1,0) by 1. - lWheel set-velocity to -velocity. - rWheel set-velocity to velocity. - - + to get-sensor-value: - return (fSensor get-sensor-value). - - +to init: - fSensor = (self add-sensor at (2.0, .4, 0)). - fSensor set-direction to (1,0,0). - fSensor set-id at 1. - bSensor = (self add-sensor at (-2.0, .4, 0)). - bSensor set-direction to (-1,0,0). - bSensor set-id at 2. - #bSensor set-sensor-angle to (-1.6). - #lSensor = (self add-sensor at (1.0, .4, 1.4)). - #lSensor set-direction to (0,0,1). - #rSensor = (self add-sensor at (1.0, .4, -1.4)). - #rSensor set-direction to (0,0,-1). - lWheel = (self add-wheel at (0, 0, -1.5)). - rWheel = (self add-wheel at (0, 0, 1.5)). - - +to iterate: - #+ to post-iterate: - valuef,valueb,valuer,valuel (float). - fl, fr(float). - - valuef=fSensor get-data. - valueb=bSensor get-data. - #valuel=lSensor get-data. - #valuer=rSensor get-data. - - #value = sensor get-data. - #value = self get-sensor-value. - #valueb = sensor2 get-sensor-value. - - if valuef >7: - self set-global-velocity to (15). - else if (valuef <=7) && (valuef > 0): - { - self set-global-velocity to (0). - #self turn-left with-velocity(2). - #self turn-right with-velocity(2). - #self set-global-velocity to (0). - } - #print "sensor valuef: $valuef valueb: $valueb". - - #else if value < 0.1: self turn-left with-velocity CELDAS_MAX_TURN_VELOCITY. - #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1). - - #fl = (flWheel get-velocity). - #fr = (frWheel get-velocity). - #print " sensorf: $value sensorb $valueb, fr: $fr, fl: $fl". - -} - -Stationary : CeldasObstacle (aka CeldasObstacles) { - % A CeldasObstacle is used in conjunction with OBJECT(CeldasControl) - % and OBJECT(CeldasVehicle). It is what the OBJECT(CeldasSensor) - % objects on the CeldasVehicle detect. - %

- % There are no special behaviors associated with the walls--they're - % basically just plain OBJECT(Stationary) objects. - - +variables: - large (float). - - - + to init with-size theSize = (10, 3, .1) (vector) with-color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 0, 0, 1 ), ( 0, 1, 0 ), ( 1, 0, 0 ) ] (matrix): - self init-with-shape shape (new Shape init-with-cube size theSize) color theColor at-location theLocation with-rotation theRotation. - large=10. - - + to init-with-shape shape theShape (object) color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 1, 0, 0 ), ( 0, 1, 0 ), ( 0, 0, 1 ) ] (matrix): - self register with-shape theShape at-location theLocation with-rotation theRotation. - self set-color to theColor. - - + to get-large: - return large. -} - -Link : CeldasWheel (aka CeldasWheels) { - % A CeldasWheel is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a wheel to the vehicle. - - + variables: - joint (object). - velocity (float). - - + to init: - velocity = 0. - - - to set-joint to j (object): - % Used internally. - - joint = j. - - + section "Configuring the Wheel's Velocity" - - + to set-velocity to n (float): - % Sets the velocity of this wheel. - - if n > CELDAS_MAX_VELOCITY: n = CELDAS_MAX_VELOCITY. - velocity = n. - - joint set-joint-velocity to velocity. - - + to get-velocity: - % Gets the velocity of this wheel. - - return velocity. - -} - -Link : CeldasSensor (aka CeldasSensors) { - % A CeldasSensor is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a sensor to the vehicle. - - + variables: - direction (vector). - positiveDirection(vector). - sensorAngle (float). - value (float). - draw (object). - id(int). - - + to init : - direction = (1,0,1). - positiveDirection= (1,0,1). - sensorAngle = 1.6. - value = 0.0. - draw = new Drawing. - - - + section "Configuring the Sensor Values" - + to set-id at n (int): - id=n. - - + to set-sensor-angle to n (float): - % Sets the angle in which this sensor can detect obstacles. The default - % value of 1.6 means that the sensor can see most of everything in - % front of it. Setting the value to be any higher leads to general - % wackiness, so I don't suggest it. - - sensorAngle = n. - - + to set-direction to n (vector): - direction = n. - positiveDirection::x=|n::x|. - positiveDirection::y=|n::y|. - positiveDirection::z=|n::z|. - - + section "Getting the Sensor Values" - - + to get-sensor-value: - % Gets the sensor value. This should be used from post-iterate, - % if not, the sensor reading correspond to the previous - % iteration. - - #+ to iterate: - - + to get-data: - i (object). - strength, angle (float). - toObstacle, transDir (vector). - largeWall (float). - source,destiny (vector). - obsLoc (vector). - location (vector). - posObstacle,posSensor (vector). - angulo(double). - des(int). - - transDir = (self get-rotation) * direction. - - value = 0.0. - foreach i in (all CeldasObstacles): { - - posObstacle=i get-location. - posObstacle::z = (self get-location)::z -posObstacle::z. - - #print " posObstacle: $posObstacle". - - toObstacle = (posObstacle) - (self get-location). - - angle = angle(toObstacle, transDir). - #angle = dot((1,1,1),direction)*angle(toObstacle, (0,0,1)). - - #print "toObstacle: $toObstacle, angle: $angle". - - posSensor=self get-location. - source = self get-location. - obsLoc = posObstacle. - destiny = obsLoc. - - draw clear. - - if(dot(direction,(1,1,1))<0): - des = ((dot((self get-location),positiveDirection))>(dot(posObstacle,positiveDirection))). - else - des = ((dot((self get-location),positiveDirection))<(dot(posObstacle,positiveDirection))). - - if (angle < sensorAngle) && (des): { - #if angle < sensorAngle: { - - strength = | (self get-location) - (i get-location) |. - largeWall=i get-large. - - print "id: $id, distancia= $toObstacle, angle $angle". - - draw set-color to (1, 0, 0). - draw draw-line from source to posObstacle. - - if |toObstacle::z|<=largeWall/2:{ - value = |toObstacle::x|. - } - else{ - value = -1. - } - return value. - } - } - value = -1. - return value. - - -} diff --git a/trunk/src/breve/robot/Celdas-2-3.tz b/trunk/src/breve/robot/Celdas-2-3.tz deleted file mode 100644 index 2ac34c8..0000000 --- a/trunk/src/breve/robot/Celdas-2-3.tz +++ /dev/null @@ -1,429 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. -@use Drawing. - -@define CELDAS_MAX_VELOCITY 30. - -PhysicalControl : CeldasControl { - % This class is used for building simple vehicle - % simulations. To create a vehicle simulation, - % subclass CeldasControl and use the init method to - % create OBJECT(CeldasObstacle) and - % OBJECT(CeldasVehicle) objects. - - + variables: - floor (object). - floorShape (object). - cloudTexture (object). - - - + to init: - self enable-lighting. - #self enable-smooth-drawing. - - floorShape = new Shape. - floorShape init-with-cube size (200, .2, 200). - - floor = new Stationary. - floor register with-shape floorShape at-location (0, 0, 0). - #floor catch-shadows. - - self point-camera at (0, 0, 0) from (3, 3, 24). - - #self enable-shadows. - #self enable-reflections. - - cloudTexture = (new Image load from "images/clouds.png"). - self set-background-color to (.4, .6, .9). - self set-background-texture-image to cloudTexture. - -} - -MultiBody : CeldasLightVehicle (aka CeldasLightVehicles) { - % This object is used in conjunction with OBJECT(CeldasControl) to - % create simple vehicles. - - + variables: - bodyShape (object). - wheelShape (object). - sensorShape (object). - bodyLink (object). - - wheels (list). - sensors (list). - - + to init: - bodyShape = new Shape. - bodyShape init-with-cube size (4.0, .75, 3.0). - - wheelShape = new Shape. - wheelShape init-with-polygon-disk radius ( self get-wheel-radius ) sides 20 height ( self get-wheel-width ). - # 40 - - sensorShape = new Shape. - sensorShape init-with-polygon-cone radius .2 sides 5 height .5. - # 10 - - bodyShape set-density to ( self get-density ). - bodyLink = new Link. - bodyLink set-shape to bodyShape. - bodyLink set-mu to -1.0. - bodyLink set-eT to .8. - - self set-root to bodyLink. - - self move to (0, 0.9, 0). - self set-texture-scale to 1.5. - - - to get-density: - return 1.0. - - - to get-wheel-width: - return 0.1. - - - to get-wheel-radius: - return 0.6. - - + section "Adding Wheels and Sensors to a Vehicle" - - + to add-wheel at location (vector): - % Adds a wheel at location on the vehicle. This method returns - % the wheel which is created, a OBJECT(CeldasWheel). - - wheel, joint (object). - - wheel = new CeldasWheel. - wheel set-shape to wheelShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (1, 0, 0) by 1.5708. - joint link parent bodyLink to-child wheel with-normal (0, 0, 1) - with-parent-point location with-child-point (0, 0, 0). - - wheel set-eT to .8. - wheel set-texture to 0. - wheel set-joint to joint. - joint set-strength-limit to (joint get-strength-hard-limit) / 2. - wheel set-color to (.6, .6, .6). - wheel set-mu to 100000. - - self add-dependency on joint. - self add-dependency on wheel. - - push wheel onto wheels. - - return wheel. - - + to add-sensor at location (vector) with-direction direction = (0,1,0)(vector) : - % Adds a sensor at location on the vehicle. This method returns - % the sensor which is created, a OBJECT(CeldasSensor). - - sensor, joint (object). - - sensor = new CeldasSensor. - sensor set-direction to direction. - - sensor set-shape to sensorShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (0, 0, 1) by -1.57. - joint link parent bodyLink to-child sensor with-normal (1, 0, 0) - with-parent-point location with-child-point (0, 0, 0). - - joint set-double-spring with-strength 300 with-max 0.01 with-min -0.01. - - self add-dependency on joint. - self add-dependency on sensor. - - sensor set-color to (0, 0, 0). - - #push sensor onto sensors. - - return sensor. - - + to destroy: - free sensorShape. - free wheelShape. - free bodyShape. - - super destroy. -} - -CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { - % A heavy duty version of OBJECT(CeldasLightVehicle), this - % vehicle is heavier and harder to control, but more stable - % at higher speeds. - +variables: - lSensor, rSensor, fSensor, bSensor (object). - lWheel,rWheel (object). - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. - - + to set-global-velocity to velocity (float): - rWheel set-velocity to velocity. - lWheel set-velocity to velocity. - - + to get-global-velocity: - return ((rWheel get-velocity) + (lWheel get-velocity)) / 2. - - + to turn-right with-velocity velocity (float): - lWheel set-velocity to velocity. - rWheel set-velocity to -velocity. - - + to turn-left with-velocity velocity (float): -# vehicle rotate around-axis (0,1,0) by 1. - lWheel set-velocity to -velocity. - rWheel set-velocity to velocity. - - + to get-sensor-value: - return (fSensor get-sensor-value). - - +to init: - fSensor = (self add-sensor at (2.0, .4, 0)). - fSensor set-direction to (1,0,0). - fSensor set-id at 1. - fSensor set-body at self. - bSensor = (self add-sensor at (-2.0, .4, 0)). - bSensor set-direction to (-1,0,0). - bSensor set-id at 2. - bSensor set-body at self. - #bSensor set-sensor-angle to (-1.6). - lSensor = (self add-sensor at (1.0, .4, 1.4)). - lSensor set-direction to (0,0,1). - bSensor set-id at 3. - bSensor set-body at self. - - #rSensor = (self add-sensor at (1.0, .4, -1.4)). - #rSensor set-direction to (0,0,-1). - lWheel = (self add-wheel at (0, 0, -1.5)). - rWheel = (self add-wheel at (0, 0, 1.5)). - - +to iterate: - #+ to post-iterate: - valuef,valueb,valuer,valuel (float). - fl, fr(float). - - valuef=fSensor get-data. - valueb=bSensor get-data. - #valuel=lSensor get-data. - #valuer=rSensor get-data. - - #value = sensor get-data. - #value = self get-sensor-value. - #valueb = sensor2 get-sensor-value. - - if valuef >7: - self set-global-velocity to (15). - else if (valuef <=7) && (valuef > 0): - { - self set-global-velocity to (0). - #self turn-left with-velocity(2). - #self turn-right with-velocity(2). - #self set-global-velocity to (0). - } - #print "sensor valuef: $valuef valueb: $valueb". - - #else if value < 0.1: self turn-left with-velocity CELDAS_MAX_TURN_VELOCITY. - #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1). - - #fl = (flWheel get-velocity). - #fr = (frWheel get-velocity). - #print " sensorf: $value sensorb $valueb, fr: $fr, fl: $fl". - -} - -Stationary : CeldasObstacle (aka CeldasObstacles) { - % A CeldasObstacle is used in conjunction with OBJECT(CeldasControl) - % and OBJECT(CeldasVehicle). It is what the OBJECT(CeldasSensor) - % objects on the CeldasVehicle detect. - %

- % There are no special behaviors associated with the walls--they're - % basically just plain OBJECT(Stationary) objects. - - +variables: - large (float). - - - + to init with-size theSize = (10, 3, .1) (vector) with-color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 0, 0, 1 ), ( 0, 1, 0 ), ( 1, 0, 0 ) ] (matrix): - self init-with-shape shape (new Shape init-with-cube size theSize) color theColor at-location theLocation with-rotation theRotation. - large=10. - - + to init-with-shape shape theShape (object) color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 1, 0, 0 ), ( 0, 1, 0 ), ( 0, 0, 1 ) ] (matrix): - self register with-shape theShape at-location theLocation with-rotation theRotation. - self set-color to theColor. - - + to get-large: - return large. -} - -Link : CeldasWheel (aka CeldasWheels) { - % A CeldasWheel is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a wheel to the vehicle. - - + variables: - joint (object). - velocity (float). - - + to init: - velocity = 0. - - - to set-joint to j (object): - % Used internally. - - joint = j. - - + section "Configuring the Wheel's Velocity" - - + to set-velocity to n (float): - % Sets the velocity of this wheel. - - if n > CELDAS_MAX_VELOCITY: n = CELDAS_MAX_VELOCITY. - velocity = n. - - joint set-joint-velocity to velocity. - - + to get-velocity: - % Gets the velocity of this wheel. - - return velocity. - -} - -Link : CeldasSensor (aka CeldasSensors) { - % A CeldasSensor is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a sensor to the vehicle. - - + variables: - direction (vector). - positiveDirection(vector). - sensorAngle (float). - value (float). - draw (object). - body(object). - id(int). - - + to init : - direction = (1,0,1). - positiveDirection= (1,0,1). - sensorAngle = 1.6. - value = 0.0. - draw = new Drawing. - - - + section "Configuring the Sensor Values" - + to set-id at n (int): - id=n. - - + to set-body at robotBody(object): - body=robotBody. - - + to set-sensor-angle to n (float): - % Sets the angle in which this sensor can detect obstacles. The default - % value of 1.6 means that the sensor can see most of everything in - % front of it. Setting the value to be any higher leads to general - % wackiness, so I don't suggest it. - - sensorAngle = n. - - + to set-direction to n (vector): - direction = n. - positiveDirection::x=|n::x|. - positiveDirection::y=|n::y|. - positiveDirection::z=|n::z|. - - + section "Getting the Sensor Values" - - + to get-sensor-value: - % Gets the sensor value. This should be used from post-iterate, - % if not, the sensor reading correspond to the previous - % iteration. - - #+ to iterate: - - + to get-data: - i (object). - x,y,z (float). - v(vector). - aux(float). - - - strength, angle (float). - toObstacle, transDir (vector). - largeWall (float). - source,destiny (vector). - obsLoc (vector). - location (vector). - posObstacle,posSensor (vector). - angulo(double). - des(int). - - transDir = (self get-rotation) * direction. - - value = 0.0. - foreach i in (all CeldasObstacles): { - - posObstacle=i get-location. - print "$i". - - - - if(dot(direction,(1,1,1))<0): - des = ((dot((self get-location),positiveDirection))>(dot(posObstacle,positiveDirection))). - else - des = ((dot((self get-location),positiveDirection))<(dot(posObstacle,positiveDirection))). - - - if (des): - { - #posObstacle::z = (self get-location)::z -posObstacle::z. - - #print " posObstacle: $posObstacle". - - angle = angle(toObstacle, transDir). - posSensor=self get-location. - source = self get-location. - #obsLoc = posObstacle. - - #v = (self get-rotation) * (direction). - v = (body get-location) - (self get-location ). - #v = (direction). - #aux=(self get-rotation). - #print "rot: $aux". - aux=v::z/v::x. - print "m: $aux". - - obsLoc::z=z=((self get-location)::z + ((posObstacle::x - (self get-location)::x)*v::z/v::x)). - obsLoc::y=y=posObstacle::y. - obsLoc::x=x=posObstacle::x. - - destiny = obsLoc. - print "v:$direction x,y,z: $x,$y,$z". - #print "v: $v". - draw clear. - - draw set-color to (1, 0, 0). - draw draw-line from source to obsLoc. - } - - } - value = -1. - return value. - - -} diff --git a/trunk/src/breve/robot/Celdas-2-5.tz b/trunk/src/breve/robot/Celdas-2-5.tz deleted file mode 100644 index ee56a6e..0000000 --- a/trunk/src/breve/robot/Celdas-2-5.tz +++ /dev/null @@ -1,485 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. -@use Drawing. - -@define CELDAS_MAX_VELOCITY 30. - -PhysicalControl : CeldasControl { - % This class is used for building simple vehicle - % simulations. To create a vehicle simulation, - % subclass CeldasControl and use the init method to - % create OBJECT(CeldasObstacle) and - % OBJECT(CeldasVehicle) objects. - - + variables: - floor (object). - floorShape (object). - cloudTexture (object). - - - + to init: - self enable-lighting. - #self enable-smooth-drawing. - - floorShape = new Shape. - floorShape init-with-cube size (200, .2, 200). - - floor = new Stationary. - floor register with-shape floorShape at-location (0, 0, 0). - #floor catch-shadows. - - self point-camera at (0, 0, 0) from (3, 3, 24). - - #self enable-shadows. - #self enable-reflections. - - cloudTexture = (new Image load from "images/clouds.png"). - self set-background-color to (.4, .6, .9). - self set-background-texture-image to cloudTexture. - -} - -MultiBody : CeldasLightVehicle (aka CeldasLightVehicles) { - % This object is used in conjunction with OBJECT(CeldasControl) to - % create simple vehicles. - - + variables: - bodyShape (object). - wheelShape (object). - sensorShape (object). - bodyLink (object). - - wheels (list). - sensors (list). - - + to init: - bodyShape = new Shape. - bodyShape init-with-cube size (4.0, .75, 3.0). - - wheelShape = new Shape. - wheelShape init-with-polygon-disk radius ( self get-wheel-radius ) sides 20 height ( self get-wheel-width ). - # 40 - - sensorShape = new Shape. - sensorShape init-with-polygon-cone radius .2 sides 5 height .5. - # 10 - - bodyShape set-density to ( self get-density ). - bodyLink = new Link. - bodyLink set-shape to bodyShape. - bodyLink set-mu to -1.0. - bodyLink set-eT to .8. - - self set-root to bodyLink. - - self move to (0, 0.9, 0). - self set-texture-scale to 1.5. - - - to get-density: - return 1.0. - - - to get-wheel-width: - return 0.1. - - - to get-wheel-radius: - return 0.6. - - + section "Adding Wheels and Sensors to a Vehicle" - - + to add-wheel at location (vector): - % Adds a wheel at location on the vehicle. This method returns - % the wheel which is created, a OBJECT(CeldasWheel). - - wheel, joint (object). - - wheel = new CeldasWheel. - wheel set-shape to wheelShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (1, 0, 0) by 1.5708. - joint link parent bodyLink to-child wheel with-normal (0, 0, 1) - with-parent-point location with-child-point (0, 0, 0). - - wheel set-eT to .8. - wheel set-texture to 0. - wheel set-joint to joint. - joint set-strength-limit to (joint get-strength-hard-limit) / 2. - wheel set-color to (.6, .6, .6). - wheel set-mu to 100000. - - self add-dependency on joint. - self add-dependency on wheel. - - push wheel onto wheels. - - return wheel. - - + to add-sensor at location (vector) with-direction direction = (0,1,0)(vector) : - % Adds a sensor at location on the vehicle. This method returns - % the sensor which is created, a OBJECT(CeldasSensor). - - sensor, joint (object). - - sensor = new CeldasSensor. - sensor set-direction to direction. - - sensor set-shape to sensorShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (0, 0, 1) by -1.57. - joint link parent bodyLink to-child sensor with-normal (1, 0, 0) - with-parent-point location with-child-point (0, 0, 0). - - joint set-double-spring with-strength 300 with-max 0.01 with-min -0.01. - - self add-dependency on joint. - self add-dependency on sensor. - - sensor set-color to (0, 0, 0). - - #push sensor onto sensors. - - return sensor. - - + to destroy: - free sensorShape. - free wheelShape. - free bodyShape. - - super destroy. -} - -CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { - % A heavy duty version of OBJECT(CeldasLightVehicle), this - % vehicle is heavier and harder to control, but more stable - % at higher speeds. - +variables: - lSensor, rSensor, fSensor, bSensor (object). - lWheel,rWheel (object). - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. - - + to set-global-velocity to velocity (float): - rWheel set-velocity to velocity. - lWheel set-velocity to velocity. - - + to get-global-velocity: - return ((rWheel get-velocity) + (lWheel get-velocity)) / 2. - - + to turn-right with-velocity velocity (float): - lWheel set-velocity to velocity. - rWheel set-velocity to -velocity. - - + to turn-left with-velocity velocity (float): -# vehicle rotate around-axis (0,1,0) by 1. - lWheel set-velocity to -velocity. - rWheel set-velocity to velocity. - - + to get-sensor-value: - return (fSensor get-sensor-value). - - +to init: - fSensor = (self add-sensor at (2.0, .4, 0)). - fSensor set-direction to (1,0,0). - fSensor set-id at 1. - fSensor set-body at self. - bSensor = (self add-sensor at (-2.0, .4, 0)). - bSensor set-direction to (-1,0,0). - bSensor set-id at 2. - bSensor set-body at self. - lSensor = (self add-sensor at (0, .4, 1.5)). - lSensor set-direction to (0,0,1). - lSensor set-id at 3. - lSensor set-body at self. - - - rSensor = (self add-sensor at (0, .4, -1.5)). - rSensor set-direction to (0,0,-1). - rSensor set-id at 4. - rSensor set-body at self. - - lWheel = (self add-wheel at (0, 0, -1.5)). - rWheel = (self add-wheel at (0, 0, 1.5)). - - +to iterate: - #+ to post-iterate: - valuef,valueb,valuer,valuel (float). - fl, fr(float). - - valuef=fSensor get-data. - valueb=bSensor get-data. - valuel=lSensor get-data. - valuer=rSensor get-data. - - self turn-left with-velocity(20). - self set-global-velocity to (15). - if valuef >7: - self set-global-velocity to (15). - else if (valuef <=7) && (valuef > 0): - { - self set-global-velocity to (0). - #self turn-left with-velocity(2). - #self turn-right with-velocity(2). - #self set-global-velocity to (0). - } - #print "sensor valuef: $valuef valueb: $valueb". - - #else if value < 0.1: self turn-left with-velocity CELDAS_MAX_TURN_VELOCITY. - #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1). - - #fl = (flWheel get-velocity). - #fr = (frWheel get-velocity). - #print " sensorf: $value sensorb $valueb, fr: $fr, fl: $fl". - -} - -Stationary : CeldasObstacle (aka CeldasObstacles) { - % A CeldasObstacle is used in conjunction with OBJECT(CeldasControl) - % and OBJECT(CeldasVehicle). It is what the OBJECT(CeldasSensor) - % objects on the CeldasVehicle detect. - %

- % There are no special behaviors associated with the walls--they're - % basically just plain OBJECT(Stationary) objects. - - +variables: - large (float). - direction (vector). - - - + to init with-size theSize = (10, 3, .1) (vector) with-color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 0, 0, 1 ), ( 0, 1, 0 ), ( 1, 0, 0 ) ] (matrix): - self init-with-shape shape (new Shape init-with-cube size theSize) color theColor at-location theLocation with-rotation theRotation. - large=20. - - + to init-with-shape shape theShape (object) color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 1, 0, 0 ), ( 0, 1, 0 ), ( 0, 0, 1 ) ] (matrix): - self register with-shape theShape at-location theLocation with-rotation theRotation. - self set-color to theColor. - - + to get-large: - return large. - - + to set-direction at theDirection (vector): - direction=theDirection. - - + to get-direction: - return direction. -} - -Link : CeldasWheel (aka CeldasWheels) { - % A CeldasWheel is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a wheel to the vehicle. - - + variables: - joint (object). - velocity (float). - - + to init: - velocity = 0. - - - to set-joint to j (object): - % Used internally. - - joint = j. - - + section "Configuring the Wheel's Velocity" - - + to set-velocity to n (float): - % Sets the velocity of this wheel. - - if n > CELDAS_MAX_VELOCITY: n = CELDAS_MAX_VELOCITY. - velocity = n. - - joint set-joint-velocity to velocity. - - + to get-velocity: - % Gets the velocity of this wheel. - - return velocity. - -} - -Link : CeldasSensor (aka CeldasSensors) { - % A CeldasSensor is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a sensor to the vehicle. - - + variables: - direction (vector). - positiveDirection(vector). - sensorAngle (float). - value (float). - draw (object). - body(object). - id(int). - - + to init : - direction = (1,0,1). - positiveDirection= (1,0,1). - sensorAngle = 1.6. - value = 0.0. - draw = new Drawing. - - - + section "Configuring the Sensor Values" - + to set-id at n (int): - id=n. - - + to set-body at robotBody(object): - body=robotBody. - - + to set-sensor-angle to n (float): - % Sets the angle in which this sensor can detect obstacles. The default - % value of 1.6 means that the sensor can see most of everything in - % front of it. Setting the value to be any higher leads to general - % wackiness, so I don't suggest it. - - sensorAngle = n. - - + to set-direction to n (vector): - direction = n. - positiveDirection::x=|n::x|. - positiveDirection::y=|n::y|. - positiveDirection::z=|n::z|. - - + section "Getting the Sensor Values" - - + to get-sensor-value: - % Gets the sensor value. This should be used from post-iterate, - % if not, the sensor reading correspond to the previous - % iteration. - - #+ to iterate: - - + to get-data: - i (object). - x,y,z (float). - min,dist (float). - v,obs(vector). - aux(float). - j (int). - des1,des2,des3(int). - wallBegin,wallEnd (float). - - aux1,aux2,aux3,aux4 (float). - yo,toObstacle, transDir (vector). - largeWall (float). - source,destiny (vector). - obsLoc (vector). - location (vector). - posObstacle,posSensor (vector). - - draw clear. - value = 0.0. - j=0. - min=0. - foreach i in (all CeldasObstacles): - { - posObstacle=i get-location. - - - #! - if(dot((i get-direction),direction)==0): - des1=1. - else - des1=0. - !# - - des2=0. - if(dot(direction,(1,1,1))<0): - { - if((dot((self get-location),positiveDirection))>(dot(posObstacle,positiveDirection))): - des2=1. - } - else - { - if((dot((self get-location),positiveDirection))<(dot(posObstacle,positiveDirection))): - des2=1. - } - - - #Compruebo que el robot este frente a la pared - wallBegin=dot((i get-location),(i get-direction) )- (i get-large)/2. - wallEnd=dot((i get-location),(i get-direction) )+ (i get-large)/2. - - - #print "begin: $wallBegin end: $wallEnd". - yo=self get-location. - destiny=i get-direction. - - v = (body get-location) - (self get-location ). - obsLoc::y=y=posObstacle::y. - - if (dot((i get-direction),(1,0,0))): - { - obsLoc::x=x=((self get-location)::x + ((posObstacle::z - (self get-location)::z)*v::x/v::z)). - obsLoc::z=z=posObstacle::z. - } - else - { - obsLoc::z=z=((self get-location)::z + ((posObstacle::x - (self get-location)::x)*v::z/v::x)). - obsLoc::x=x=posObstacle::x. - } - - - if (dot((obsLoc),(i get-direction)) > wallBegin) && (dot((obsLoc),(i get-direction)) < wallEnd): - des3=1. - else - { - des3=0. - - } - - aux1=dot((self get-location),(i get-direction)). - - #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ". - #print "dist: $aux1 begin: $wallBegin end: $wallEnd". - - - print "sensor: $id , des1: $des1, des2: $des2, des3: $des3". - if ((des2) && (des3)): - { - draw clear. - #print " posObstacle: $posObstacle". - - dist=|obsLoc - (self get-location)|. - if( (j==0) || (min>dist) ): - { - min=dist. - obs=obsLoc. - j++. - } - - } - - - } #end for - - if(j!=0): - { - #Dibujo el laser - draw set-color to (1, 0, 0). - draw draw-line from (self get-location) to (obs). - return dist. - } - - - value = -1. - return value. - - -} - \ No newline at end of file diff --git a/trunk/src/breve/robot/Celdas-2-6.tz b/trunk/src/breve/robot/Celdas-2-6.tz deleted file mode 100644 index 9756afe..0000000 --- a/trunk/src/breve/robot/Celdas-2-6.tz +++ /dev/null @@ -1,526 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. -@use Drawing. - -@define CELDAS_MAX_VELOCITY 30. - -PhysicalControl : CeldasControl { - % This class is used for building simple vehicle - % simulations. To create a vehicle simulation, - % subclass CeldasControl and use the init method to - % create OBJECT(CeldasObstacle) and - % OBJECT(CeldasVehicle) objects. - - + variables: - floor (object). - floorShape (object). - cloudTexture (object). - - - + to init: - self enable-lighting. - #self enable-smooth-drawing. - - floorShape = new Shape. - floorShape init-with-cube size (200, .2, 200). - - floor = new Stationary. - floor register with-shape floorShape at-location (0, 0, 0). - #floor catch-shadows. - - self point-camera at (0, 0, 0) from (3, 3, 24). - - #self enable-shadows. - #self enable-reflections. - - cloudTexture = (new Image load from "images/clouds.png"). - self set-background-color to (.4, .6, .9). - self set-background-texture-image to cloudTexture. - -} - -MultiBody : CeldasLightVehicle (aka CeldasLightVehicles) { - % This object is used in conjunction with OBJECT(CeldasControl) to - % create simple vehicles. - - + variables: - bodyShape (object). - wheelShape (object). - sensorShape (object). - bodyLink (object). - - wheels (list). - sensors (list). - - + to init: - bodyShape = new Shape. - bodyShape init-with-cube size (4.0, .75, 3.0). - - wheelShape = new Shape. - wheelShape init-with-polygon-disk radius ( self get-wheel-radius ) sides 20 height ( self get-wheel-width ). - # 40 - - sensorShape = new Shape. - sensorShape init-with-polygon-cone radius .2 sides 5 height .5. - # 10 - - bodyShape set-density to ( self get-density ). - bodyLink = new Link. - bodyLink set-shape to bodyShape. - bodyLink set-mu to -1.0. - bodyLink set-eT to .8. - - self set-root to bodyLink. - - self move to (0, 0.9, 0). - self set-texture-scale to 1.5. - - - to get-density: - return 1.0. - - - to get-wheel-width: - return 0.1. - - - to get-wheel-radius: - return 0.6. - - + section "Adding Wheels and Sensors to a Vehicle" - - + to add-wheel at location (vector): - % Adds a wheel at location on the vehicle. This method returns - % the wheel which is created, a OBJECT(CeldasWheel). - - wheel, joint (object). - - wheel = new CeldasWheel. - wheel set-shape to wheelShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (1, 0, 0) by 1.5708. - joint link parent bodyLink to-child wheel with-normal (0, 0, 1) - with-parent-point location with-child-point (0, 0, 0). - - wheel set-eT to .8. - wheel set-texture to 0. - wheel set-joint to joint. - joint set-strength-limit to (joint get-strength-hard-limit) / 2. - wheel set-color to (.6, .6, .6). - wheel set-mu to 100000. - - self add-dependency on joint. - self add-dependency on wheel. - - push wheel onto wheels. - - return wheel. - - + to add-sensor at location (vector) with-direction direction = (0,1,0)(vector) : - % Adds a sensor at location on the vehicle. This method returns - % the sensor which is created, a OBJECT(CeldasSensor). - - sensor, joint (object). - - sensor = new CeldasSensor. - sensor set-direction to direction. - - sensor set-shape to sensorShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (0, 0, 1) by -1.57. - joint link parent bodyLink to-child sensor with-normal (1, 0, 0) - with-parent-point location with-child-point (0, 0, 0). - - joint set-double-spring with-strength 300 with-max 0.01 with-min -0.01. - - self add-dependency on joint. - self add-dependency on sensor. - - sensor set-color to (0, 0, 0). - - #push sensor onto sensors. - - return sensor. - - + to destroy: - free sensorShape. - free wheelShape. - free bodyShape. - - super destroy. -} - -CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { - % A heavy duty version of OBJECT(CeldasLightVehicle), this - % vehicle is heavier and harder to control, but more stable - % at higher speeds. - +variables: - lSensor, rSensor, fSensor, bSensor (object). - lfWheel,rfWheel,lbWheel,rbWheel (object). - tleft,tright (int). - - avanzando,retrocediendo,girando(int). - - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. - - + to set-global-velocity to velocity (float): - rfWheel set-velocity to velocity. - lfWheel set-velocity to velocity. - rbWheel set-velocity to velocity. - lbWheel set-velocity to velocity. - - + to get-global-velocity: - return ((rfWheel get-velocity) + (lfWheel get-velocity)) / 2. - - + to turn-right: - tright++. - - self rotate around-axis (0,1,0) by (-1.5709/10)*tright. - - if(tright==10): tright=0. - - - + to turn-left: - tleft++. - - self rotate around-axis (0,1,0) by (1.5709/10)*tleft. - - if(tleft==10): tleft=0. - - - + to get-sensor-value: - return (fSensor get-sensor-value). - - +to init: - fSensor = (self add-sensor at (2.0, .4, 0)). - fSensor set-direction to (1,0,0). - #fSensor set-direction to (0,0,1). - fSensor set-id at 1. - fSensor set-body at self. - bSensor = (self add-sensor at (-2.0, .4, 0)). - bSensor set-direction to (-1,0,0). - #bSensor set-direction to (0,0,1). - bSensor set-id at 2. - bSensor set-body at self. - lSensor = (self add-sensor at (0, .4, 1.5)). - lSensor set-direction to (0,0,1). - #lSensor set-direction to (1,0,0). - lSensor set-id at 3. - lSensor set-body at self. - - - rSensor = (self add-sensor at (0, .4, -1.5)). - rSensor set-direction to (0,0,-1). - #rSensor set-direction to (-1,0,0). - rSensor set-id at 4. - rSensor set-body at self. - - lfWheel = (self add-wheel at (2, 0, -1.5)). - lbWheel = (self add-wheel at (-2, 0, -1.5)). - rfWheel = (self add-wheel at (2, 0, 1.5)). - rbWheel = (self add-wheel at (-2, 0, 1.5)). - - tleft=tright=0. #Debe ser inicializado en 0 esta asi para probar!!!!!!!!!!!!!!!!!!!!!!!! - avanzando=1. - retrocediendo=0. - girando=0. - - +to iterate: - valuef,valueb,valuer,valuel (float). - fl, fr(float). - - valuef=fSensor get-data. - valueb=bSensor get-data. - valuel=lSensor get-data. - valuer=rSensor get-data. - - print "senforl: $valuel". - - if(avanzando): - if(valuef>15): - self set-global-velocity to (15). - else - { - avanzando=0. - retrocediendo=1. - } - - - if(retrocediendo): - if(valueb>15): - self set-global-velocity to (-15). - else - { - tleft=1. - retrocediendo=0. - } - - - if((tleft) && (valuel>10)): - { - #self set-global-velocity to (0). - self turn-left. - } - else - { - avanzando=1. - #tright=1. - } - -#! - if((tright) && (valuer>10)): - { - #self set-global-velocity to (0). - self turn-right. - } - else - { - avanzando=1. - #tright=1. - } -!# - -} - -Stationary : CeldasObstacle (aka CeldasObstacles) { - % A CeldasObstacle is used in conjunction with OBJECT(CeldasControl) - % and OBJECT(CeldasVehicle). It is what the OBJECT(CeldasSensor) - % objects on the CeldasVehicle detect. - %

- % There are no special behaviors associated with the walls--they're - % basically just plain OBJECT(Stationary) objects. - - +variables: - large (float). - direction (vector). - - - + to init with-size theSize = (10, 3, .1) (vector) with-color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 0, 0, 1 ), ( 0, 1, 0 ), ( 1, 0, 0 ) ] (matrix): - self init-with-shape shape (new Shape init-with-cube size theSize) color theColor at-location theLocation with-rotation theRotation. - large=20. - - + to init-with-shape shape theShape (object) color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 1, 0, 0 ), ( 0, 1, 0 ), ( 0, 0, 1 ) ] (matrix): - self register with-shape theShape at-location theLocation with-rotation theRotation. - self set-color to theColor. - - + to get-large: - return large. - - + to set-direction at theDirection (vector): - direction=theDirection. - - + to get-direction: - return direction. -} - -Link : CeldasWheel (aka CeldasWheels) { - % A CeldasWheel is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a wheel to the vehicle. - - + variables: - joint (object). - velocity (float). - - + to init: - velocity = 0. - - - to set-joint to j (object): - % Used internally. - - joint = j. - - + section "Configuring the Wheel's Velocity" - - + to set-velocity to n (float): - % Sets the velocity of this wheel. - - if n > CELDAS_MAX_VELOCITY: n = CELDAS_MAX_VELOCITY. - velocity = n. - - joint set-joint-velocity to velocity. - - + to get-velocity: - % Gets the velocity of this wheel. - - return velocity. - -} - -Link : CeldasSensor (aka CeldasSensors) { - % A CeldasSensor is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a sensor to the vehicle. - - + variables: - direction (vector). - positiveDirection(vector). - sensorAngle (float). - value (float). - draw (object). - body(object). - id(int). - - + to init : - direction = (1,0,1). - positiveDirection= (1,0,1). - sensorAngle = 1.6. - value = 0.0. - draw = new Drawing. - - - + section "Configuring the Sensor Values" - + to set-id at n (int): - id=n. - - + to set-body at robotBody(object): - body=robotBody. - - + to set-sensor-angle to n (float): - % Sets the angle in which this sensor can detect obstacles. The default - % value of 1.6 means that the sensor can see most of everything in - % front of it. Setting the value to be any higher leads to general - % wackiness, so I don't suggest it. - - sensorAngle = n. - - + to set-direction to n (vector): - direction = n. - positiveDirection::x=|n::x|. - positiveDirection::y=|n::y|. - positiveDirection::z=|n::z|. - - + section "Getting the Sensor Values" - - + to get-sensor-value: - % Gets the sensor value. This should be used from post-iterate, - % if not, the sensor reading correspond to the previous - % iteration. - - #+ to iterate: - - + to get-data: - i (object). - min,dist (float). - v,obs(vector). - aux(float). - j (int). - des2,des3(int). - wallBegin,wallEnd,wallCenter (float). - - toObstacle(vector). - largeWall (float). - - obsLoc (vector). - location (vector). - posObstacle,destiny,yo(vector). - - draw clear. - value = 0.0. - j=0. - min=0. - foreach i in (all CeldasObstacles): - { - posObstacle=i get-location. - v = (body get-location) - (self get-location ). - obsLoc::y=posObstacle::y. - - if (dot((i get-direction),(1,0,0))): - { - obsLoc::x=((self get-location)::x + ((posObstacle::z - (self get-location)::z)*v::x/v::z)). - obsLoc::z=posObstacle::z. - } - else - { - obsLoc::z=((self get-location)::z + ((posObstacle::x - (self get-location)::x)*v::z/v::x)). - obsLoc::x=posObstacle::x. - } - - #! - if(dot((i get-direction),direction)==0): - des1=1. - else - des1=0. - !# - - des2=0. - if(dot(direction,(1,1,1))<0): - { - if((dot((self get-location),positiveDirection))>(dot(obsLoc,positiveDirection))): - des2=1. - } - else - { - if((dot((self get-location),positiveDirection))<(dot(obsLoc,positiveDirection))): - des2=1. - } - - - #Compruebo que el robot este frente a la pared - wallCenter=dot((i get-location),(i get-direction)). - wallBegin=wallCenter- (i get-large)/2. - wallEnd=wallCenter + (i get-large)/2. - - - yo=self get-location. - destiny=i get-direction. - - - - if (dot((self get-location),(i get-direction)) > wallBegin) && (dot((self get-location),(i get-direction)) < wallEnd): - des3=1. - else - { - des3=0. - - } - - if ((des2) && (des3)): - { - draw clear. - - dist=|obsLoc - (self get-location)|. - - if( (j==0) || (min>dist) ): - { - min=dist. - obs=obsLoc. - - j++. - #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ". - } - - } - - - } #end for - - if(j!=0): - { - #Dibujo el laser - draw set-color to (1, 0, 0). - draw draw-line from (self get-location) to (obs). - return min. - } - - - value = -1. - return value. - - -} - \ No newline at end of file diff --git a/trunk/src/breve/robot/Celdas-2-7.tz b/trunk/src/breve/robot/Celdas-2-7.tz deleted file mode 100644 index 30e36db..0000000 --- a/trunk/src/breve/robot/Celdas-2-7.tz +++ /dev/null @@ -1,636 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. -@use Drawing. -@use SistemaAutonomo. - -@define CELDAS_MAX_VELOCITY 30. -@define CELDAS_TURNO 100. - -PhysicalControl : CeldasControl { - % This class is used for building simple vehicle - % simulations. To create a vehicle simulation, - % subclass CeldasControl and use the init method to - % create OBJECT(CeldasObstacle) and - % OBJECT(CeldasVehicle) objects. - - + variables: - floor (object). - floorShape (object). - cloudTexture (object). - - - + to init: - self enable-lighting. - #self enable-smooth-drawing. - - floorShape = new Shape. - floorShape init-with-cube size (200, .2, 200). - - floor = new Stationary. - floor register with-shape floorShape at-location (0, 0, 0). - #floor catch-shadows. - - self point-camera at (0, 0, 0) from (3, 3, 24). - - #self enable-shadows. - #self enable-reflections. - - cloudTexture = (new Image load from "images/clouds.png"). - self set-background-color to (.4, .6, .9). - self set-background-texture-image to cloudTexture. - -} - -MultiBody : CeldasLightVehicle (aka CeldasLightVehicles) { - % This object is used in conjunction with OBJECT(CeldasControl) to - % create simple vehicles. - - + variables: - bodyShape (object). - wheelShape (object). - sensorShape (object). - bodyLink (object). - - wheels (list). - sensors (list). - - + to init: - bodyShape = new Shape. - bodyShape init-with-cube size (4.0, .75, 3.0). - - wheelShape = new Shape. - wheelShape init-with-polygon-disk radius ( self get-wheel-radius ) sides 20 height ( self get-wheel-width ). - # 40 - - sensorShape = new Shape. - sensorShape init-with-polygon-cone radius .2 sides 5 height .5. - # 10 - - bodyShape set-density to ( self get-density ). - bodyLink = new Link. - bodyLink set-shape to bodyShape. - bodyLink set-mu to -1.0. - bodyLink set-eT to .8. - - self set-root to bodyLink. - - self move to (0, 0.9, 0). - self set-texture-scale to 1.5. - - - to get-density: - return 1.0. - - - to get-wheel-width: - return 0.1. - - - to get-wheel-radius: - return 0.6. - - + section "Adding Wheels and Sensors to a Vehicle" - - + to add-wheel at location (vector): - % Adds a wheel at location on the vehicle. This method returns - % the wheel which is created, a OBJECT(CeldasWheel). - - wheel, joint (object). - - wheel = new CeldasWheel. - wheel set-shape to wheelShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (1, 0, 0) by 1.5708. - joint link parent bodyLink to-child wheel with-normal (0, 0, 1) - with-parent-point location with-child-point (0, 0, 0). - - wheel set-eT to .8. - wheel set-texture to 0. - wheel set-joint to joint. - joint set-strength-limit to (joint get-strength-hard-limit) / 2. - wheel set-color to (.6, .6, .6). - wheel set-mu to 100000. - - self add-dependency on joint. - self add-dependency on wheel. - - push wheel onto wheels. - - return wheel. - - + to add-sensor at location (vector) with-direction direction = (0,1,0)(vector) : - % Adds a sensor at location on the vehicle. This method returns - % the sensor which is created, a OBJECT(CeldasSensor). - - sensor, joint (object). - - sensor = new CeldasSensor. - sensor set-direction to direction. - - sensor set-shape to sensorShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis (0, 0, 1) by -1.57. - joint link parent bodyLink to-child sensor with-normal (1, 0, 0) - with-parent-point location with-child-point (0, 0, 0). - - joint set-double-spring with-strength 300 with-max 0.01 with-min -0.01. - - self add-dependency on joint. - self add-dependency on sensor. - - sensor set-color to (0, 0, 0). - - #push sensor onto sensors. - - return sensor. - - + to destroy: - free sensorShape. - free wheelShape. - free bodyShape. - - super destroy. -} - -CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { - % A heavy duty version of OBJECT(CeldasLightVehicle), this - % vehicle is heavier and harder to control, but more stable - % at higher speeds. - +variables: - lSensor, rSensor, fSensor, bSensor (object). - lfWheel,rfWheel,lbWheel,rbWheel (object). - tleft,tright (int). - avanzando,retrocediendo,girando_izq,girando_der(int). - iterate(int). - teorias (list). - sa (object). - teoria (object). - entorno (hash). - datos-finales (hash). - plan_finished (int). - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. - - + to set-global-velocity to velocity (float): - rfWheel set-velocity to velocity. - lfWheel set-velocity to velocity. - rbWheel set-velocity to velocity. - lbWheel set-velocity to velocity. - - + to get-global-velocity: - return ((rfWheel get-velocity) + (lfWheel get-velocity)) / 2. - - + to turn-right: - tright++. - - self rotate around-axis (0,1,0) by (-1.5709/CELDAS_TURNO)*tright. - - if (tright == CELDAS_TURNO): tright=0. - - - + to turn-left: - tleft++. - - self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft. - - if (tleft == CELDAS_TURNO): tleft=0. - - - + to get-sensor-value: - return (fSensor get-sensor-value). - - +to update-entorno: - entorno{"sensor_f"} = (fSensor get-data). - entorno{"sensor_b"} = (bSensor get-data). - entorno{"sensor_r"} = (rSensor get-data). - entorno{"sensor_l"} = (lSensor get-data). - entorno{"movido"} = 0. # TODO - sa update-entorno with entorno. - - +to init: - # Configuracion de robot - fSensor = (self add-sensor at (2.0, .4, 0)). - fSensor set-direction to (1,0,0). - #fSensor set-direction to (0,0,1). - fSensor set-id at 1. - fSensor set-body at self. - bSensor = (self add-sensor at (-2.0, .4, 0)). - bSensor set-direction to (-1,0,0). - #bSensor set-direction to (0,0,1). - bSensor set-id at 2. - bSensor set-body at self. - lSensor = (self add-sensor at (0, .4, 1.5)). - lSensor set-direction to (0,0,1). - #lSensor set-direction to (1,0,0). - lSensor set-id at 3. - lSensor set-body at self. - - rSensor = (self add-sensor at (0, .4, -1.5)). - rSensor set-direction to (0,0,-1). - #rSensor set-direction to (-1,0,0). - rSensor set-id at 4. - rSensor set-body at self. - - lfWheel = (self add-wheel at (2, 0, -1.5)). - lbWheel = (self add-wheel at (-2, 0, -1.5)). - rfWheel = (self add-wheel at (2, 0, 1.5)). - rbWheel = (self add-wheel at (-2, 0, 1.5)). - - tleft=tright=0. - avanzando=0. - retrocediendo=0. - girando_izq=0. - girando_der=0. - - # Configuracion de sistema autonomo - sa = new SistemaAutonomo. - iterate = 0. - plan_finished = 1. # así planificamos apenas empezamos - - teorias = 4 new Teorias. - teorias{0} init named "Avanzar" with-action "adelante". - teorias{0} set-dato-inicial name "sensor_f" value 0. - teorias{0} set-dato-inicial name "sensor_b" value ANY. - teorias{0} set-dato-inicial name "sensor_r" value ANY. - teorias{0} set-dato-inicial name "sensor_l" value ANY. - teorias{0} set-dato-inicial name "movido" value ANY. - teorias{0} set-dato-final name "sensor_f" value ANY. - teorias{0} set-dato-final name "sensor_b" value ANY. - teorias{0} set-dato-final name "sensor_r" value ANY. - teorias{0} set-dato-final name "sensor_l" value ANY. - teorias{0} set-dato-final name "movido" value 1. - - teorias{1} init named "Retroceder" with-action "atras". - teorias{1} set-dato-inicial name "sensor_f" value 1. - teorias{1} set-dato-inicial name "sensor_b" value ANY. - teorias{1} set-dato-inicial name "sensor_r" value ANY. - teorias{1} set-dato-inicial name "sensor_l" value ANY. - teorias{1} set-dato-inicial name "movido" value ANY. - teorias{1} set-dato-final name "sensor_f" value 0. - teorias{1} set-dato-final name "sensor_b" value ANY. - teorias{1} set-dato-final name "sensor_r" value ANY. - teorias{1} set-dato-final name "sensor_l" value ANY. - teorias{1} set-dato-final name "movido" value 1. - - teorias{2} init named "Rotar a derecha" with-action "derecha". - teorias{2} set-dato-inicial name "sensor_f" value 1. - teorias{2} set-dato-inicial name "sensor_b" value ANY. - teorias{2} set-dato-inicial name "sensor_r" value ANY. - teorias{2} set-dato-inicial name "sensor_l" value ANY. - teorias{2} set-dato-inicial name "movido" value ANY. - teorias{2} set-dato-final name "sensor_f" value 0. - teorias{2} set-dato-final name "sensor_b" value ANY. - teorias{2} set-dato-final name "sensor_r" value ANY. - teorias{2} set-dato-final name "sensor_l" value 1. - teorias{2} set-dato-final name "movido" value 0. - - teorias{3} init named "Rotar a izquierda" with-action "izquierda". - teorias{3} set-dato-inicial name "sensor_f" value 1. - teorias{3} set-dato-inicial name "sensor_b" value ANY. - teorias{3} set-dato-inicial name "sensor_r" value ANY. - teorias{3} set-dato-inicial name "sensor_l" value ANY. - teorias{3} set-dato-inicial name "movido" value ANY. - teorias{3} set-dato-final name "sensor_f" value 0. - teorias{3} set-dato-final name "sensor_b" value ANY. - teorias{3} set-dato-final name "sensor_r" value 1. - teorias{3} set-dato-final name "sensor_l" value ANY. - teorias{3} set-dato-final name "movido" value 0. - - sa add teoria teorias{0}. - sa add teoria teorias{1}. - sa add teoria teorias{2}. - sa add teoria teorias{3}. - - datos-finales{"movido"} = 1. - sa update-datos-finales with datos-finales. - - +to iterate: - fl, fr(float). - - if (0): # TODO posicion_final == posicion_actual - { - print "Llegamos al FINAL!!!". - return. - } - - if (plan_finished): - { - self update-entorno. - sa plan. # Si no tenemos plan, lo hacemos - plan_finished = 0. - # TODO posicion_inicial = posicion_actual - if (! sa-has-next-theory): - { - print "El planificador no encuentra PLAN!!!". - return. - } - } - - if (iterate == 0): - { - print "iteracion 0". - if (sa has-next-theory): - { - print "hay teoria". - teoria = sa get-next-theory. - if ((teoria get-accion) == "adelante"): - { - avanzando = 1. - retrocediendo = 0. - girando_izq = 0. - girando_der = 0. - } - if ((teoria get-accion) == "atras"): - { - avanzando = 0. - retrocediendo = 1. - girando_izq = 0. - girando_der = 0. - } - if ((teoria get-accion) == "izquierda"): - { - avanzando = 0. - retrocediendo = 0. - girando_izq = 1. - girando_der = 0. - } - if ((teoria get-accion) == "derecha"): - { - avanzando = 0. - retrocediendo = 0. - girando_izq = 0. - girando_der = 1. - } - } - } - - if (iterate == CELDAS_TURNO): - { - self update-entorno. - # TODO if (posicion_actual == posicion_inicial): movido = false. else movido = true. - if (sa validate theory teoria): - { - print "valida". - } - else - { - print "Teoria no valida". - plan_finished = 1. - } - } - - iterate++. - if (iterate == CELDAS_TURNO + 1): - iterate = 0. - - # Movimiento del robot - if (avanzando): - self set-global-velocity to (15). - if (retrocediendo): - self set-global-velocity to (-15). - if (girando_izq): - self turn-left. - if (girando_der): - self turn-right. - -} - -Stationary : CeldasObstacle (aka CeldasObstacles) { - % A CeldasObstacle is used in conjunction with OBJECT(CeldasControl) - % and OBJECT(CeldasVehicle). It is what the OBJECT(CeldasSensor) - % objects on the CeldasVehicle detect. - %

- % There are no special behaviors associated with the walls--they're - % basically just plain OBJECT(Stationary) objects. - - +variables: - large (float). - direction (vector). - - - + to init with-size theSize = (10, 3, .1) (vector) with-color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 0, 0, 1 ), ( 0, 1, 0 ), ( 1, 0, 0 ) ] (matrix): - self init-with-shape shape (new Shape init-with-cube size theSize) color theColor at-location theLocation with-rotation theRotation. - large=20. - - + to init-with-shape shape theShape (object) color theColor = (1, 0, 0) (vector) at-location theLocation = (0, 0, 0) (vector) with-rotation theRotation = [ ( 1, 0, 0 ), ( 0, 1, 0 ), ( 0, 0, 1 ) ] (matrix): - self register with-shape theShape at-location theLocation with-rotation theRotation. - self set-color to theColor. - - + to get-large: - return large. - - + to set-direction at theDirection (vector): - direction=theDirection. - - + to get-direction: - return direction. -} - -Link : CeldasWheel (aka CeldasWheels) { - % A CeldasWheel is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a wheel to the vehicle. - - + variables: - joint (object). - velocity (float). - - + to init: - velocity = 0. - - - to set-joint to j (object): - % Used internally. - - joint = j. - - + section "Configuring the Wheel's Velocity" - - + to set-velocity to n (float): - % Sets the velocity of this wheel. - - if n > CELDAS_MAX_VELOCITY: n = CELDAS_MAX_VELOCITY. - velocity = n. - - joint set-joint-velocity to velocity. - - + to get-velocity: - % Gets the velocity of this wheel. - - return velocity. - -} - -Link : CeldasSensor (aka CeldasSensors) { - % A CeldasSensor is used in conjunction with OBJECT(CeldasVehicle) - % to build Celdas vehicles. This class is typically not instantiated - % manually, since OBJECT(CeldasVehicle) creates one for you when you - % add a sensor to the vehicle. - - + variables: - direction (vector). - positiveDirection(vector). - sensorAngle (float). - value (float). - draw (object). - body(object). - id(int). - - + to init : - direction = (1,0,1). - positiveDirection= (1,0,1). - sensorAngle = 1.6. - value = 0.0. - draw = new Drawing. - - - + section "Configuring the Sensor Values" - + to set-id at n (int): - id=n. - - + to set-body at robotBody(object): - body=robotBody. - - + to set-sensor-angle to n (float): - % Sets the angle in which this sensor can detect obstacles. The default - % value of 1.6 means that the sensor can see most of everything in - % front of it. Setting the value to be any higher leads to general - % wackiness, so I don't suggest it. - - sensorAngle = n. - - + to set-direction to n (vector): - direction = n. - positiveDirection::x=|n::x|. - positiveDirection::y=|n::y|. - positiveDirection::z=|n::z|. - - + section "Getting the Sensor Values" - - + to get-sensor-value: - % Gets the sensor value. This should be used from post-iterate, - % if not, the sensor reading correspond to the previous - % iteration. - - #+ to iterate: - - + to get-data: - i (object). - min,dist (float). - v,obs(vector). - aux(float). - j (int). - des2,des3(int). - wallBegin,wallEnd,wallCenter (float). - - toObstacle(vector). - largeWall (float). - - obsLoc (vector). - location (vector). - posObstacle,destiny,yo(vector). - - draw clear. - value = 0.0. - j=0. - min=0. - foreach i in (all CeldasObstacles): - { - posObstacle=i get-location. - v = (body get-location) - (self get-location ). - obsLoc::y=posObstacle::y. - - if (dot((i get-direction),(1,0,0))): - { - obsLoc::x=((self get-location)::x + ((posObstacle::z - (self get-location)::z)*v::x/v::z)). - obsLoc::z=posObstacle::z. - } - else - { - obsLoc::z=((self get-location)::z + ((posObstacle::x - (self get-location)::x)*v::z/v::x)). - obsLoc::x=posObstacle::x. - } - - #! - if(dot((i get-direction),direction)==0): - des1=1. - else - des1=0. - !# - - des2=0. - if(dot(direction,(1,1,1))<0): - { - if((dot((self get-location),positiveDirection))>(dot(obsLoc,positiveDirection))): - des2=1. - } - else - { - if((dot((self get-location),positiveDirection))<(dot(obsLoc,positiveDirection))): - des2=1. - } - - - #Compruebo que el robot este frente a la pared - wallCenter=dot((i get-location),(i get-direction)). - wallBegin=wallCenter- (i get-large)/2. - wallEnd=wallCenter + (i get-large)/2. - - - yo=self get-location. - destiny=i get-direction. - - - - if (dot((self get-location),(i get-direction)) > wallBegin) && (dot((self get-location),(i get-direction)) < wallEnd): - des3=1. - else - { - des3=0. - - } - - if ((des2) && (des3)): - { - draw clear. - - dist=|obsLoc - (self get-location)|. - if( (j==0) || (min>dist) ): - { - min=dist. - obs=obsLoc. - j++. - #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ". - } - - } - - - } #end for - - if(j!=0): - { - #Dibujo el laser - draw set-color to (1, 0, 0). - draw draw-line from (self get-location) to (obs). - return min. - } - - - value = -1. - return value. - - -} - diff --git a/trunk/src/breve/robot/Demo-2wheels2-2.tz b/trunk/src/breve/robot/Demo-2wheels2-2.tz deleted file mode 100644 index 2c3ad99..0000000 --- a/trunk/src/breve/robot/Demo-2wheels2-2.tz +++ /dev/null @@ -1,24 +0,0 @@ - -@use Celdas-2-2. - -@define CELDAS_MAX_TURN_VELOCITY 2. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - vehicle (object). - n (int). - - + to init: - - new CeldasObstacle init at-location (0,1,0). - new CeldasObstacle init at-location (-25,1,0). - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (-20, 0.8, -3). - - vehicle set-global-velocity to 15.0. -} diff --git a/trunk/src/breve/robot/Demo-2wheels2-3.tz b/trunk/src/breve/robot/Demo-2wheels2-3.tz deleted file mode 100644 index 9bc0ceb..0000000 --- a/trunk/src/breve/robot/Demo-2wheels2-3.tz +++ /dev/null @@ -1,24 +0,0 @@ - -@use Celdas-2-3. - -@define CELDAS_MAX_TURN_VELOCITY 2. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - vehicle (object). - n (int). - - + to init: - - new CeldasObstacle init at-location (0,1,0). - new CeldasObstacle init at-location (-25,1,0). - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (-20, 0.8, -3). - - vehicle set-global-velocity to 15.0. -} diff --git a/trunk/src/breve/robot/Demo-2wheels2-5.tz b/trunk/src/breve/robot/Demo-2wheels2-5.tz deleted file mode 100644 index dd3f534..0000000 --- a/trunk/src/breve/robot/Demo-2wheels2-5.tz +++ /dev/null @@ -1,23 +0,0 @@ - -@use Celdas-2-6. - -@define CELDAS_MAX_TURN_VELOCITY 2. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - vehicle (object). - n (int). - - + to init: - obs(object). - - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (-20, 0.8, -3). - - vehicle set-global-velocity to 15.0. -} diff --git a/trunk/src/breve/robot/laberintov4.tz b/trunk/src/breve/robot/laberintov4.tz deleted file mode 100644 index 488ae42..0000000 --- a/trunk/src/breve/robot/laberintov4.tz +++ /dev/null @@ -1,198 +0,0 @@ -@use Control. -@use Stationary. -@use Celdas-2-7. - -@define altoPared 5. -@define posYPared 25. -@define seccion 20. -@define distanciaTotalX 240. -@define distanciaTotalZ 240. - -Controller myControl. - - -CeldasObstacle : Wall{ - - - +to Create to-posX posX = 0 (float) to-posY posY = 2.5 (float) to-posZ posZ = 0 (float) to-widthX widthX = 5(float) to-widthZ widthZ = 5(float): - - if(widthX>widthZ): - { - large=widthX. - direction=(1,0,0). - } - else - { - large=widthZ. - direction=(0,0,1). - } - self register with-shape (new Cube init-with size (widthX,altoPared,widthZ)) at-location (posX,posY,posZ). - self set-color to (0,1,0). - - -} - - -CeldasObstacle : Labyrinth{ - - +to init: - wall(object). - - wall=new Wall. - #Contorno del laberinto - wall Create to-widthX 11.25*seccion. - wall=new Wall. - wall Create to-posX -5.5*seccion to-widthX 5 to-widthZ 11.25*seccion to-posZ 5.5*seccion . - wall=new Wall. - wall Create to-posX -5.5*seccion to-widthX 5 to-widthZ 11.25*seccion to-posZ 5.5*seccion to-posX 5.5*seccion . - wall=new Wall. - wall Create to-widthX 5.25*seccion to-posZ 11*seccion to-posX -3*seccion. - wall=new Wall. - wall Create to-widthX 5.25*seccion to-posZ 11*seccion to-posX 3*seccion. - #fin contorno - - #Paredesd verticales (en el diagrama) - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 10.5*seccion to-posX 0.5*seccion. - wall=new Wall. - wall Create to-widthZ 2*seccion to-widthX 5 to-posZ 10*seccion to-posX -1.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 10.5*seccion to-posX -3.5*seccion. - - wall=new Wall. - wall Create to-widthZ 2*seccion to-widthX 5 to-posZ 9*seccion to-posX -0.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 9.5*seccion to-posX -4.5*seccion. - wall=new Wall. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 8.5*seccion to-posX -2.5*seccion. - wall=new Wall. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 8.5*seccion to-posX 3.5*seccion. - - wall=new Wall. - wall Create to-widthZ 5*seccion to-widthX 5 to-posZ 5.5*seccion to-posX -4.5*seccion. - wall=new Wall. - wall Create to-widthZ 6*seccion to-widthX 5 to-posZ 4*seccion to-posX -3.5*seccion. - wall=new Wall. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 4.5*seccion to-posX -2.5*seccion. - wall=new Wall. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 5.5*seccion to-posX -1.5*seccion. - - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 2.5*seccion to-posX 0.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 1.5*seccion to-posX 1.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 4.5*seccion to-posX 1.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 6.5*seccion to-posX 1.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 2.5*seccion to-posX -1.5*seccion. - - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 1.5*seccion to-posX -2.5*seccion. - - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 3.5*seccion to-posX -0.5*seccion. - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 3.5*seccion to-posX 2.5*seccion. - - wall=new Wall. - wall Create to-widthZ 2*seccion to-widthX 5 to-posZ 7*seccion to-posX 2.5*seccion. - - wall=new Wall. - wall Create to-widthZ seccion to-widthX 5 to-posZ 4.5*seccion to-posX 3.5*seccion. - - wall=new Wall. - wall Create to-widthZ 6*seccion to-widthX 5 to-posZ 6*seccion to-posX 4.5*seccion. - - wall=new Wall. - #Paredes horizontales (en el diagrama) - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 10*seccion to-posX 1.5*seccion. #1 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 10*seccion to-posX 4.5*seccion. #2 - - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 9*seccion to-posX -3.5*seccion. #3 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 8*seccion to-posX -4*seccion. #4 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 5.25*seccion to-posZ 8*seccion to-posX 0. #5 - - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 3*seccion to-posZ 9*seccion to-posX 2*seccion. #6 - - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 7*seccion to-posX -3*seccion. #7 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 3.25*seccion to-posZ 7*seccion to-posX 0. #8 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 6*seccion to-posX 3.5*seccion. #9 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 6*seccion to-posX -2*seccion. #10 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 3.25*seccion to-posZ 4*seccion to-posX 0. #11 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 5*seccion to-posX 2.5*seccion. #12 - - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 3*seccion to-posX -4*seccion. #13 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 3*seccion to-posX -2*seccion. #14 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 4.25*seccion to-posZ 3*seccion to-posX 2.5*seccion. #15 - - #wall Create to-widthZ 5 to-widthX 4*seccion to-posZ 3*seccion to-posX 2.5*seccion. #15 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX seccion to-posZ 2*seccion to-posX -5*seccion. #16 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 2*seccion to-posX -0.5*seccion. #17 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 4.25*seccion to-posZ 2*seccion to-posX 3.5*seccion. #18 - - wall=new Wall. - wall Create to-widthZ 5 to-widthX 9*seccion to-posZ 1*seccion to-posX 0. #19 - -} - - -Control: myControl{ -+ variables: - agent(object). - pared(object). - labe(object). - - sensor (object). - vehicle (object). - -+ to init: - self point-camera at (0,0,0) from (200,200,200). - new Floor. - - labe = new Labyrinth. - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (0, 0, 10). - -+to iterate: - super iterate. - -} - -- 2.43.0