lobot::TurnArbiter::Vote Class Reference

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

Collaboration diagram for lobot::TurnArbiter::Vote:
Collaboration graph
[legend]

List of all members.

Classes

class  iterator

Public Member Functions

 Vote ()
std::vector< int > get_directions () const
 Retrieve the supported turn directions in a vector.
VoteMap::mapped_type & operator[] (int direction)
void vote (int direction, float vote_value)
Voteoperator+= (const Vote &v)
 An operator to add one vote to another.
void normalize ()
void normalize (float min, float max)
 ~Vote ()
 Turn arbiter vote clean-up.
void dump (const std::string &caller="Vote::dump") const
 Debug support.

iterator begin ()
 Obtaining iterators for the vote object.
iterator end ()
const iterator begin () const
const iterator end () const

int num_directions () const
 Helpers to return the turn direction parameters.

Friends

class TurnArbiter
class iterator

Detailed Description

To control the robot's steering, each turn related behaviour must vote for or against each possible turn direction. These votes are represented by this inner class. In order to vote, a behaviour must instantiate this class with the new operator, fill out the voting structure properly and then pass it to the arbiter's vote() method.

A vote is a number between -1 and +1. If a behaviour votes -1 for some direction, it means that the behaviour is dead-set against turning in that direction; a vote of +1 indicates a strong preference for going in that direction; and a vote of zero means the behaviour is neutral with regards to that direction. Fractional numbers indicate varying degrees between the three states described above. For example, an obstacle avoidance behaviour might scale vote values based on the distance to obstacles.

Definition at line 112 of file LoTurnArbiter.H.


Constructor & Destructor Documentation

lobot::TurnArbiter::Vote::Vote (  ) 

When a new turn arbiter vote object is created, we initialize the internal turn-direction-to-vote-value map by using the appropriate config file parameters.

Definition at line 161 of file LoTurnArbiter.C.

References lobot::TurnArbiter::turn_max().

lobot::TurnArbiter::Vote::~Vote (  ) 

Turn arbiter vote clean-up.

Definition at line 207 of file LoTurnArbiter.C.


Member Function Documentation

iterator lobot::TurnArbiter::Vote::begin (  )  [inline]

Obtaining iterators for the vote object.

Definition at line 258 of file LoTurnArbiter.H.

Referenced by normalize(), and operator+=().

void lobot::TurnArbiter::Vote::dump ( const std::string caller = "Vote::dump"  )  const

Debug support.

Definition at line 296 of file LoTurnArbiter.C.

std::vector< int > lobot::TurnArbiter::Vote::get_directions (  )  const

Retrieve the supported turn directions in a vector.

Definition at line 173 of file LoTurnArbiter.C.

References transform().

void lobot::TurnArbiter::Vote::normalize ( float  min,
float  max 
)

Normalization requires finding the current min and max votes. However, sometimes, clients might obligingly have already done this. This method can be used when the current min and max vote values are known beforehand.

Definition at line 290 of file LoTurnArbiter.C.

References begin(), and transform().

void lobot::TurnArbiter::Vote::normalize (  ) 

When many votes are added together, the result can go out of the [-1, +1] range. This method normalizes such votes so that all directions get a vote in the proper range.

Definition at line 281 of file LoTurnArbiter.C.

References begin().

int lobot::TurnArbiter::Vote::num_directions (  )  const [inline]

Helpers to return the turn direction parameters.

Definition at line 280 of file LoTurnArbiter.H.

TurnArbiter::Vote & lobot::TurnArbiter::Vote::operator+= ( const Vote v  ) 

An operator to add one vote to another.

Definition at line 242 of file LoTurnArbiter.C.

References begin(), and transform().

TurnArbiter::Vote::VoteMap::mapped_type & lobot::TurnArbiter::Vote::operator[] ( int  direction  ) 

Operator to access the vote value corresponding to the supplied direction. If the turn direction is not supported by the arbiter, an exception will be thrown.

Definition at line 196 of file LoTurnArbiter.C.

Referenced by vote().

void lobot::TurnArbiter::Vote::vote ( int  direction,
float  vote_value 
) [inline]

After creating a new turn arbiter vote object, behaviours can use this method to specify their votes for a given direction.

Definition at line 140 of file LoTurnArbiter.H.

References operator[]().


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