@use Celdas. Controller DemoController. CeldasVehicle : MyVehicle { + variables: sensor (object). flWheel, frWheel, blWheel, brWheel (object). + to init at location = (0, 0, 0) (vector): self move to location. blWheel = (self add-wheel at (2, 0, -1.5)). brWheel = (self add-wheel at (2, 0, 1.5)). blWheel = (self add-wheel at (-2, 0, -1.5)). brWheel = (self add-wheel at (-2, 0, 1.5)). #blWheel set-velocity to 15.0. #brWheel set-velocity to 15.0. sensor = (self add-sensor at (2.0, .4, 0)). + to set-global-velocity to velocity (float): brWheel set-velocity to velocity. frWheel set-velocity to velocity. blWheel set-velocity to velocity. flWheel set-velocity to velocity. + to get-global-velocity: return ((brWheel get-velocity) + (frWheel get-velocity) + (blWheel get-velocity) + (flWheel set-velocity)) / 4. + to turn-right with-velocity velocity (float): brWheel set-velocity to velocity. frWheel set-velocity to velocity. blWheel set-velocity to -velocity. flWheel set-velocity to -velocity. + to turn-left with-velocity velocity (float): blWheel set-velocity to velocity. flWheel set-velocity to velocity. brWheel set-velocity to -velocity. frWheel set-velocity to -velocity. + to get-sensor-value: return (sensor get-sensor-value). } CeldasControl : DemoController { + variables: vehicle (object). n (int). + to init: for n=0, n<10, n++: new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)). vehicle = new MyVehicle. self watch item vehicle. + to post-iterate: value (float). value = vehicle get-sensor-value. if value < 1: vehicle set-global-velocity to ((vehicle get-global-velocity) + 1). else if value > 10: vehicle set-global-velocity to ((vehicle get-global-velocity) - 1). print value. }