User Tools

Site Tools


Cliff Watcher Project Implementing Arbitrator and Behavior

The Functionality of Arbitrator and Behavior

  • The Arbitrator class and the Behavior interface are used to program a series of actions for the leJOS robot to do. For the program to function properly, there must be a class that contains the main method. This class should contain an instance of the Arbitrator class that has an array of Behavior objects for it to execute. Arbitration works by executing a start method. This method is different from a start method for a Thread. That is, the start method of the Arbitrator class never returns. This is why the Arbitrator class cannot be treated as a Thread, it is merely a class that contains an infinite loop within its start method and it runs the Behaviors that it was given. Neither the Behavior interface nor the Arbitrator class are Thread subclasses.


  1. Design a cliff detecting robot program that uses the capabilities of the Arbitrator class and Behavior interface.
  2. Allow the user to terminate the program at anytime by the use of a touch sensor.


  1. Create a class that uses the Arbitrator class. Have this class be the main class and have it invoke the start method of the Arbitrator class.
  2. Create an array of tasks that implement the Behavior interface. Make these tasks able to make the robot detect and handle a cliff. Have the main class use this array for its implementation of the Arbitrator class.
  3. Make the robot search for cliffs indefinitely or until the user wishes to exit (by pressing the touch sensor).

Final Remarks

  1. The functionality of Arbitrator and Behavior do not allow for the Arbitrator's start method to return. Keep this in mind when implementing the termination functionality for the program.
  2. The robot should not attempt to move forward if either of its motors are in motion. Also, the motors need to be stopped before they can be turned in other directions.
  3. The ultra-sonic sensor takes 30 milliseconds to issue a ping and read the reflections that are returned from the ping. Take this into account.
  4. This program does not need any explicitly coded concurrency and/or synchronization.
reu/cliff_watcher_behavior.txt · Last modified: 2009/02/03 08:52 by jtk