lobot::Arbiter Class Reference

An ABC defining the common interface for lobot's motor control arbiters. More...

#include <Robots/LoBot/control/LoArbiter.H>

Inheritance diagram for lobot::Arbiter:
Inheritance graph
[legend]
Collaboration diagram for lobot::Arbiter:
Collaboration graph
[legend]

List of all members.

Classes

struct  vote_data
struct  VoteBase

Public Member Functions

bool is_frozen (const std::string &name) const
 Check if the named behaviour has frozen the arbiter.
void vote (const std::string &name, VoteBase *vote)
 Behaviours use this method to cast their votes.
virtual ~Arbiter ()
 Clean-up.

void freeze (const std::string &name)
void unfreeze (const std::string &name)

Protected Types

typedef std::list< vote_data * > Votes

Protected Member Functions

 Arbiter (int update_delay, const std::string &drawable_name="", const Drawable::Geometry &=Drawable::Geometry())
void run ()
float priority (const std::string &behaviour_name) const
virtual void motor_cmd (const Votes &, Robot *)=0

virtual void pre_run ()
virtual void post_run ()

Detailed Description

An ABC defining the common interface for lobot's motor control arbiters.

This class implements an abstract base class that provides a common interface for a behaviour arbitration mechanism. The Robolocust arbiter follows Rosenblatt's ideas as described in his Ph.D. thesis on the Distributed Architecture for Mobile Navigation (DAMN).

Thus, Robolocust behaviours do not directly control the motors or engage in such nefarious activities as suppressing or inhibiting each other (a la subsumption). Instead, they vote for each of the different possible motor control commands. A central arbiter tallies votes using a weighted sum and smoothing procedure that results in command fusion (as opposed to sensor fusion) and then issues the command with the highest vote.

Definition at line 95 of file LoArbiter.H.


Member Typedef Documentation

typedef std::list<vote_data*> lobot::Arbiter::Votes [protected]

The arbiter maintains all the votes in a list of this type. The list is held privately by the base (i.e., this) class and passed to subclasses as part of the motor_cmd() method.

Definition at line 250 of file LoArbiter.H.


Constructor & Destructor Documentation

lobot::Arbiter::Arbiter ( int  update_delay,
const std::string drawable_name = "",
const Drawable::Geometry g = Drawable::Geometry() 
) [protected]

A protected constructor because only subclasses should be able to invoke it. Clients cannot directly create arbiters.

Derived classes must specify an appropriate update delay to use when they invoke this constructor. It is up to each individual arbiter to guard against possibly catastrophic update delay settings in the config file and provide reasonable defaults and boundaries.

Optionally, arbiters interested in visualization may provide the names and geometries for their respective drawables.

Definition at line 117 of file LoArbiter.C.

lobot::Arbiter::~Arbiter (  )  [virtual]

Clean-up.

Definition at line 271 of file LoArbiter.C.


Member Function Documentation

void lobot::Arbiter::freeze ( const std::string name  ) 

Sometimes, a behaviour might want/need exclusive control over the robot's actuators. To facilitate this, the freeze() method freezes the arbiter's priority to that of the behaviour identified by the given name. Once frozen, the arbiter will ignore votes cast by behaviours whose priorities are lower than the priority at which the arbiter is frozen.

After its need is fulfilled, the behaviour that has frozen the arbiter must unfreeze it to resume normal operation.

NOTE: Freezing the arbiter goes against the grain of the DAMN paradigm. This feature is meant for occasional use by high priority behaviours that might have a need for implementing a sequence of actions without "interference" from other behaviours. Use this feature only if absolutely necessary.

Definition at line 208 of file LoArbiter.C.

References priority().

bool lobot::Arbiter::is_frozen ( const std::string name  )  const

Check if the named behaviour has frozen the arbiter.

Definition at line 229 of file LoArbiter.C.

virtual void lobot::Arbiter::motor_cmd ( const Votes ,
Robot  
) [protected, pure virtual]

The DAMN arbiter's main loop (implemented in Arbiter::run()) is responsible for tallying the available votes and issuing the appropriae motor command. However, since each type of arbiter can have different voting semantics, the base class cannot tally votes and issue the motor commands. That must be done by subclasses. This method performs the vote tallying and issuance of motor commands. It must be implemented by each subclass.

NOTE: Subclasses must treat the votes list as read-only. Although this list is passed to the subclass as const object, its nodes are actually up for grabs and can be modified. However, subclasses must refrain from editing the individual vote_data* nodes held by the votes list. Otherwise, Bad Things will happen.

Referenced by run().

void lobot::Arbiter::pre_run (  )  [protected, virtual]

These methods provide derived classes hooks for implementing any pre- and post-run operations. pre_run() is called right before the main loop is entered and post_run() right after it is exited.

Derived classes are not required to define these functions. The default versions implemented in the Arbiter base class do nothing.

Definition at line 132 of file LoArbiter.C.

Referenced by run().

float lobot::Arbiter::priority ( const std::string behaviour_name  )  const [protected]

Returns the normalized priority value stored in the behaviours priority map.

Definition at line 198 of file LoArbiter.C.

Referenced by freeze(), and vote().

void lobot::Arbiter::run (  )  [protected, virtual]

This method implements the arbiter's main loop, taking care of checking with the lobot::Shutdown object whether or not it's time to quit.

NOTE: Derived classes may but generally should not provide their own implementations of the Thread::run() method. If, for some reason, a subclass of lobot::Arbiter needs to define its own version of run(), it should be sure to check the status of the lobot::Shutdown object.

Implements lobot::Thread.

Definition at line 134 of file LoArbiter.C.

References lobot::Pause::is_clear(), motor_cmd(), pre_run(), lobot::Shutdown::signaled(), and lobot::App::wait_for_init().

void lobot::Arbiter::vote ( const std::string name,
VoteBase vote 
)

Behaviours use this method to cast their votes.

Definition at line 253 of file LoArbiter.C.

References priority(), and lobot::Thread::running().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:30:20 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3