#include <mc_control/fsm/State.h>
Public Member Functions | |
virtual | ~State () |
void | configure_ (const mc_rtc::Configuration &config) |
void | start_ (Controller &ctl) |
void | teardown_ (Controller &ctl) |
virtual bool | run (Controller &ctl)=0 |
virtual void | stop (Controller &) |
virtual bool | read_msg (std::string &) |
virtual bool | read_write_msg (std::string &, std::string &) |
const std::string & | output () const noexcept |
const std::string & | name () |
void | name (const std::string &n) |
Protected Member Functions | |
void | output (const std::string &o) |
virtual void | configure (const mc_rtc::Configuration &config) |
virtual void | start (Controller &ctl)=0 |
virtual void | teardown (Controller &ctl)=0 |
A state of an FSM.
A state implementation should create, add and remove the tasks/constraints it needs, with the following exceptions:
Notably, a state should not keep constraints or tasks it created active after the state finished its execution.
Every methods can be called in a real-time context. You should be aware of that, especially if you plan to have threads in your state (e.g. monitoring a ROS topic, waiting for data on the network...) then you should be especially careful when your state is destroyed.
The life-span of a state is:
The state might be interrupted (e.g. emergency behaviour triggered) in which case, stopped(...) will be called. The default implementation does nothing as teardown(...) is called anyway.
|
inlinevirtual |
|
protectedvirtual |
Called to configure the state.
This is called multiple times:
The default implementation simply loads the provided configuration into the config_
protected members. You can override this behavior to implement a more complex loading logic.
You can access this configuration either via the config_
variable
Reimplemented in mc_control::fsm::MetaTasksState, mc_control::fsm::StabilizerStandingState, mc_control::fsm::PauseState, mc_control::fsm::MessageState, mc_control::fsm::PostureState, and mc_control::fsm::PythonState.
void mc_control::fsm::State::configure_ | ( | const mc_rtc::Configuration & | config | ) |
Common implementation, handles the following options:
|
inline |
Returns the name of the state
|
inline |
|
inlinenoexcept |
Returns the output of the state, should only be consulted once run has returned true
|
inlineprotected |
Output setter for derived classes
|
inlinevirtual |
Handle read service call
Reimplemented in mc_control::fsm::ParallelState, and mc_control::fsm::MetaState.
|
inlinevirtual |
Handle read/write service call
Reimplemented in mc_control::fsm::ParallelState.
|
pure virtual |
Called every iteration until it returns true
Implemented in mc_control::fsm::PythonState, mc_control::fsm::MetaTasksState, mc_control::fsm::AddRemoveContactState, mc_control::fsm::Grippers, mc_control::fsm::StabilizerStandingState, mc_control::fsm::ParallelState, mc_control::fsm::MetaState, mc_control::fsm::HalfSittingState, mc_control::fsm::PauseState, mc_control::fsm::MessageState, mc_control::fsm::EnableControllerState, and mc_control::fsm::PostureState.
|
protectedpure virtual |
Called before the state starts being run
This will be called only once with the state fully configured.
Implemented in mc_control::fsm::PythonState, mc_control::fsm::MetaTasksState, mc_control::fsm::AddRemoveContactState, mc_control::fsm::Grippers, mc_control::fsm::StabilizerStandingState, mc_control::fsm::ParallelState, mc_control::fsm::MetaState, mc_control::fsm::HalfSittingState, mc_control::fsm::PauseState, mc_control::fsm::MessageState, mc_control::fsm::EnableControllerState, and mc_control::fsm::PostureState.
void mc_control::fsm::State::start_ | ( | Controller & | ctl | ) |
Common implementation, takes care of common options
|
inlinevirtual |
Called if the state is interrupted
Reimplemented in mc_control::fsm::PythonState, mc_control::fsm::ParallelState, and mc_control::fsm::MetaState.
|
protectedpure virtual |
Called right before destruction
Implemented in mc_control::fsm::PythonState, mc_control::fsm::MetaTasksState, mc_control::fsm::AddRemoveContactState, mc_control::fsm::Grippers, mc_control::fsm::ParallelState, mc_control::fsm::StabilizerStandingState, mc_control::fsm::MetaState, mc_control::fsm::HalfSittingState, mc_control::fsm::PauseState, mc_control::fsm::MessageState, mc_control::fsm::EnableControllerState, and mc_control::fsm::PostureState.
void mc_control::fsm::State::teardown_ | ( | Controller & | ctl | ) |
Common implementation, takes care of common options
|
protected |
AddCollisionsAfter in the configuration
|
protected |
AddCollisions in the configuration
|
protected |
AddContactsAfter in the configuration
|
protected |
AddContacts in the configuration
|
protected |
Configuration obtained through several calls
|
protected |
Constraints managed by the state if any
|
protected |
constraints in the configuration
|
protected |
Posture tasks that were removed by this state
|
protected |
RemoveCollisionsAfter in the configuration
|
protected |
RemoveCollisions in the configuration
|
protected |
RemoveContactsAfter in the configuration
|
protected |
RemoveContacts in the configuration
|
protected |
RemovePostureTask in the configuration
|
protected |
Tasks managed by the state if any
|
protected |
tasks in the configuration