2 @use CeldasMultiSensor.
4 Controller DemoController.
6 CeldasControl : DemoController {
8 leftWheel, rightWheel (object).
9 leftSensor, rightSensor (object).
16 new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)).
18 vehicle = new CeldasVehicle.
19 self watch item vehicle.
21 vehicle move to (10, 2, 5).
23 leftWheel = (vehicle add-wheel at (-2, 0, -1.5)).
24 rightWheel = (vehicle add-wheel at (-2, 0, 1.5)).
25 vehicle add-wheel at (1, 0, 0).
27 leftWheel set-velocity to 15.0.
28 rightWheel set-velocity to 15.0.
30 leftSensor = (vehicle add-sensor at (2.0, .4, 0)).
31 rightSensor = (vehicle add-sensor at (2.0, .4, 0)).
34 valueL, valueR (float).
36 valueL = leftSensor get-sensor-value.
37 valueR = rightSensor get-sensor-value.
39 if valueL < 2: leftWheel set-velocity to ((leftWheel get-velocity) + 1).
40 else: leftWheel set-velocity to ((leftWheel get-velocity) - 1).
42 if valueL < 2: rightWheel set-velocity to ((rightWheel get-velocity) + 1).
43 else: rightWheel set-velocity to ((rightWheel get-velocity) - 1).
45 print "leftSensor = $valueL -- rightSensor = $valueR".