From 5530730f6759a3c449df3e78f122084d16f825d6 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 18 Dec 2006 18:29:40 +0000 Subject: [PATCH] =?utf8?q?Bugfix,=20cambia=20modo=20de=20rotaci=C3=B3n=20p?= =?utf8?q?ara=20que=20rote=20en=20el=20lugar=20y=20varios=20cambios=20de?= =?utf8?q?=20par=C3=A1metros=20para=20que=20funcione=20mejor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- trunk/src/breve/Celdas.tz | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/trunk/src/breve/Celdas.tz b/trunk/src/breve/Celdas.tz index 6ca2d6c..ae29a51 100644 --- a/trunk/src/breve/Celdas.tz +++ b/trunk/src/breve/Celdas.tz @@ -6,8 +6,8 @@ @use Drawing. @use SistemaAutonomo. -@define CELDAS_MAX_VELOCITY 30. -@define CELDAS_TURNO 100. +@define CELDAS_MAX_VELOCITY 5. +@define CELDAS_TURNO 30. @define CELDAS_SENSOR_THRESHOLD 10. PhysicalControl : CeldasControl { @@ -205,19 +205,23 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { return ((rfWheel get-velocity) + (lfWheel get-velocity)) / 2. + to turn-right: - tright++. - + #tright++. + #self rotate around-axis (0,1,0) by (-1.5709/CELDAS_TURNO)*tright. + #if (tright == CELDAS_TURNO): tright=0. + if (tright == 0): self set-global-velocity to 0. self rotate around-axis (0,1,0) by (-1.5709/CELDAS_TURNO)*tright. - if (tright == CELDAS_TURNO): tright=0. + else tright++. + to turn-left: - tleft++. - - self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft. - + #tleft++. + #self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft. + #if (tleft == CELDAS_TURNO): tleft=0. + if (tleft == 0): self set-global-velocity to 0. + self rotate around-axis (0,1,0) by (1.5709/CELDAS_TURNO)*tleft. if (tleft == CELDAS_TURNO): tleft=0. + else tleft++. + to get-sensor-value: @@ -289,7 +293,7 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { 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} init named "Retroceder" with-action "atras" executed 2. 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. @@ -313,7 +317,7 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { 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} init named "Rotar a izquierda" with-action "izquierda" executed 2. 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. @@ -399,13 +403,17 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { girando_der = 1. } } + else + { + plan-finished = 1. + } } # Validación de teoría if (iterate == CELDAS_TURNO): { # Actualiza entorno segun si se movio o no - if (self near position posicion-inicial with-error 1.0): + if (self near position posicion-inicial with-error 2.0): { sa set-entorno value 0 with-name "movido". } @@ -427,9 +435,9 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { # Movimiento del robot if (avanzando): - self set-global-velocity to (15). + self set-global-velocity to (CELDAS_MAX_VELOCITY). if (retrocediendo): - self set-global-velocity to (-15). + self set-global-velocity to (-CELDAS_MAX_VELOCITY). if (girando_izq): self turn-left. if (girando_der): -- 2.43.0