X-Git-Url: https://git.llucax.com/z.facultad/75.68/celdas.git/blobdiff_plain/3d6b50d2b60ae819d5879c844639ab78f3a4731e..9d2694b6708c33f0eeb0537032687872e0056e4b:/trunk/src/breve/Celdas.tz?ds=sidebyside diff --git a/trunk/src/breve/Celdas.tz b/trunk/src/breve/Celdas.tz index 0d3ced5..7c1afdc 100644 --- a/trunk/src/breve/Celdas.tz +++ b/trunk/src/breve/Celdas.tz @@ -8,6 +8,7 @@ @define CELDAS_MAX_VELOCITY 30. @define CELDAS_TURNO 100. +@define CELDAS_SENSOR_THRESHOLD 9. PhysicalControl : CeldasControl { % This class is used for building simple vehicle @@ -55,7 +56,6 @@ MultiBody : CeldasLightVehicle (aka CeldasLightVehicles) { bodyLink (object). wheels (list). - sensors (list). + to init: bodyShape = new Shape. @@ -211,10 +211,10 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { return (fSensor get-sensor-value). +to update-entorno: - entorno{"sensor_f"} = (fSensor get-data). - entorno{"sensor_b"} = (bSensor get-data). - entorno{"sensor_r"} = (rSensor get-data). - entorno{"sensor_l"} = (lSensor get-data). + entorno{"sensor_f"} = (fSensor get-sensor-value). + entorno{"sensor_b"} = (bSensor get-sensor-value). + entorno{"sensor_r"} = (rSensor get-sensor-value). + entorno{"sensor_l"} = (lSensor get-sensor-value). entorno{"movido"} = 0. # TODO sa update-entorno with entorno. @@ -316,17 +316,17 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { sa update-datos-finales with datos-finales. +to iterate: - fl, fr(float). + self update-entorno. if (0): # TODO posicion_final == posicion_actual { print "Llegamos al FINAL!!!". + self set-global-velocity to 0. return. } if (plan_finished): { - self update-entorno. sa plan. # Si no tenemos plan, lo hacemos plan_finished = 0. # TODO posicion_inicial = posicion_actual @@ -340,10 +340,8 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { if (iterate == 0): { - print "iteracion 0". if (sa has-next-theory): { - print "hay teoria". teoria = sa get-next-theory. if ((teoria get-accion) == "adelante"): { @@ -378,15 +376,12 @@ CeldasLightVehicle : CeldasVehicle (aka CeldasVehicles) { if (iterate == CELDAS_TURNO): { - self update-entorno. # TODO if (posicion_actual == posicion_inicial): movido = false. else movido = true. if (sa validate theory teoria): { - print "valida". } else { - print "Teoria no valida". plan_finished = 1. } } @@ -523,6 +518,11 @@ Link : CeldasSensor (aka CeldasSensors) { % Gets the sensor value. This should be used from post-iterate, % if not, the sensor reading correspond to the previous % iteration. + val (float). + + val = self get-data. + if (val > CELDAS_SENSOR_THRESHOLD): return 0. + else return 1. #+ to iterate: @@ -530,16 +530,10 @@ Link : CeldasSensor (aka CeldasSensors) { i (object). min,dist (float). v,obs(vector). - aux(float). j (int). des2,des3(int). wallBegin,wallEnd,wallCenter (float). - - toObstacle(vector). - largeWall (float). - obsLoc (vector). - location (vector). posObstacle,destiny,yo(vector). draw clear.