]> git.llucax.com Git - z.facultad/75.68/celdas.git/commitdiff
(no commit message)
authorMarcelo Benitez <cmarcelobenitez@gmail.com>
Fri, 15 Dec 2006 21:32:17 +0000 (21:32 +0000)
committerMarcelo Benitez <cmarcelobenitez@gmail.com>
Fri, 15 Dec 2006 21:32:17 +0000 (21:32 +0000)
trunk/src/breve/robot/Celdas-2-6.tz
trunk/src/breve/robot/laberintov4.tz

index 1e3f9a6b8bd8d6106c8982ba5fe96fb6f4675a76..9756afe1a352e201635a80ca5d911fccf340fe0d 100644 (file)
@@ -160,10 +160,12 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) {
        % at higher speeds.\r
         +variables:\r
             lSensor, rSensor, fSensor, bSensor (object).\r
        % at higher speeds.\r
         +variables:\r
             lSensor, rSensor, fSensor, bSensor (object).\r
-            lWheel,rWheel (object).\r
+            lfWheel,rfWheel,lbWheel,rbWheel (object).\r
            tleft,tright (int).     \r
         \r
            tleft,tright (int).     \r
         \r
-        \r
+           avanzando,retrocediendo,girando(int).           \r
+           \r
+                   \r
        - to get-density:\r
                return 20.0.\r
 \r
        - to get-density:\r
                return 20.0.\r
 \r
@@ -174,11 +176,13 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) {
                return 0.8.\r
 \r
         + to set-global-velocity to velocity (float):\r
                return 0.8.\r
 \r
         + to set-global-velocity to velocity (float):\r
-               rWheel set-velocity to velocity.\r
-               lWheel set-velocity to velocity.\r
+               rfWheel set-velocity to velocity.\r
+               lfWheel set-velocity to velocity.\r
+               rbWheel set-velocity to velocity.\r
+               lbWheel set-velocity to velocity.\r
 \r
        + to get-global-velocity:\r
 \r
        + to get-global-velocity:\r
-               return ((rWheel get-velocity) + (lWheel get-velocity)) / 2.\r
+               return ((rfWheel get-velocity) + (lfWheel get-velocity)) / 2.\r
 \r
        + to turn-right:                \r
                tright++.\r
 \r
        + to turn-right:                \r
                tright++.\r
@@ -223,13 +227,17 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) {
             rSensor set-id at 4.\r
            rSensor set-body at self.\r
 \r
             rSensor set-id at 4.\r
            rSensor set-body at self.\r
 \r
-            lWheel = (self add-wheel at (0, 0, -1.5)).\r
-            rWheel = (self add-wheel at (0, 0, 1.5)).\r
+            lfWheel = (self add-wheel at (2, 0, -1.5)).\r
+            lbWheel = (self add-wheel at (-2, 0, -1.5)).\r
+            rfWheel = (self add-wheel at (2, 0, 1.5)).\r
+            rbWheel = (self add-wheel at (-2, 0, 1.5)).\r
 \r
 \r
-           tleft=tright=1.     #Debe ser inicializado en 0 esta asi para probar!!!!!!!!!!!!!!!!!!!!!!!!\r
-                        \r
+           tleft=tright=0.     #Debe ser inicializado en 0 esta asi para probar!!!!!!!!!!!!!!!!!!!!!!!!\r
+           avanzando=1.\r
+           retrocediendo=0.\r
+           girando=0.            \r
+            \r
         +to iterate:\r
         +to iterate:\r
-        #+ to post-iterate:\r
                valuef,valueb,valuer,valuel (float).\r
                fl, fr(float).\r
                \r
                valuef,valueb,valuer,valuel (float).\r
                fl, fr(float).\r
                \r
@@ -238,31 +246,51 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) {
                 valuel=lSensor get-data.\r
                 valuer=rSensor get-data.\r
                \r
                 valuel=lSensor get-data.\r
                 valuer=rSensor get-data.\r
                \r
-               \r
-               if(tright>0):\r
-                       self turn-right.\r
-               \r
+               print "senforl: $valuel".\r
 \r
 \r
+                if(avanzando):\r
+                       if(valuef>15):\r
+                               self set-global-velocity to (15).\r
+                       else \r
+                               {               \r
+                                avanzando=0.\r
+                                retrocediendo=1.\r
+                               }       \r
 \r
 \r
-               #self turn-left with-velocity(20).\r
-                #self set-global-velocity to (15).\r
-               #if valuef >7:          \r
-                #    self set-global-velocity to (15).\r
-                #else if (valuef <=7) && (valuef > 0):\r
-                #{   \r
-                    self set-global-velocity to (0).\r
-                    #self turn-left with-velocity(2).\r
-                    #self turn-right with-velocity(2).\r
-                    #self set-global-velocity to (0).\r
-               #}\r
-                #print "sensor valuef: $valuef  valueb: $valueb".\r
-                \r
-                #else if value < 0.1: self turn-left with-velocity CELDAS_MAX_TURN_VELOCITY.\r
-               #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1).\r
 \r
 \r
-               #fl = (flWheel get-velocity).\r
-               #fr = (frWheel get-velocity).\r
-               #print " sensorf: $value  sensorb $valueb, fr: $fr, fl: $fl".            \r
+               if(retrocediendo):\r
+                       if(valueb>15):\r
+                               self set-global-velocity to (-15).\r
+                       else \r
+                               {               \r
+                                tleft=1.\r
+                                retrocediendo=0.\r
+                               }\r
+\r
+\r
+               if((tleft) && (valuel>10)):                                             \r
+                       {\r
+                        #self set-global-velocity to (0).\r
+                        self turn-left.\r
+                       }\r
+               else\r
+                       {\r
+                        avanzando=1.\r
+                        #tright=1.\r
+                       }\r
+\r
+#!\r
+               if((tright) && (valuer>10)):                                            \r
+                       {\r
+                        #self set-global-velocity to (0).\r
+                        self turn-right.\r
+                       }\r
+               else\r
+                       {\r
+                        avanzando=1.\r
+                        #tright=1.\r
+                       }       \r
+!#     \r
             \r
 }\r
 \r
             \r
 }\r
 \r
