Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

RHexMode Class Reference
[The Mode Supervisor]

#include <RHexMode.hh>

Inherited by RHexCalibMode.

List of all members.


Detailed Description

Template class for all modes recognized by the mode supervisor.

The RHexMode class is the abstract base class for all the modes that can be registered with the Mode Supervisor. Note that it is not derived from Module or StateMachine classes to avoid restrictions on mode implementations.

Modes often incorporate multiple behaviors with different goal states and stability properties. They are required to identify some states as their "valid entry points", which is checked by the Supervisor. Consequently, all the mode implementations should also provide user interface functionality to put themselves in states where other modes can possibly start from (such as standing, sitting etc.)


Public Member Functions

 RHexMode (const char *name)
mode_id_t getId (void) const
const char * getName (void) const
virtual const char * getStructID (void) const
virtual bool entryPostureCheck (void)=0
virtual void initialize (void)=0
virtual void uninitialize (void)
virtual void start (void)=0
virtual void updateDatabase (void)
void disable (void)
void enable (void)
bool isEnabled (void)
virtual void stop (void)=0
virtual bool pause (void)=0
virtual void resume (void)=0
virtual void kill (void)=0
param_id_t firstParam (void)
param_id_t nextParam (void)
int countParams (void)
DBEntrygetParamEntry (param_id_t id)
DBEntrygetParamEntry (const char *name)
template<class T> void setParam (param_id_t, T *val)
template<class T> void setParam (const char *name, T *val)
template<class T> void getParam (param_id_t id, T *val)
template<class T> void getParam (const char *name, T *val)
const char * getParamName (param_id_t id)
param_id_t findParamByName (const char *name)

Protected Member Functions

template<class T> param_id_t registerParam (const char *name, const char *desc, T *value, ModeParamCallback *cb=NULL)


Constructor & Destructor Documentation

RHexMode::RHexMode const char *  name  ) 
 

The RHexMode class constructor creates a mode with the given name and assigns a UNIQUE ID number (positive nonzero integer) to the mode. This identifier can be used as a reference to this mode in the supervisor's database.


Member Function Documentation

int RHexMode::countParams void   )  [inline]
 

This method returns the number of parameters for this mode

void RHexMode::disable void   )  [inline]
 

This method temporarily disables a mode to prevent its activation. This method is used in conjunction with disable and is useful for preventing accidental activation of certain modes in some situations. It

void RHexMode::enable void   )  [inline]
 

This method enables the mode if it was previously disabled through the disable method

virtual bool RHexMode::entryPostureCheck void   )  [pure virtual]
 

Derived implementations of this method are expected to check physical robot state to make sure that it is ok to enter the mode. The collection of these posture checks must allow all modes to be reachable through user interface elements or mode capabilities allowing the robot to be brought to states that are acceptable entry postures for other modes.

param_id_t RHexMode::firstParam void   ) 
 

This method returns the first in the list of parameters defined through registerParam

mode_id_t RHexMode::getId void   )  const [inline]
 

This method returns the ID number of the mode.

const char* RHexMode::getName void   )  const [inline]
 

This method returns the name of the mode. It is usually used for user interface pruposes. It is recommended that ID numbers are used as references to modes to minimize lookup time.

template<class T>
void RHexMode::getParam const char *  name,
T *  val
 

This method retrieves the contents of the blackboard entry with the specified name into the supplied structre. The use of this method is discouraged as name lookup is more expensive than using entry IDs.

template<class T>
void RHexMode::getParam param_id_t  id,
T *  val
 

This method retrieves the contents of the blackboard entry with the specified ID into the supplied structure.

DBEntry* RHexMode::getParamEntry const char *  name  )  [inline]
 

This method returns a pointer to the blackboard entry for a given parameter name

DBEntry* RHexMode::getParamEntry param_id_t  id  ) 
 

This method returns a pointer to the blackboard entry for a given parameter id

virtual const char* RHexMode::getStructID void   )  const [virtual]
 

