Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## josx.robotics
Interface Behavior

    public interface Behavior

The Behavior interface represents an object embodying a specific behavior belonging to a robot. Each behavior must define three things:
1) The circumstances to make this behavior seize control of the robot. e.g. When the touch sensor determines the robot has collided with an object.
2) The action to exhibit when this behavior takes control. e.g. Back up and turn.
3) The actions to perform when another behavior has seized control from this behavior. e.g. Stop the current movement and update coordinates.
These are represented by defining the methods takeControl(), action(), and suppress() respectively.
A behavior control system has one or more Behavior objects. When you have defined these objects, create an array of them and use that array to initialize an Arbitrator object.

Version:
  0.1 27-July-2001
Author:
  Brian Bagnall
See Also:
  `Arbitrator`

Method Summary
`void` | `action()` The code in action() represents the actual action of the robot when this behavior becomes active.
`void` | `suppress()` The code in suppress() should stop the current behavior.
`boolean` | `takeControl()` Returns a boolean to indicate if this behavior should seize control of the robot.

Method Detail

### takeControl

    boolean takeControl()

  Returns a boolean to indicate if this behavior should seize control of the robot. For example, a robot that reacts if a touch sensor is pressed:
  public boolean takeControl() {
  return Sensor.S1.readBooleanValue();
  }

  Returns:
    boolean Indicates if this Behavior should seize control.

### action

    void action()

  The code in action() represents the actual action of the robot when this behavior becomes active. It can be as complex as navigating around a room, or as simple as playing a tune.
  The contract for implementing this method is:
  Any action can be started in this method. This method should not start a never ending loop. This method can return on its own, or when the suppress() method is called; but it must return eventually. The action can run in a seperate thread if the designer wishes it, and can therefore continue running after this method call returns.

### suppress

    void suppress()

  The code in suppress() should stop the current behavior. This can include stopping motors, or even calling methods to update internal data (such as navigational coordinates).
  The contract for implementing this method is:
  This method will stop the action running in this Behavior class. This method will not return until that action has been stopped. It is acceptable for a delay to occur while the action() method finishes up.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD