4 Controller DemoController.
6 CeldasControl : DemoController {
9 blWheel, brWheel (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, 0.8, 5).
23 blWheel = (vehicle add-wheel at (0, 0, -1.5)).
24 brWheel = (vehicle add-wheel at (0, 0, 1.5)).
26 self set-global-velocity to 15.0.
28 sensor = (vehicle add-sensor at (2.0, .4, 0)).
30 + to set-global-velocity to velocity (float):
32 brWheel set-velocity to velocity.
33 blWheel set-velocity to velocity.
35 + to get-global-velocity:
37 return ((brWheel get-velocity)
38 + (blWheel get-velocity)) / 2.
40 + to turn-right with-velocity velocity (float):
42 brWheel set-velocity to velocity.
43 blWheel set-velocity to -velocity.
45 + to turn-left with-velocity velocity (float):
47 blWheel set-velocity to velocity.
48 brWheel set-velocity to -velocity.
50 + to get-sensor-value:
52 return (sensor get-sensor-value).
59 value = self get-sensor-value.
61 if value < 1: self set-global-velocity to ((self get-global-velocity) + 1).
62 else if value > 5: self turn-right with-velocity 15.0.
63 #else if value > 10: self set-global-velocity to ((self get-global-velocity) - 1).
65 bl = (blWheel get-velocity).
66 br = (brWheel get-velocity).
67 print "sensor: $value, br: $br, bl: $bl".