@use Drawing.\r
@use SistemaAutonomo.\r
\r
-@define CELDAS_MAX_VELOCITY 30.\r
-@define CELDAS_TURNO 100.\r
+@define CELDAS_MAX_VELOCITY 5.\r
+@define CELDAS_TURNO 30.\r
@define CELDAS_SENSOR_THRESHOLD 10.\r
\r
PhysicalControl : CeldasControl {\r
return ((rfWheel get-velocity) + (lfWheel get-velocity)) / 2.\r
\r
+ to turn-right: \r
- tright++.\r
-\r
+ #tright++.\r
+ #self rotate around-axis (0,1,0) by (-1.5709/CELDAS_TURNO)*tright. \r
+ #if (tright == CELDAS_TURNO): tright=0.\r
+ if (tright == 0): self set-global-velocity to 0.\r
self rotate around-axis (0,1,0) by (-1.5709/CELDAS_TURNO)*tright. \r
- \r
if (tright == CELDAS_TURNO): tright=0.\r
+ else tright++.\r
\r
\r
+ to turn-left:\r
- tleft++.\r
-\r
- self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft. \r
- \r
+ #tleft++.\r
+ #self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft. \r
+ #if (tleft == CELDAS_TURNO): tleft=0.\r
+ if (tleft == 0): self set-global-velocity to 0.\r
+ self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft.\r
if (tleft == CELDAS_TURNO): tleft=0.\r
+ else tleft++.\r
\r
\r
+ to get-sensor-value:\r
teorias{0} set-dato-final name "sensor_l" value ANY.\r
teorias{0} set-dato-final name "movido" value 1.\r
\r
- teorias{1} init named "Retroceder" with-action "atras".\r
+ teorias{1} init named "Retroceder" with-action "atras" executed 2.\r
teorias{1} set-dato-inicial name "sensor_f" value 1.\r
teorias{1} set-dato-inicial name "sensor_b" value ANY.\r
teorias{1} set-dato-inicial name "sensor_r" value ANY.\r
teorias{2} set-dato-final name "sensor_l" value 1.\r
teorias{2} set-dato-final name "movido" value 0.\r
\r
- teorias{3} init named "Rotar a izquierda" with-action "izquierda".\r
+ teorias{3} init named "Rotar a izquierda" with-action "izquierda" executed 2.\r
teorias{3} set-dato-inicial name "sensor_f" value 1.\r
teorias{3} set-dato-inicial name "sensor_b" value ANY.\r
teorias{3} set-dato-inicial name "sensor_r" value ANY.\r
girando_der = 1.\r
}\r
}\r
+ else\r
+ {\r
+ plan-finished = 1.\r
+ }\r
}\r
\r
# Validación de teoría\r
if (iterate == CELDAS_TURNO):\r
{\r
# Actualiza entorno segun si se movio o no\r
- if (self near position posicion-inicial with-error 1.0):\r
+ if (self near position posicion-inicial with-error 2.0):\r
{\r
sa set-entorno value 0 with-name "movido".\r
}\r
\r
# Movimiento del robot\r
if (avanzando):\r
- self set-global-velocity to (15).\r
+ self set-global-velocity to (CELDAS_MAX_VELOCITY).\r
if (retrocediendo):\r
- self set-global-velocity to (-15).\r
+ self set-global-velocity to (-CELDAS_MAX_VELOCITY).\r
if (girando_izq):\r
self turn-left.\r
if (girando_der):\r