#include <RHexMode.hh>
Inherited by RHexCalibMode.
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) |
DBEntry * | getParamEntry (param_id_t id) |
DBEntry * | getParamEntry (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) |
|
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. |
|
This method returns the number of parameters for this mode |
|
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 |
|
This method enables the mode if it was previously disabled through the disable method |
|
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. |
|
This method returns the first in the list of parameters defined through registerParam |
|
This method returns the ID number of the mode. |
|
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. |
|
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. |
|
This method retrieves the contents of the blackboard entry with the specified ID into the supplied structure. |
|
This method returns a pointer to the blackboard entry for a given parameter name |
|
This method returns a pointer to the blackboard entry for a given parameter id |
|
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. |
|
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. |
|
This method queries whether the mode is enabled or disabled |
|
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. |
|
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. |
|
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. |
|
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. |
|
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. |
|
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. |
|
This method sets the contents of the blackboard entry with the specified ID to the supplied value. |
|
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. |
|
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. |
|
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. |
|
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. |