This method returns an identifier string which will be used to describe the "version" of the command/status/state structures stored in the blackboard. The empty string is treated as a "wildcard" indicating no checking should be done.

virtual void RHexMode::initialize void   )  [pure virtual]
 

Similar to Module::init, this method is called when the mode is added to the ModeSupervisor 's list. Derived classes must provide implementations to perform necessary initializations such as reading configuration variables from the symbol table.

bool RHexMode::isEnabled void   )  [inline]
 

This method queries whether the mode is enabled or disabled

virtual void RHexMode::kill void   )  [pure virtual]
 

This method is called by the Supervisor for the current mode in the case of a real emergency to let the mode do software cleanup before it gets prematurely killed. A call to stop() is most likely to follow this one.

param_id_t RHexMode::nextParam void   ) 
 

Together with firstParam, this method implements an iterator for the current list of parameter entries for this mode. It returns -1 after the last parameter.

virtual bool RHexMode::pause void   )  [pure virtual]
 

The supervisor calls this method in soft emergencies (e.g. loss of communication with the GUI) for the current mode. Following this call, the mode will still remain active. So, this call acts as a trigger for the mode to put itself in as safe a state as possible and await further user interface commands. The meaning of "safe state" is defined by the particulars of the mode. returning true indicates that the robot is "safe" returning false signals the ModeSupervisor that it should "safe" the robot as it deems appropriate (probably by switching to sit mode). Note that this is different than the supervisor's safe mode defined through , which is only invoked in real emergencies.

template<class T>
param_id_t RHexMode::registerParam const char *  name,
const char *  desc,
T *  value,
ModeParamCallback *  cb = NULL
[protected]
 

This method is a convenience function for the mode to register blackboard entries to be accessed remotely. It is usually called from within the initialize function to register 5 entries: commands, current commands, parameters, current parameters and state. These five entries are then accessed by either a user interface or a remote master to modulate the behavior of the mode. Templates are used to define the blackboard entry contents as arbitrary structures. Note that even though the name uniquely identifies entries in the blackboard, the description is used to double-check consistency of entry content types. The return value is an identifier handle for the entry, which should be used for all subsequent references (read or write) to this entry.

virtual void RHexMode::resume void   )  [pure virtual]
 

this method is called when a soft emergency has ended (e.g. restoration of communication). This indicates that the mode should return to "normal" operations.

template<class T>
void RHexMode::setParam const char *  name,
T *  val
 

This method sets the contents of the blackboard entry with the specified name to the supplied value. The use of this method is discouraged as name lookup is more expensive than using entry IDs.

template<class T>
void RHexMode::setParam param_id_t  ,
T *  val
 

This method sets the contents of the blackboard entry with the specified ID to the supplied value.

virtual void RHexMode::start void   )  [pure virtual]
 

This method is invoked by the Supervisor to signal the mode that it has become the current mode. This is analogous to Module::activate and derived classes are expected to prepare the system to handle requests for this mode.

virtual void RHexMode::stop void   )  [pure virtual]
 

This method is invoked by the mode supervisor to signal the current mode that it is no longer active. It is called AFTER the supervisor decides that it can transition into another mode (by checking entryPostureCheck for the requested mode). This is analogous to Module::deactivate. In particular, this is where all the grabbed modules should be released, motor drives deactivated etc.

virtual void RHexMode::uninitialize void   )  [inline, virtual]
 

Similar to Module::uninit, this method is called when the mode is removed from the ModeSupervisor 's list. Derived classes must provide implementations to perform necessary cleanup operations.

virtual void RHexMode::updateDatabase void   )  [inline, virtual]
 

The mode supervisor periodically calls this method for the current mode. Derived implementations for this pure virtual method are expected to access the database entries corresponding to the mode, process incoming commands and parameter changes and post the current mode state. Analogous to Module::update, this method defines the principal functionality for the mode through the processing of incoming commands.


RHexLib Reference Documentation