@use Celdas. Controller DemoController. CeldasControl : DemoController { + variables: sensor (object). blWheel, brWheel (object). 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 CeldasVehicle. self watch item vehicle. vehicle move to (10, 0.8, 5). blWheel = (vehicle add-wheel at (0, 0, -1.5)). brWheel = (vehicle add-wheel at (0, 0, 1.5)). self set-global-velocity to 15.0. sensor = (vehicle add-sensor at (2.0, .4, 0)). + to set-global-velocity to velocity (float): brWheel set-velocity to velocity. blWheel set-velocity to velocity. + to get-global-velocity: return ((brWheel get-velocity) + (blWheel get-velocity)) / 2. + to turn-right with-velocity velocity (float): brWheel set-velocity to velocity. blWheel set-velocity to -velocity. + to turn-left with-velocity velocity (float): blWheel set-velocity to velocity. brWheel set-velocity to -velocity. + to get-sensor-value: return (sensor get-sensor-value). + to post-iterate: value (float). bl, br (float). value = self get-sensor-value. if value < 1: self set-global-velocity to ((self get-global-velocity) + 1). else if value > 5: self turn-right with-velocity 15.0. #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1). bl = (blWheel get-velocity). br = (brWheel get-velocity). print "sensor: $value, br: $br, bl: $bl". }