mc_control::fsm::TransitionMap Class Reference

#include <mc_control/fsm/TransitionMap.h>

Public Types

using origin_t = std::pair< std::string, std::string >
 

Public Member Functions

std::pair< bool, Transitiontransition (const std::string &state, const std::string &output) const
 
std::unordered_set< std::string > transitions (const std::string &state) const
 
void init (const StateFactory &factory, const mc_rtc::Configuration &config)
 
const std::string & initState () const
 
std::ostream & print (std::ostream &os) const
 

Detailed Description

This class takes care of reading a transition map from a configuration entry and makes sure it's coherent with the states provided by the StateFactory.

A transition map is formed by entries of the form ["StateName", "OutputName", "NewStateName", "OptionalTriggerType"], e.g.:

  • ["InitState", "OK", "GraspBar", "Strict"]
  • ["GraspBar", "OK", "LiftLeftFoot", "StepByStep"]
  • ["GraspBar", "NOK", "GraspBar", "Auto"]
  • ["GraspBar", "DEFAULT", "GraspBar", "Auto"]

If the "DEFAULT" output is present, this transition will be returned in case no other output pattern has been matched.

Valid values for the trigger type are:

  • "StepByStep": only require user input if running in StepByStep mode (default)
  • "Auto": automatic transition no matter what
  • "Strict": require user input no matter what

Member Typedef Documentation

◆ origin_t

using mc_control::fsm::TransitionMap::origin_t = std::pair<std::string, std::string>

A (state, output) pair is the origin of a transition

Member Function Documentation

◆ init()

void mc_control::fsm::TransitionMap::init ( const StateFactory factory,
const mc_rtc::Configuration config 
)

Build the map from a Configuration

The following entries are expected in config:

  • init: initial state for this map (string)
  • transitions: list of transitions as described in this documentation (array of strings' arrays)

If init is absent, defaults to the first state in transitions

Parameters
factoryThe factory that will provie states
configHolds the JSON representation of this transition map

◆ initState()

const std::string& mc_control::fsm::TransitionMap::initState ( ) const

Returns the initial state value

◆ print()

std::ostream& mc_control::fsm::TransitionMap::print ( std::ostream &  os) const

Print the map

◆ transition()

std::pair<bool, Transition> mc_control::fsm::TransitionMap::transition ( const std::string &  state,
const std::string &  output 
) const

Return a transition given a current state and its ouput

Parameters
stateThe current state
outputThe state's output
Returns
A pair made of a bool and a Transition:
  • If the (state, output) has a registered next state, the bool is true and Transition returns the corresponding transition.
  • Else, if the (state, DEFAULT) has a registered next state, the bool is true and Transition returns the corresponding transition
  • Otherwise, the bool is false and the Transition has no meaning

◆ transitions()

std::unordered_set<std::string> mc_control::fsm::TransitionMap::transitions ( const std::string &  state) const

For a given state, gives all possible next states


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