Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RobotInfo::Capabilities Class Reference

#include <CommonInfo.h>

Inheritance diagram for RobotInfo::Capabilities:

List of all members.


Detailed Description

Allows behaviors to lookup output/button/sensor names from other models to support basic cross-model portability.

Use the getCapabilities() function to look up the Capabalities instance for a given model based on its string robot name

Definition at line 48 of file CommonInfo.h.


Public Member Functions

 Capabilities (const char *robName, size_t numOut, const char *const outNames[], size_t numBut, const char *const butNames[], size_t numSen, const char *const senNames[], size_t pidOff, size_t numPID, size_t ledOff, size_t numLED)
 constructor, pass the robot name this is regarding, and outputs, buttons, and sensor names
 Capabilities (const Capabilities &cap)
 shallow copy (explicit to satisfy warning)
Capabilitiesoperator= (const Capabilities &cap)
 shallow assign (explicit to satisfy warning)
virtual ~Capabilities ()
 destructor, explicit just to avoid warning when used as base class
const char * getRobotName () const
 returns the name of the robot this corresponds to
unsigned int getNumOutputs () const
 returns the number of unique outputs (i.e. not counting aliases)
unsigned int getNumButtons () const
 returns the number of unique buttons (i.e. not counting aliases)
unsigned int getNumSensors () const
 returns the number of unique sensors (i.e. not counting aliases)
const char * getOutputName (unsigned int i) const
 look up the name corresponding to an offset, returns NULL if not found/available
const char * getButtonName (unsigned int i) const
 look up the name corresponding to an offset, returns NULL if not found/available
const char * getSensorName (unsigned int i) const
 look up the name corresponding to an offset, returns NULL if not found/available
unsigned int getOutputOffset (const char *out) const
 Look up the offset corresponding to a output name, throws std::invalid_argument if not found.
unsigned int getButtonOffset (const char *but) const
 look up the offset corresponding to a button name, throws std::invalid_argument if not found
unsigned int getSensorOffset (const char *sen) const
 look up the offset corresponding to a sensor name, throws std::invalid_argument if not found
unsigned int findOutputOffset (const char *out) const
 look up the offset corresponding to a output name, returns -1U if not found/available
unsigned int findButtonOffset (const char *but) const
 look up the offset corresponding to a button name, returns -1U if not found/available
unsigned int findSensorOffset (const char *sen) const
 look up the offset corresponding to a sensor name, returns -1U if not found/available
unsigned int getPIDJointOffset () const
 returns the offset of the block of 'PID' joints in an output array
unsigned int getNumPIDJoints () const
 returns the number of 'PID' joints
unsigned int getLEDOffset () const
 returns the offset of the block of LEDs in an output array
unsigned int getNumLEDs () const
 returns the number of LEDs
const std::set< unsigned int > & getFakeOutputs () const
 returns the offsets of "fake" outputs, see fakeOutputs

Protected Member Functions

unsigned int lookupT (const char *errStr, const std::map< std::string, unsigned int > &nameToIndex, const char *capname) const
 helper function, does the work of the get..Offset functions
unsigned int lookup (const std::map< std::string, unsigned int > &nameToIndex, const char *capname) const
 helper function, does the work of the find..Offset functions

Static Protected Member Functions

static std::map< std::string,
class Capabilities * > & 
getCaps ()
 returns a static map from robot names to capability instances, which are externally allocated

Protected Attributes

const char * name
 name of robot model
size_t numOutputs
 length of outputs
size_t numButtons
 length of buttons
size_t numSensors
 length of sensors
const char *const * outputs
 array of names for outputs -- this is the "primary" name for each output, outputToIndex may contain additional aliases
const char *const * buttons
 array of names for buttons -- this is the "primary" name for each button, buttonToIndex may contain additional aliases
const char *const * sensors
 array of names for sensors -- this is the "primary" name for each sensor, sensorToIndex may contain additional aliases
std::map< std::string,
unsigned int > 
outputToIndex
 maps output names to offset values
