|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.ridgesoft.robotics.BehaviorArbiter
public class BehaviorArbiter
Implements a behavior arbitrator for behavior-based control of a robot.
A BehaviorArbiter arbitrates between a number of behaviors competing for control of the robot. The BehaviorArbiter maintains a priority ordered list of behavoir objects which must implent the Behavior interface. Using its own thread, the BehaviorArbiter periodically polls each Behavior by invoking each Behavior's poll method. Each Behavior indicates whether it desires to control the robot via the return argument of its poll method. During each polling iteration the BehaviorArbiter selects the active Behavior by choosing the highest priority Behavior that desires to control the robot. The BehaviorArbiter invokes each Behavior's poll method on each iteration, regardless of which Behavior it selects to be active.
Whenever the BehaviorArbiter's active Behavior selection changes, the BehaviorArbiter brings about a change in control by deactivating the currently active Behavior and activating the newly selected Behavior. It does this by invoking the setActive method of the affected Behaviors, using the argument to this method to activate or deactivate the Behavior, as appropriate.
The Behaviors operate in a "nice-guy" environment and, therefore, must operate according to the intentions of the BehaviorArbiter inorder for the behavior system to function correctly. When a Behavior is active, it is must take control of the robot. When a Behavior is inactive it must refrain from attempting to control the robot.
Active Behaviors may use their poll method as a means to periodically adjust their control of the robot. However, calls to a Behavior's poll method must return quickly to avoid interfering with the operation of the BehaviorArbiter and the other Behaviors. If a particular Behavior needs to update its control of the robot more frequently than the polling interval, that Behavior should use a separate thread or timer to carry out its control of the robot.
Behavior
,
Behavior2
,
BehaviorEvent
,
BehaviorListener
,
com.ridgesoft.robotics.behaviors
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
BehaviorArbiter(Behavior[] behaviors,
int period)
Constructs a BehaviorArbiter object and thread, but does not start the thread. |
|
BehaviorArbiter(Behavior[] behaviors,
int period,
DigitalOutput heartBeat)
Constructs a BehaviorArbiter object and thread, but does not start the thread. |
|
BehaviorArbiter(Behavior[] behaviors,
LED led,
int period)
Constructs a BehaviorArbiter object and thread, but does not start the thread. |
Method Summary | |
---|---|
void |
run()
The BehaviorArbiter thread's run method. |
Methods inherited from class java.lang.Thread |
---|
activeCount, currentThread, dumpStack, getName, getPriority, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, setDaemon, setName, setPriority, sleep, start, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait |
Constructor Detail |
---|
public BehaviorArbiter(Behavior[] behaviors, int period)
Use the start method to start the BehaviorArbiter thread.
behaviors
- an array of behaviors with the highest priority behavior at
index 0 in the listperiod
- the period of execution of this BehaviorArbiter in
millisecondspublic BehaviorArbiter(Behavior[] behaviors, int period, DigitalOutput heartBeat)
Use the start method to start the BehaviorArbiter thread.
behaviors
- an array of behaviors with the highest priority behavior at
index 0 in the listperiod
- the period of execution of this BehaviorArbiter in
millisecondsheartBeat
- a DigitalOutput to toggle each behavior iteration - may be
nullpublic BehaviorArbiter(Behavior[] behaviors, LED led, int period)
Use the start method to start the BehaviorArbiter thread.
behaviors
- an array of behaviors with the highest priority behavior at
index 0 in the listled
- an LED to toggle each behavior iteration - may be nullperiod
- the period of execution of this BehaviorArbiter in
millisecondsMethod Detail |
---|
public void run()
Do not use this method directly. Instead, use the start method to start the BehaviorArbiter thread.
run
in interface Runnable
run
in class Thread
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |