From d2d8f6e6f3a8692e7d2711644258c1b53daac63a Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sat, 16 Dec 2006 23:37:10 +0000 Subject: [PATCH] =?utf8?q?Reestructuraci=C3=B3n=20y=20limpieza=20de=20arch?= =?utf8?q?ivos=20viejos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- trunk/src/breve/Celdas.tz | 265 ------------------- trunk/src/breve/CeldasMultiSensor.tz | 262 ------------------ trunk/src/breve/Demo-2wheels.tz | 69 ----- trunk/src/breve/Demo-4wheels.tz | 79 ------ trunk/src/breve/Demo-multi-sensor.tz | 47 ---- trunk/src/breve/Demo-myvehicle-4wheels.tz | 81 ------ trunk/src/breve/Demo.tz | 47 ---- trunk/src/breve/Laberinto.tz | 151 ----------- trunk/src/{ => breve}/SistemaAutonomo.tz | 0 trunk/src/{ => breve}/SistemaAutonomoDemo.tz | 0 10 files changed, 1001 deletions(-) delete mode 100644 trunk/src/breve/Celdas.tz delete mode 100644 trunk/src/breve/CeldasMultiSensor.tz delete mode 100644 trunk/src/breve/Demo-2wheels.tz delete mode 100644 trunk/src/breve/Demo-4wheels.tz delete mode 100644 trunk/src/breve/Demo-multi-sensor.tz delete mode 100644 trunk/src/breve/Demo-myvehicle-4wheels.tz delete mode 100644 trunk/src/breve/Demo.tz delete mode 100644 trunk/src/breve/Laberinto.tz rename trunk/src/{ => breve}/SistemaAutonomo.tz (100%) rename trunk/src/{ => breve}/SistemaAutonomoDemo.tz (100%) diff --git a/trunk/src/breve/Celdas.tz b/trunk/src/breve/Celdas.tz deleted file mode 100644 index b9a63fb..0000000 --- a/trunk/src/breve/Celdas.tz +++ /dev/null @@ -1,265 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. - -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): - % 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-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. - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. -} - -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. - - + 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. - - + 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. -} - -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). - - - 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. - - joint set-joint-velocity to n. - - + to get-velocity: - % Gets the velocity of this wheel. - - return (joint get-joint-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). - sensorAngle (float). - value (float). - - + to init: - direction = (0, 1, 0). - sensorAngle = 1.6. - value = 0.0. - - + section "Configuring the Sensor Values" - - + 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. - - + 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. - - return value. - - + to iterate: - i (object). - strength, angle (float). - toObstacle, transDir (vector). - - transDir = (self get-rotation) * direction. - - value = 0.0. - - foreach i in (all CeldasObstacles): { - toObstacle = (i get-location) - (self get-location). - angle = angle(toObstacle, transDir). - - if angle < sensorAngle: { - strength = | (self get-location) - (i get-location) |. - strength = 100.0 / (strength * strength) . - - if strength > value: value = strength. - } - } - -} diff --git a/trunk/src/breve/CeldasMultiSensor.tz b/trunk/src/breve/CeldasMultiSensor.tz deleted file mode 100644 index e85342e..0000000 --- a/trunk/src/breve/CeldasMultiSensor.tz +++ /dev/null @@ -1,262 +0,0 @@ -@use PhysicalControl. -@use Shape. -@use Stationary. -@use Link. -@use MultiBody. - -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). - - + 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. - - return wheel. - - + to add-sensor at location (vector) with-rotation angle = -1.57 (float) - arround-axis axis = (0, 0, 1) (vector) - with-normal normal = (1, 0, 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-shape to sensorShape. - - joint = new RevoluteJoint. - - joint set-relative-rotation around-axis axis by angle. - joint link parent bodyLink to-child sensor with-normal normal - 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). - - 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. - - - to get-density: - return 20.0. - - - to get-wheel-width: - return 0.4. - - - to get-wheel-radius: - return 0.8. -} - -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. - - + 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. - - + 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. -} - -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). - - - 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. - - joint set-joint-velocity to n. - - + to get-velocity: - % Gets the velocity of this wheel. - - return (joint get-joint-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). - sensorAngle (float). - value (float). - - + to init with-direction theDirection = (0, 1, 0) (vector) - with-angle theAngle = 1.6 (float): - direction = theDirection. - sensorAngle = theAngle. - value = 0.0. - - + section "Configuring the Sensor Values" - - + 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. - - + 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. - - return value. - - + to iterate: - i (object). - strength, angle (float). - toObstacle, transDir (vector). - - transDir = (self get-rotation) * direction. - - value = 0.0. - - foreach i in (all CeldasObstacles): { - toObstacle = (i get-location) - (self get-location). - angle = angle(toObstacle, transDir). - - print "angle: $angle -- sensorAngle = $sensorAngle". - if angle < sensorAngle: { - strength = | (self get-location) - (i get-location) |. - strength = 100.0 / (strength * strength) . - - if strength > value: value = strength. - } - } - -} diff --git a/trunk/src/breve/Demo-2wheels.tz b/trunk/src/breve/Demo-2wheels.tz deleted file mode 100644 index 4c4c45b..0000000 --- a/trunk/src/breve/Demo-2wheels.tz +++ /dev/null @@ -1,69 +0,0 @@ - -@use Celdas. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - sensor (object). - blWheel, brWheel (object). - vehicle (object). - - n (int). - - + to init: - for n=0, n<10, n++: - new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)). - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (10, 0.8, 5). - - blWheel = (vehicle add-wheel at (0, 0, -1.5)). - brWheel = (vehicle add-wheel at (0, 0, 1.5)). - - self set-global-velocity to 15.0. - - sensor = (vehicle add-sensor at (2.0, .4, 0)). - - + to set-global-velocity to velocity (float): - - brWheel set-velocity to velocity. - blWheel set-velocity to velocity. - - + to get-global-velocity: - - return ((brWheel get-velocity) - + (blWheel get-velocity)) / 2. - - + to turn-right with-velocity velocity (float): - - brWheel set-velocity to velocity. - blWheel set-velocity to -velocity. - - + to turn-left with-velocity velocity (float): - - blWheel set-velocity to velocity. - brWheel set-velocity to -velocity. - - + to get-sensor-value: - - return (sensor get-sensor-value). - - - + to post-iterate: - value (float). - bl, br (float). - - value = self get-sensor-value. - - if value < 1: self set-global-velocity to ((self get-global-velocity) + 1). - else if value > 5: self turn-right with-velocity 15.0. - #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1). - - bl = (blWheel get-velocity). - br = (brWheel get-velocity). - print "sensor: $value, br: $br, bl: $bl". - -} diff --git a/trunk/src/breve/Demo-4wheels.tz b/trunk/src/breve/Demo-4wheels.tz deleted file mode 100644 index 943de3b..0000000 --- a/trunk/src/breve/Demo-4wheels.tz +++ /dev/null @@ -1,79 +0,0 @@ - -@use Celdas. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - sensor (object). - flWheel, frWheel, blWheel, brWheel (object). - vehicle (object). - - n (int). - - + to init: - for n=0, n<10, n++: - new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)). - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (10, 0.8, 5). - - flWheel = (vehicle add-wheel at (2, 0, -1.5)). - frWheel = (vehicle add-wheel at (2, 0, 1.5)). - blWheel = (vehicle add-wheel at (-2, 0, -1.5)). - brWheel = (vehicle add-wheel at (-2, 0, 1.5)). - - self set-global-velocity to 15.0. - - sensor = (vehicle add-sensor at (2.0, .4, 0)). - - + to set-global-velocity to velocity (float): - - brWheel set-velocity to velocity. - frWheel set-velocity to velocity. - blWheel set-velocity to velocity. - flWheel set-velocity to velocity. - - + to get-global-velocity: - - return ((brWheel get-velocity) + (frWheel get-velocity) - + (blWheel get-velocity) + (flWheel set-velocity)) / 4. - - + to turn-right with-velocity velocity (float): - - brWheel set-velocity to velocity. - frWheel set-velocity to velocity. - blWheel set-velocity to -velocity. - flWheel set-velocity to -velocity. - - + to turn-left with-velocity velocity (float): - - blWheel set-velocity to velocity. - flWheel set-velocity to velocity. - brWheel set-velocity to -velocity. - frWheel set-velocity to -velocity. - - + to get-sensor-value: - - return (sensor get-sensor-value). - - - + to post-iterate: - value (float). - fl, fr, bl, br (float). - - value = self get-sensor-value. - - if value < 1: self set-global-velocity to ((self get-global-velocity) + 1). - else if value > 5: self turn-right with-velocity 15.0. - #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1). - - fl = (flWheel get-velocity). - bl = (blWheel get-velocity). - fr = (frWheel get-velocity). - br = (brWheel get-velocity). - print "sensor: $value, fr: $fr, fl: $fl, br: $br, bl: $bl". - -} diff --git a/trunk/src/breve/Demo-multi-sensor.tz b/trunk/src/breve/Demo-multi-sensor.tz deleted file mode 100644 index 880d3b1..0000000 --- a/trunk/src/breve/Demo-multi-sensor.tz +++ /dev/null @@ -1,47 +0,0 @@ - -@use CeldasMultiSensor. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - leftWheel, rightWheel (object). - leftSensor, rightSensor (object). - vehicle (object). - - n (int). - - + to init: - for n=0, n<10, n++: - new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)). - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (10, 2, 5). - - leftWheel = (vehicle add-wheel at (-2, 0, -1.5)). - rightWheel = (vehicle add-wheel at (-2, 0, 1.5)). - vehicle add-wheel at (1, 0, 0). - - leftWheel set-velocity to 15.0. - rightWheel set-velocity to 15.0. - - leftSensor = (vehicle add-sensor at (2.0, .4, 0)). - rightSensor = (vehicle add-sensor at (2.0, .4, 0)). - - + to post-iterate: - valueL, valueR (float). - - valueL = leftSensor get-sensor-value. - valueR = rightSensor get-sensor-value. - - if valueL < 2: leftWheel set-velocity to ((leftWheel get-velocity) + 1). - else: leftWheel set-velocity to ((leftWheel get-velocity) - 1). - - if valueL < 2: rightWheel set-velocity to ((rightWheel get-velocity) + 1). - else: rightWheel set-velocity to ((rightWheel get-velocity) - 1). - - print "leftSensor = $valueL -- rightSensor = $valueR". - -} diff --git a/trunk/src/breve/Demo-myvehicle-4wheels.tz b/trunk/src/breve/Demo-myvehicle-4wheels.tz deleted file mode 100644 index 865681b..0000000 --- a/trunk/src/breve/Demo-myvehicle-4wheels.tz +++ /dev/null @@ -1,81 +0,0 @@ - -@use Celdas. - -Controller DemoController. - -CeldasVehicle : MyVehicle { - - + variables: - sensor (object). - flWheel, frWheel, blWheel, brWheel (object). - - + to init at location = (0, 0, 0) (vector): - - self move to location. - - blWheel = (self add-wheel at (2, 0, -1.5)). - brWheel = (self add-wheel at (2, 0, 1.5)). - blWheel = (self add-wheel at (-2, 0, -1.5)). - brWheel = (self add-wheel at (-2, 0, 1.5)). - - #blWheel set-velocity to 15.0. - #brWheel set-velocity to 15.0. - - sensor = (self add-sensor at (2.0, .4, 0)). - - + to set-global-velocity to velocity (float): - - brWheel set-velocity to velocity. - frWheel set-velocity to velocity. - blWheel set-velocity to velocity. - flWheel set-velocity to velocity. - - + to get-global-velocity: - - return ((brWheel get-velocity) + (frWheel get-velocity) - + (blWheel get-velocity) + (flWheel set-velocity)) / 4. - - + to turn-right with-velocity velocity (float): - - brWheel set-velocity to velocity. - frWheel set-velocity to velocity. - blWheel set-velocity to -velocity. - flWheel set-velocity to -velocity. - - + to turn-left with-velocity velocity (float): - - blWheel set-velocity to velocity. - flWheel set-velocity to velocity. - brWheel set-velocity to -velocity. - frWheel set-velocity to -velocity. - - + to get-sensor-value: - - return (sensor get-sensor-value). - -} - -CeldasControl : DemoController { - + variables: - vehicle (object). - - n (int). - - + to init: - for n=0, n<10, n++: - new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)). - - vehicle = new MyVehicle. - self watch item vehicle. - - + to post-iterate: - value (float). - - value = vehicle get-sensor-value. - - if value < 1: vehicle set-global-velocity to ((vehicle get-global-velocity) + 1). - else if value > 10: vehicle set-global-velocity to ((vehicle get-global-velocity) - 1). - - print value. - -} diff --git a/trunk/src/breve/Demo.tz b/trunk/src/breve/Demo.tz deleted file mode 100644 index 7794c3d..0000000 --- a/trunk/src/breve/Demo.tz +++ /dev/null @@ -1,47 +0,0 @@ - -@use Celdas. - -Controller DemoController. - -CeldasControl : DemoController { - + variables: - sensor (object). - leftWheel, rightWheel (object). - vehicle (object). - - n (int). - - + to init: - for n=0, n<10, n++: - new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)). - - vehicle = new CeldasVehicle. - self watch item vehicle. - - vehicle move to (10, 2, 5). - - leftWheel = (vehicle add-wheel at (-2, 0, -1.5)). - rightWheel = (vehicle add-wheel at (-2, 0, 1.5)). - vehicle add-wheel at (1, 0, 0). - - leftWheel set-velocity to 15.0. - rightWheel set-velocity to 15.0. - - sensor = (vehicle add-sensor at (2.0, .4, 0)). - - + to post-iterate: - value (float). - - value = sensor get-sensor-value. - - if value < 1: { - leftWheel set-velocity to ((leftWheel get-velocity) + 15). - rightWheel set-velocity to ((rightWheel get-velocity) + 15). - } else if value > 10: { - leftWheel set-velocity to ((leftWheel get-velocity) - 15). - rightWheel set-velocity to ((rightWheel get-velocity) - 15). - } - - print value. - -} diff --git a/trunk/src/breve/Laberinto.tz b/trunk/src/breve/Laberinto.tz deleted file mode 100644 index 83b5c16..0000000 --- a/trunk/src/breve/Laberinto.tz +++ /dev/null @@ -1,151 +0,0 @@ -@use Control. -@use Stationary. -@use Celdas. - -@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 = 120(float) to-widthZ widthZ = 5(float): - - 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 Create to-posX -5.5*seccion to-widthX 5 to-widthZ 11.25*seccion to-posZ 5.5*seccion . - 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 Create to-widthX 5.25*seccion to-posZ 11*seccion to-posX -3*seccion. - wall Create to-widthX 5.25*seccion to-posZ 11*seccion to-posX 3*seccion. - #fin contorno - - #Paredesd verticales (en el diagrama) - wall Create to-widthZ seccion to-widthX 5 to-posZ 10.5*seccion to-posX 0.5*seccion. - wall Create to-widthZ 2*seccion to-widthX 5 to-posZ 10*seccion to-posX -1.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 10.5*seccion to-posX -3.5*seccion. - - wall Create to-widthZ 2*seccion to-widthX 5 to-posZ 9*seccion to-posX -0.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 9.5*seccion to-posX -4.5*seccion. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 8.5*seccion to-posX -2.5*seccion. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 8.5*seccion to-posX 3.5*seccion. - - wall Create to-widthZ 5*seccion to-widthX 5 to-posZ 5.5*seccion to-posX -4.5*seccion. - wall Create to-widthZ 6*seccion to-widthX 5 to-posZ 4*seccion to-posX -3.5*seccion. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 4.5*seccion to-posX -2.5*seccion. - wall Create to-widthZ 3*seccion to-widthX 5 to-posZ 5.5*seccion to-posX -1.5*seccion. - - wall Create to-widthZ seccion to-widthX 5 to-posZ 2.5*seccion to-posX 0.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 1.5*seccion to-posX 1.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 4.5*seccion to-posX 1.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 6.5*seccion to-posX 1.5*seccion. - - wall Create to-widthZ seccion to-widthX 5 to-posZ 2.5*seccion to-posX -1.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 1.5*seccion to-posX -2.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 3.5*seccion to-posX -0.5*seccion. - - wall Create to-widthZ seccion to-widthX 5 to-posZ 3.5*seccion to-posX 2.5*seccion. - wall Create to-widthZ 2*seccion to-widthX 5 to-posZ 7*seccion to-posX 2.5*seccion. - wall Create to-widthZ seccion to-widthX 5 to-posZ 4.5*seccion to-posX 3.5*seccion. - - wall Create to-widthZ 6*seccion to-widthX 5 to-posZ 6*seccion to-posX 4.5*seccion. - - #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 Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 10*seccion to-posX 4.5*seccion. #2 - - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 9*seccion to-posX -3.5*seccion. #3 - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 8*seccion to-posX -4*seccion. #4 - wall Create to-widthZ 5 to-widthX 5.25*seccion to-posZ 8*seccion to-posX 0. #5 - - wall Create to-widthZ 5 to-widthX 3*seccion to-posZ 9*seccion to-posX 2*seccion. #6 - - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 7*seccion to-posX -3*seccion. #7 - wall Create to-widthZ 5 to-widthX 3.25*seccion to-posZ 7*seccion to-posX 0. #8 - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 6*seccion to-posX 3.5*seccion. #9 - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 6*seccion to-posX -2*seccion. #10 - - wall Create to-widthZ 5 to-widthX 3.25*seccion to-posZ 4*seccion to-posX 0. #11 - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 5*seccion to-posX 2.5*seccion. #12 - - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 3*seccion to-posX -4*seccion. #13 - wall Create to-widthZ 5 to-widthX 1.25*seccion to-posZ 3*seccion to-posX -2*seccion. #14 - 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 Create to-widthZ 5 to-widthX seccion to-posZ 2*seccion to-posX -5*seccion. #16 - wall Create to-widthZ 5 to-widthX 2.25*seccion to-posZ 2*seccion to-posX -0.5*seccion. #17 - wall Create to-widthZ 5 to-widthX 4.25*seccion to-posZ 2*seccion to-posX 3.5*seccion. #18 - - wall Create to-widthZ 5 to-widthX 9*seccion to-posZ 1*seccion to-posX 0. #19 - - #push wall onto walls. -} - - -Control: myControl{ -+ variables: - labe(object). - sensor (object). - leftWheel, rightWheel (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). - - leftWheel = (vehicle add-wheel at (-2, 0, -1.5)). - rightWheel = (vehicle add-wheel at (-2, 0, 1.5)). - vehicle add-wheel at (1, 0, 0). - - leftWheel set-velocity to 50.0. - rightWheel set-velocity to 50.0. - - sensor = (vehicle add-sensor at (2.0, .4, 0)). - - -+to iterate: - super iterate. - -+ to post-iterate: - value (float). - - value = sensor get-sensor-value. - - if value < 2: { - leftWheel set-velocity to ((leftWheel get-velocity) + 1). - rightWheel set-velocity to ((rightWheel get-velocity) + 1). - } - - if value > 2: { - leftWheel set-velocity to ((leftWheel get-velocity) - 1). - rightWheel set-velocity to ((rightWheel get-velocity) - 1). - } - - #print value. - -} - diff --git a/trunk/src/SistemaAutonomo.tz b/trunk/src/breve/SistemaAutonomo.tz similarity index 100% rename from trunk/src/SistemaAutonomo.tz rename to trunk/src/breve/SistemaAutonomo.tz diff --git a/trunk/src/SistemaAutonomoDemo.tz b/trunk/src/breve/SistemaAutonomoDemo.tz similarity index 100% rename from trunk/src/SistemaAutonomoDemo.tz rename to trunk/src/breve/SistemaAutonomoDemo.tz -- 2.43.0