std::map< std::string,
unsigned int > 
buttonToIndex
 maps button names to offset values
std::map< std::string,
unsigned int > 
sensorToIndex
 maps sensor names to offset values
size_t pidJointOffset
 the offset of the PID joints
size_t numPIDJoints
 the number of PID joints
size_t ledOffset
 the offset of the LEDs
size_t numLEDs
 the number of LEDs
std::set< unsigned int > fakeOutputs
 Offsets of "fake" outputs, which don't correspond to any physical device on the robot.

Friends

CapabilitiesgetCapabilities (const std::string &robName)
 Accessor for Capabilities::caps, returns the Capabilities instance for a specified robot model (or NULL if robot is unknown or didn't provide a Capabilities instance).

Constructor & Destructor Documentation

RobotInfo::Capabilities::Capabilities ( const char *  robName,
size_t  numOut,
const char *const   outNames[],
size_t  numBut,
const char *const   butNames[],
size_t  numSen,
const char *const   senNames[],
size_t  pidOff,
size_t  numPID,
size_t  ledOff,
size_t  numLED 
)

constructor, pass the robot name this is regarding, and outputs, buttons, and sensor names

Definition at line 106 of file RobotInfo.cc.

RobotInfo::Capabilities::Capabilities ( const Capabilities cap  )  [inline]

shallow copy (explicit to satisfy warning)

Definition at line 54 of file CommonInfo.h.

virtual RobotInfo::Capabilities::~Capabilities (  )  [inline, virtual]

destructor, explicit just to avoid warning when used as base class

Definition at line 71 of file CommonInfo.h.


Member Function Documentation

Capabilities& RobotInfo::Capabilities::operator= ( const Capabilities cap  )  [inline]

shallow assign (explicit to satisfy warning)

Definition at line 61 of file CommonInfo.h.

const char* RobotInfo::Capabilities::getRobotName (  )  const [inline]

returns the name of the robot this corresponds to

Definition at line 74 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getNumOutputs (  )  const [inline]

returns the number of unique outputs (i.e. not counting aliases)

Definition at line 77 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getNumButtons (  )  const [inline]

returns the number of unique buttons (i.e. not counting aliases)

Definition at line 79 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getNumSensors (  )  const [inline]

returns the number of unique sensors (i.e. not counting aliases)

Definition at line 81 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

const char* RobotInfo::Capabilities::getOutputName ( unsigned int  i  )  const [inline]

look up the name corresponding to an offset, returns NULL if not found/available

Definition at line 84 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

const char* RobotInfo::Capabilities::getButtonName ( unsigned int  i  )  const [inline]

look up the name corresponding to an offset, returns NULL if not found/available

Definition at line 86 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

const char* RobotInfo::Capabilities::getSensorName ( unsigned int  i  )  const [inline]

look up the name corresponding to an offset, returns NULL if not found/available

Definition at line 88 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getOutputOffset ( const char *  out  )  const [inline]

Look up the offset corresponding to a output name, throws std::invalid_argument if not found.

Identical to findOutputOffset(), except throws an exception instead of returning an invalid value. Use this if you expect that the output is available, and want a noisy fail-fast if something's wrong (e.g. typo in name?)

Definition at line 93 of file CommonInfo.h.

Referenced by EmergencyStopMC::EmergencyStopMC(), EmergencyStopMC::freezeJoints(), BatteryMonitorBehavior::setFlipper(), and TailWagMC::updateOutputs().

unsigned int RobotInfo::Capabilities::getButtonOffset ( const char *  but  )  const [inline]

look up the offset corresponding to a button name, throws std::invalid_argument if not found

Identical to findButtonOffset(), except throws an exception instead of returning an invalid value. Use this if you expect that the output is available, and want a noisy fail-fast if something's wrong (e.g. typo in name?)

Definition at line 97 of file CommonInfo.h.

Referenced by EmergencyStopMC::trigger().

unsigned int RobotInfo::Capabilities::getSensorOffset ( const char *  sen  )  const [inline]

look up the offset corresponding to a sensor name, throws std::invalid_argument if not found

Identical to findSensorOffset(), except throws an exception instead of returning an invalid value. Use this if you expect that the output is available, and want a noisy fail-fast if something's wrong (e.g. typo in name?)

Definition at line 101 of file CommonInfo.h.

unsigned int RobotInfo::Capabilities::findOutputOffset ( const char *  out  )  const [inline]

look up the offset corresponding to a output name, returns -1U if not found/available

Identical to getOutputOffset(), except returns an invalid value instead of throwing an exception. Use this if you are testing to see if a capability exists, and don't want to incur exception handling if it isn't (say you're doing a lot of testing)

Definition at line 106 of file CommonInfo.h.

Referenced by PostureMC::defaultMaxSpeed(), HeadPointerMC::defaultMaxSpeed(), PostureEngine::loadLine(), WalkToTargetNode::processEvent(), HeadPointControllerBehavior::runCommand(), and HeadPointerMC::setJoints().

unsigned int RobotInfo::Capabilities::findButtonOffset ( const char *  but  )  const [inline]

look up the offset corresponding to a button name, returns -1U if not found/available

Identical to getButtonOffset(), except returns an invalid value instead of throwing an exception. Use this if you are testing to see if a capability exists, and don't want to incur exception handling if it isn't (say you're doing a lot of testing)

Definition at line 110 of file CommonInfo.h.

Referenced by PostureEngine::loadLine(), RunSequenceControl< SequenceSize >::selectedFile(), and LoadPostureControl::selectedFile().

unsigned int RobotInfo::Capabilities::findSensorOffset ( const char *  sen  )  const [inline]

look up the offset corresponding to a sensor name, returns -1U if not found/available

Identical to getSensorOffset(), except returns an invalid value instead of throwing an exception. Use this if you are testing to see if a capability exists, and don't want to incur exception handling if it isn't (say you're doing a lot of testing)

Definition at line 114 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getPIDJointOffset (  )  const [inline]

returns the offset of the block of 'PID' joints in an output array

Definition at line 116 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getNumPIDJoints (  )  const [inline]

returns the number of 'PID' joints

Definition at line 117 of file CommonInfo.h.

Referenced by PostureEngine::loadLine().

unsigned int RobotInfo::Capabilities::getLEDOffset (  )  const [inline]

returns the offset of the block of LEDs in an output array

Definition at line 118 of file CommonInfo.h.

unsigned int RobotInfo::Capabilities::getNumLEDs (  )  const [inline]

returns the number of LEDs

Definition at line 119 of file CommonInfo.h.

const std::set<unsigned int>& RobotInfo::Capabilities::getFakeOutputs (  )  const [inline]

returns the offsets of "fake" outputs, see fakeOutputs

Definition at line 122 of file CommonInfo.h.

unsigned int RobotInfo::Capabilities::lookupT ( const char *  errStr,
const std::map< std::string, unsigned int > &  nameToIndex,
const char *  capname 
) const [inline, protected]

helper function, does the work of the get..Offset functions

Definition at line 126 of file CommonInfo.h.

Referenced by getButtonOffset(), getOutputOffset(), and getSensorOffset().

unsigned int RobotInfo::Capabilities::lookup ( const std::map< std::string, unsigned int > &  nameToIndex,
const char *  capname 
) const [inline, protected]

helper function, does the work of the find..Offset functions

Definition at line 135 of file CommonInfo.h.

Referenced by findButtonOffset(), findOutputOffset(), and findSensorOffset().

std::map< std::string, class Capabilities * > & RobotInfo::Capabilities::getCaps (  )  [static, protected]

returns a static map from robot names to capability instances, which are externally allocated

The Capabilties base class will automatically insert entries into this collection.

Definition at line 126 of file RobotInfo.cc.

Referenced by Capabilities(), and RobotInfo::getCapabilities().


Friends And Related Function Documentation

Capabilities* getCapabilities ( const std::string &  robName  )  [friend]

Accessor for Capabilities::caps, returns the Capabilities instance for a specified robot model (or NULL if robot is unknown or didn't provide a Capabilities instance).

Use this if you have a robot name in string form and want to check or map its capabilities. (For example, if you are communicating with another robot of a different type over the network.) If you know at compile time the type of the robot in question, you could just directly access its 'capabilities' instance via its RobotInfo namespace. (e.g. ERS210Info::capabilities) If you want the capabilities for the current robot, just use the global 'capabilities' instance as RobotInfo.h will automatically import the current robot's namespace into the global space.

Definition at line 64 of file RobotInfo.h.


Member Data Documentation

const char* RobotInfo::Capabilities::name [protected]

name of robot model

Definition at line 140 of file CommonInfo.h.

Referenced by getRobotName(), lookupT(), and operator=().

length of outputs

Definition at line 141 of file CommonInfo.h.

Referenced by Capabilities(), getNumOutputs(), getOutputName(), and operator=().

length of buttons

Definition at line 142 of file CommonInfo.h.

Referenced by Capabilities(), getButtonName(), getNumButtons(), and operator=().

length of sensors

Definition at line 143 of file CommonInfo.h.

Referenced by Capabilities(), getNumSensors(), getSensorName(), and operator=().

const char* const* RobotInfo::Capabilities::outputs [protected]

array of names for outputs -- this is the "primary" name for each output, outputToIndex may contain additional aliases

Definition at line 144 of file CommonInfo.h.

Referenced by Capabilities(), getOutputName(), and operator=().

const char* const* RobotInfo::Capabilities::buttons [protected]

array of names for buttons -- this is the "primary" name for each button, buttonToIndex may contain additional aliases

Definition at line 145 of file CommonInfo.h.

Referenced by Capabilities(), getButtonName(), and operator=().

const char* const* RobotInfo::Capabilities::sensors [protected]

array of names for sensors -- this is the "primary" name for each sensor, sensorToIndex may contain additional aliases

Definition at line 146 of file CommonInfo.h.

Referenced by Capabilities(), getSensorName(), and operator=().

std::map<std::string,unsigned int> RobotInfo::Capabilities::sensorToIndex [protected]

maps sensor names to offset values

Definition at line 149 of file CommonInfo.h.

Referenced by Capabilities(), ERS7Info::ERS7Capabilities::ERS7Capabilities(), findSensorOffset(), getSensorOffset(), and operator=().

the offset of the PID joints

Definition at line 151 of file CommonInfo.h.

Referenced by getPIDJointOffset(), and operator=().

the number of PID joints

Definition at line 152 of file CommonInfo.h.

Referenced by getNumPIDJoints(), and operator=().

the offset of the LEDs

Definition at line 153 of file CommonInfo.h.

Referenced by getLEDOffset(), and operator=().

the number of LEDs

Definition at line 154 of file CommonInfo.h.

Referenced by getNumLEDs(), and operator=().

std::set<unsigned int> RobotInfo::Capabilities::fakeOutputs [protected]

Offsets of "fake" outputs, which don't correspond to any physical device on the robot.

This is used in compatability modes, where some outputs may not be available on the host hardware, or for meta-outputs, which control the interpretation of other outputs. (such as the A/B LED mode setting for the ERS-7, where a "virtual" LED switches the system's intepretation of the face panel LEDs).

Most robots can probably just leave this empty -- on Aperios the "fake" outputs are skipped when interfacing with the system and their values receive feedback from the motion process. When using the tekkotsu executable under unix-based systems, the HAL layer handles this functionality via its own configuration settings, and these values are ignored.

Definition at line 167 of file CommonInfo.h.

Referenced by ERS2xxInfo::ERS2xxCapabilities::ERS2xxCapabilities(), ERS7Info::ERS7Capabilities::ERS7Capabilities(), getFakeOutputs(), and operator=().


The documentation for this class was generated from the following files:

Tekkotsu v4.0
Generated Thu Nov 22 00:58:59 2007 by Doxygen 1.5.4