@@ -460,30 +488,18 @@ Link : CeldasSensor (aka CeldasSensors) {
                                 des3=0.\r
                                 \r
                        }                               \r
                                 des3=0.\r
                                 \r
                        }                               \r
-\r
-                       #aux1=dot((self get-location),(i get-direction)).\r
-\r
-                       #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".\r
-                       #print "begin: $wallBegin end: $wallEnd ".\r
-                       #print "begin: $wallBegin end: $wallEnd".\r
-\r
                        \r
                        \r
-\r
-                       #print "sensor: $id , des1: $des1, des2: $des2, des3: $des3".\r
                        if ((des2) && (des3)):\r
                          {                                    \r
                        if ((des2) && (des3)):\r
                          {                                    \r
-                               draw clear.                             \r
-                               #print " posObstacle: $posObstacle".                                                    \r
-                               \r
-                       print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".\r
-                       print "begin: $wallBegin end: $wallEnd ".\r
-                                       \r
+                               draw clear.                                                     \r
 \r
                                dist=|obsLoc - (self get-location)|.\r
 \r
                                dist=|obsLoc - (self get-location)|.\r
+\r
                                if( (j==0) || (min>dist) ):\r
                                 {\r
                                        min=dist.\r
                                        obs=obsLoc.\r
                                if( (j==0) || (min>dist) ):\r
                                 {\r
                                        min=dist.\r
                                        obs=obsLoc.\r
+                                       \r
                                        j++.\r
                                        #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".        \r
                                 }\r
                                        j++.\r
                                        #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".        \r
                                 }\r
@@ -498,7 +514,7 @@ Link : CeldasSensor (aka CeldasSensors) {
                          #Dibujo el laser\r
                                  draw set-color to (1, 0, 0).\r
                          draw draw-line from (self get-location) to (obs).\r
                          #Dibujo el laser\r
                                  draw set-color to (1, 0, 0).\r
                          draw draw-line from (self get-location) to (obs).\r
-                         return dist.\r
+                         return min.\r
                        }\r
                \r
 \r
                        }\r
                \r
 \r
index 488ae4231700dcccc07167fc99c188aa27f4f6b2..157623ce794a28f95ca9ef22c81655f030c9c103 100644 (file)
@@ -1,6 +1,6 @@
 @use Control.\r
 @use Stationary.\r
 @use Control.\r
 @use Stationary.\r
-@use Celdas-2-7.\r
+@use Celdas-2-6.\r
 \r
 @define altoPared  5.\r
 @define posYPared 25.\r
 \r
 @define altoPared  5.\r
 @define posYPared 25.\r