% at higher speeds.\r
+variables:\r
lSensor, rSensor, fSensor, bSensor (object).\r
- lWheel,rWheel (object). \r
+ lWheel,rWheel (object).\r
+ tleft,tright (int). \r
+ \r
\r
- to get-density:\r
return 20.0.\r
+ to get-global-velocity:\r
return ((rWheel get-velocity) + (lWheel get-velocity)) / 2.\r
\r
- + to turn-right with-velocity velocity (float): \r
- lWheel set-velocity to velocity.\r
- rWheel set-velocity to -velocity.\r
+ + to turn-right: \r
+ tright++.\r
+\r
+ self rotate around-axis (0,1,0) by (-1.5709/10)*tright. \r
+ \r
+ if(tright==10): tright=0.\r
+\r
+\r
+ + to turn-left:\r
+ tleft++.\r
+\r
+ self rotate around-axis (0,1,0) by (1.5709/10)*tleft. \r
+ \r
+ if(tleft==10): tleft=0.\r
\r
- + to turn-left with-velocity velocity (float):\r
-# vehicle rotate around-axis (0,1,0) by 1. \r
- lWheel set-velocity to -velocity. \r
- rWheel set-velocity to velocity.\r
\r
+ to get-sensor-value:\r
return (fSensor get-sensor-value).\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
+ lWheel = (self add-wheel at (0, 0, -1.5)).\r
+ rWheel = (self add-wheel at (0, 0, 1.5)).\r
+\r
+ tleft=tright=1. #Debe ser inicializado en 0 esta asi para probar!!!!!!!!!!!!!!!!!!!!!!!!\r
\r
- +to iterate: \r
+ +to iterate:\r
#+ to post-iterate:\r
valuef,valueb,valuer,valuel (float).\r
fl, fr(float).\r
valueb=bSensor get-data.\r
valuel=lSensor get-data.\r
valuer=rSensor get-data.\r
+ \r
+ \r
+ if(tright>0):\r
+ self turn-right.\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
+\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
+ #}\r
#print "sensor valuef: $valuef valueb: $valueb".\r
\r
#else if value < 0.1: self turn-left with-velocity CELDAS_MAX_TURN_VELOCITY.\r
v,obs(vector).\r
aux(float).\r
j (int).\r
- des1,des2,des3(int).\r
+ des2,des3(int).\r
wallBegin,wallEnd,wallCenter (float).\r
\r
- aux1,aux2,aux3,aux4 (float).\r
- yo,toObstacle, transDir (vector).\r
+ toObstacle(vector).\r
largeWall (float).\r
- source,destiny (vector).\r
+ \r
obsLoc (vector). \r
location (vector).\r
- posObstacle,posSensor (vector).\r
+ posObstacle,destiny,yo(vector).\r
\r
draw clear.\r
value = 0.0.\r
\r
} \r
\r
- aux1=dot((self get-location),(i get-direction)).\r
+ #aux1=dot((self get-location),(i get-direction)).\r
\r
#print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".\r
- #print "dist: $aux1 begin: $wallBegin end: $wallEnd ".\r
+ #print "begin: $wallBegin end: $wallEnd ".\r
#print "begin: $wallBegin end: $wallEnd".\r
\r
\r
- if ((i get-location)::z==20):\r
- print "------>sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo des2: $des2 des1: $des1". \r
\r
#print "sensor: $id , des1: $des1, des2: $des2, des3: $des3".\r
if ((des2) && (des3)):\r
draw clear. \r
#print " posObstacle: $posObstacle". \r
\r
- #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".\r
- #print "dist: $aux1 begin: $wallBegin end: $wallEnd ".\r
-\r
-\r
+ print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ".\r
+ print "begin: $wallBegin end: $wallEnd ".\r
\r
\r
-\r
dist=|obsLoc - (self get-location)|.\r
if( (j==0) || (min>dist) ):\r
{\r
min=dist.\r
obs=obsLoc.\r
j++.\r
- print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ". \r
+ #print "sensor: $id obstaculo: $posObstacle direP: $destiny direS: $direction yo: $yo ". \r
}\r
\r
} \r
-@use Celdas-2-5.
+@use Celdas-2-6.
\r
@define CELDAS_MAX_TURN_VELOCITY 2.\r
+ to init: \r
obs(object).\r
- \r
- obs = new CeldasObstacle .
- obs init at-location (0,1,10)with-size (20,3,1).\r
- obs set-direction at (0,0,1) .\r
- \r
- obs = new CeldasObstacle. \r
- obs init at-location (-25,1,0) with-size (20,3,1).\r
- obs set-direction at (0,0,1).\r
- \r
- obs = new CeldasObstacle.\r
- obs init at-location (-10,1,-10) with-size (1,3,20).\r
- obs set-direction at (1,0,0).\r
-
- obs = new CeldasObstacle.\r
- obs init at-location (-10,1,10) with-size (1,3,20).\r
- obs set-direction at (1,0,0).\r
-
- obs = new CeldasObstacle.\r
- obs init at-location (10,1,10) with-size (1,3,20).\r
- obs set-direction at (1,0,0).\r
+\r
\r
vehicle = new CeldasVehicle.
self watch item vehicle.