SMACC
|
#include <smacc_state_machine.h>
Public Member Functions | |
ISmaccStateMachine (SignalDetector *signalDetector) | |
virtual | ~ISmaccStateMachine () |
virtual void | reset () |
virtual void | stop () |
virtual void | eStop () |
template<typename TOrthogonal > | |
TOrthogonal * | getOrthogonal () |
const std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > & | getOrthogonals () const |
template<typename SmaccComponentType > | |
void | requiresComponent (SmaccComponentType *&storage) |
template<typename EventType > | |
void | postEvent (EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE) |
template<typename EventType > | |
void | postEvent (EventLifeTime evlifetime=EventLifeTime::ABSOLUTE) |
void | getTransitionLogHistory () |
template<typename T > | |
bool | getGlobalSMData (std::string name, T &ret) |
template<typename T > | |
void | setGlobalSMData (std::string name, T value) |
template<typename StateField , typename BehaviorType > | |
void | mapBehavior () |
std::string | getStateMachineName () |
void | state_machine_visualization (const ros::TimerEvent &) |
std::shared_ptr< SmaccStateInfo > | getCurrentStateInfo () |
void | publishTransition (const SmaccTransitionInfo &transitionInfo) |
virtual void | onInitialize () |
this function should be implemented by the user to create the orthogonals More... | |
bool | getTransitionLogHistory (smacc_msgs::SmaccGetTransitionHistory::Request &req, smacc_msgs::SmaccGetTransitionHistory::Response &res) |
template<typename TSmaccSignal , typename TMemberFunctionPrototype , typename TSmaccObjectType > | |
boost::signals2::connection | createSignalConnection (TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object) |
void | disconnectSmaccSignalObject (void *object) |
template<typename StateType > | |
void | notifyOnStateEntryStart (StateType *state) |
template<typename StateType > | |
void | notifyOnStateEntryEnd (StateType *state) |
template<typename StateType > | |
void | notifyOnRuntimeConfigured (StateType *state) |
template<typename StateType > | |
void | notifyOnStateExitting (StateType *state) |
template<typename StateType > | |
void | notifyOnStateExited (StateType *state) |
template<typename StateType > | |
void | notifyOnRuntimeConfigurationFinished (StateType *state) |
uint64_t | getCurrentStateCounter () const |
ISmaccState * | getCurrentState () const |
const SmaccStateMachineInfo & | getStateMachineInfo () |
template<typename InitialStateType > | |
void | buildStateMachineInfo () |
ros::NodeHandle | getNode () |
Protected Member Functions | |
void | checkStateMachineConsistence () |
void | initializeROS (std::string smshortname) |
void | onInitialized () |
template<typename TOrthogonal > | |
void | createOrthogonal () |
template<typename T > | |
bool | getParam (std::string param_name, T ¶m_storage) |
template<typename T > | |
void | setParam (std::string param_name, T param_val) |
template<typename T > | |
bool | param (std::string param_name, T ¶m_val, const T &default_val) const |
Protected Attributes | |
ros::NodeHandle | nh_ |
ros::NodeHandle | private_nh_ |
ros::Timer | timer_ |
ros::Publisher | stateMachinePub_ |
ros::Publisher | stateMachineStatusPub_ |
ros::Publisher | transitionLogPub_ |
ros::ServiceServer | transitionHistoryService_ |
std::vector< ISmaccState * > | currentState_ |
std::shared_ptr< SmaccStateInfo > | currentStateInfo_ |
smacc_msgs::SmaccStatus | status_msg_ |
std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > | orthogonals_ |
Private Member Functions | |
void | lockStateMachine (std::string msg) |
void | unlockStateMachine (std::string msg) |
template<typename EventType > | |
void | propagateEventToStateReactors (ISmaccState *st, EventType *ev) |
void | updateStatusMessage () |
Private Attributes | |
std::recursive_mutex | m_mutex_ |
std::recursive_mutex | eventQueueMutex_ |
StateMachineInternalAction | stateMachineCurrentAction |
std::map< void *, std::shared_ptr< CallbackCounterSemaphore > > | stateCallbackConnections |
std::map< std::string, std::pair< std::function< std::string()>, boost::any > > | globalData_ |
std::vector< smacc_msgs::SmaccTransitionLogEntry > | transitionLogHistory_ |
smacc::SMRunMode | runMode_ |
SignalDetector * | signalDetector_ |
uint64_t | stateSeqCounter_ |
std::shared_ptr< SmaccStateMachineInfo > | stateMachineInfo_ |
Friends | |
class | ISmaccState |
class | SignalDetector |
Definition at line 53 of file smacc_state_machine.h.
smacc::ISmaccStateMachine::ISmaccStateMachine | ( | SignalDetector * | signalDetector | ) |
Definition at line 15 of file smacc_state_machine.cpp.
References smacc::DEBUG, smacc::SignalDetector::initialize(), nh_, smacc::RELEASE, runMode_, and signalDetector_.
|
virtual |
Definition at line 59 of file smacc_state_machine.cpp.
void smacc::ISmaccStateMachine::buildStateMachineInfo |
Definition at line 656 of file smacc_state_machine_impl.h.
References checkStateMachineConsistence(), and stateMachineInfo_.
|
protected |
Definition at line 184 of file smacc_state_machine.cpp.
Referenced by buildStateMachineInfo().
|
protected |
Definition at line 63 of file smacc_state_machine_impl.h.
References lockStateMachine(), orthogonals_, and unlockStateMachine().
boost::signals2::connection smacc::ISmaccStateMachine::createSignalConnection | ( | TSmaccSignal & | signal, |
TMemberFunctionPrototype | callback, | ||
TSmaccObjectType * | object | ||
) |
Definition at line 345 of file smacc_state_machine_impl.h.
References smacc::utils::Bind< arity >::bindaux(), m_mutex_, and stateCallbackConnections.
Referenced by smacc::ISmaccClient::connectSignal(), smacc::client_bases::SmaccActionClientBase< ActionType >::onAborted(), smacc::SmaccAsyncClientBehavior::onFailure(), smacc::SmaccAsyncClientBehavior::onFinished(), smacc::client_bases::SmaccSubscriberClient< MessageType >::onFirstMessageReceived(), cl_keyboard::ClKeyboard::OnKeyPress(), smacc::client_bases::SmaccSubscriberClient< MessageType >::onMessageReceived(), cl_multirole_sensor::ClMultiroleSensor< MessageType >::onMessageTimeout(), cl_move_group_interface::ClMoveGroup::onMotionExecutionFailed(), cl_move_group_interface::ClMoveGroup::onMotionExecutionSuccedded(), smacc::client_bases::SmaccActionClientBase< ActionType >::onPreempted(), smacc::client_bases::SmaccActionClientBase< ActionType >::onRejected(), smacc::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived(), smacc::client_bases::SmaccActionClientBase< ActionType >::onSucceeded(), smacc::SmaccAsyncClientBehavior::onSuccess(), cl_ros_timer::ClRosTimer::onTimerTick(), cl_ros_timer::CbTimerCountdownLoop::onTimerTick(), and cl_ros_timer::CbTimerCountdownOnce::onTimerTick().
void smacc::ISmaccStateMachine::disconnectSmaccSignalObject | ( | void * | object | ) |
Definition at line 44 of file smacc_state_machine.cpp.
References stateCallbackConnections.
Referenced by notifyOnStateExited(), and smacc::ISmaccOrthogonal::onDispose().
|
virtual |
Reimplemented in smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.
Definition at line 72 of file smacc_state_machine.cpp.
Referenced by smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::eStop().
|
inline |
Definition at line 669 of file smacc_state_machine_impl.h.
References currentState_.
|
inline |
Definition at line 664 of file smacc_state_machine_impl.h.
References stateSeqCounter_.
|
inline |
Definition at line 95 of file smacc_state_machine.h.
References currentStateInfo_.
bool smacc::ISmaccStateMachine::getGlobalSMData | ( | std::string | name, |
T & | ret | ||
) |
Definition at line 173 of file smacc_state_machine_impl.h.
References globalData_, and m_mutex_.
Referenced by smacc::ISmaccOrthogonal::getGlobalSMData(), smacc::ISmaccState::getGlobalSMData(), and mapBehavior().
|
inline |
Definition at line 136 of file smacc_state_machine.h.
References nh_.
Referenced by smacc::ISmaccClientBehavior::getNode().
TOrthogonal * smacc::ISmaccStateMachine::getOrthogonal |
Definition at line 30 of file smacc_state_machine_impl.h.
References m_mutex_, and orthogonals_.
Referenced by smacc::ISmaccState::getOrthogonal().
const std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > & smacc::ISmaccStateMachine::getOrthogonals | ( | ) | const |
Definition at line 76 of file smacc_state_machine.cpp.
References orthogonals_.
Referenced by smacc::introspection::SmaccStateMachineInfo::assembleSMStructureMessage(), smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal(), smacc::SignalDetector::findUpdatableClients(), smacc::SignalDetector::findUpdatableStateElements(), and smacc::ISmaccState::requiresClient().
|
protected |
Definition at line 405 of file smacc_state_machine_impl.h.
References nh_.
|
inline |
Definition at line 674 of file smacc_state_machine_impl.h.
References stateMachineInfo_.
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateInfo().
std::string smacc::ISmaccStateMachine::getStateMachineName | ( | ) |
Definition at line 179 of file smacc_state_machine.cpp.
References smacc::introspection::demangleSymbol().
void smacc::ISmaccStateMachine::getTransitionLogHistory | ( | ) |
bool smacc::ISmaccStateMachine::getTransitionLogHistory | ( | smacc_msgs::SmaccGetTransitionHistory::Request & | req, |
smacc_msgs::SmaccGetTransitionHistory::Response & | res | ||
) |
Definition at line 148 of file smacc_state_machine.cpp.
References transitionLogHistory_.
|
protected |
Definition at line 136 of file smacc_state_machine.cpp.
References getTransitionLogHistory(), nh_, stateMachinePub_, stateMachineStatusPub_, transitionHistoryService_, and transitionLogPub_.
Referenced by smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
|
private |
Definition at line 167 of file smacc_state_machine.cpp.
References m_mutex_.
Referenced by createOrthogonal(), notifyOnStateExited(), and smacc::SignalDetector::pollOnce().
void smacc::ISmaccStateMachine::mapBehavior |
Definition at line 227 of file smacc_state_machine_impl.h.
References smacc::introspection::demangleSymbol(), getGlobalSMData(), requiresComponent(), and setGlobalSMData().
void smacc::ISmaccStateMachine::notifyOnRuntimeConfigurationFinished | ( | StateType * | state | ) |
Definition at line 495 of file smacc_state_machine_impl.h.
References currentState_, m_mutex_, smacc::SignalDetector::notifyStateConfigured(), orthogonals_, signalDetector_, smacc::STATE_ENTERING, stateMachineCurrentAction, and updateStatusMessage().
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().
void smacc::ISmaccStateMachine::notifyOnRuntimeConfigured | ( | StateType * | state | ) |
Definition at line 514 of file smacc_state_machine_impl.h.
References smacc::STATE_CONFIGURING, and stateMachineCurrentAction.
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().
void smacc::ISmaccStateMachine::notifyOnStateEntryEnd | ( | StateType * | state | ) |
Definition at line 437 of file smacc_state_machine_impl.h.
References currentState_, smacc::introspection::demangleSymbol(), m_mutex_, orthogonals_, smacc::STATE_STEADY, stateMachineCurrentAction, and updateStatusMessage().
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().
void smacc::ISmaccStateMachine::notifyOnStateEntryStart | ( | StateType * | state | ) |
Definition at line 425 of file smacc_state_machine_impl.h.
References currentState_, currentStateInfo_, smacc::introspection::demangleSymbol(), m_mutex_, orthogonals_, stateMachineInfo_, and stateSeqCounter_.
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().
void smacc::ISmaccStateMachine::notifyOnStateExited | ( | StateType * | state | ) |
Definition at line 575 of file smacc_state_machine_impl.h.
References currentState_, smacc::introspection::demangleSymbol(), disconnectSmaccSignalObject(), lockStateMachine(), smacc::SignalDetector::notifyStateExited(), orthogonals_, signalDetector_, stateCallbackConnections, stateMachineCurrentAction, smacc::TRANSITIONING, and unlockStateMachine().
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::exit().
void smacc::ISmaccStateMachine::notifyOnStateExitting | ( | StateType * | state | ) |
Definition at line 520 of file smacc_state_machine_impl.h.
References smacc::introspection::demangleSymbol(), orthogonals_, smacc::STATE_EXITING, and stateMachineCurrentAction.
Referenced by smacc::SmaccState< MostDerived, Context, InnerInitial, historyMode >::exit().
|
virtual |
this function should be implemented by the user to create the orthogonals
Definition at line 127 of file smacc_state_machine.cpp.
Referenced by smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
|
protected |
Definition at line 131 of file smacc_state_machine.cpp.
References nh_, state_machine_visualization(), and timer_.
Referenced by smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
|
protected |
Definition at line 419 of file smacc_state_machine_impl.h.
References nh_.
void smacc::ISmaccStateMachine::postEvent | ( | EventLifeTime | evlifetime = EventLifeTime::ABSOLUTE | ) |
Definition at line 166 of file smacc_state_machine_impl.h.
References postEvent().
void smacc::ISmaccStateMachine::postEvent | ( | EventType * | ev, |
EventLifeTime | evlifetime = EventLifeTime::ABSOLUTE |
||
) |
Definition at line 138 of file smacc_state_machine_impl.h.
References smacc::CURRENT_STATE, currentState_, eventQueueMutex_, smacc::SignalDetector::postEvent(), propagateEventToStateReactors(), signalDetector_, smacc::STATE_EXITING, stateMachineCurrentAction, and smacc::TRANSITIONING.
Referenced by smacc::ISmaccComponent::postEvent(), smacc::ISmaccClient::postEvent(), smacc::ISmaccClientBehavior::postEvent(), smacc::ISmaccState::postEvent(), postEvent(), and smacc::StateReactor::setOutputEvent().
|
private |
Definition at line 640 of file smacc_state_machine_impl.h.
References smacc::ISmaccState::getClassName(), smacc::ISmaccState::getParentState(), smacc::ISmaccState::getStateReactors(), and propagateEventToStateReactors().
Referenced by postEvent(), and propagateEventToStateReactors().
void smacc::ISmaccStateMachine::publishTransition | ( | const SmaccTransitionInfo & | transitionInfo | ) |
Definition at line 117 of file smacc_state_machine.cpp.
References smacc::introspection::transitionInfoToMsg(), transitionLogHistory_, and transitionLogPub_.
Referenced by smacc::ISmaccState::notifyTransitionFromTransitionTypeInfo().
void smacc::ISmaccStateMachine::requiresComponent | ( | SmaccComponentType *& | storage | ) |
Definition at line 94 of file smacc_state_machine_impl.h.
References smacc::introspection::demangleSymbol(), m_mutex_, and orthogonals_.
Referenced by mapBehavior(), smacc::ISmaccClientBehavior::requiresComponent(), smacc::ISmaccOrthogonal::requiresComponent(), and smacc::ISmaccState::requiresComponent().
|
virtual |
Reimplemented in smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.
Definition at line 64 of file smacc_state_machine.cpp.
Referenced by smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::reset().
void smacc::ISmaccStateMachine::setGlobalSMData | ( | std::string | name, |
T | value | ||
) |
Definition at line 208 of file smacc_state_machine_impl.h.
References globalData_, m_mutex_, and updateStatusMessage().
Referenced by cl_move_base_z::CbNavigateGlobalPosition::execute(), mapBehavior(), smacc::ISmaccOrthogonal::setGlobalSMData(), and smacc::ISmaccState::setGlobalSMData().
|
protected |
Definition at line 412 of file smacc_state_machine_impl.h.
References nh_.
void smacc::ISmaccStateMachine::state_machine_visualization | ( | const ros::TimerEvent & | ) |
Definition at line 155 of file smacc_state_machine.cpp.
References m_mutex_, stateMachineInfo_, stateMachinePub_, stateMachineStatusPub_, and status_msg_.
Referenced by onInitialized().
|
virtual |
Reimplemented in smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.
Definition at line 68 of file smacc_state_machine.cpp.
Referenced by smacc::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::stop().
|
private |
Definition at line 173 of file smacc_state_machine.cpp.
References m_mutex_.
Referenced by createOrthogonal(), notifyOnStateExited(), and smacc::SignalDetector::pollOnce().
|
private |
Definition at line 81 of file smacc_state_machine.cpp.
References currentStateInfo_, smacc::DEBUG, globalData_, m_mutex_, runMode_, stateMachineStatusPub_, and status_msg_.
Referenced by notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), and setGlobalSMData().
|
friend |
Definition at line 215 of file smacc_state_machine.h.
|
friend |
Definition at line 216 of file smacc_state_machine.h.
|
protected |
Definition at line 175 of file smacc_state_machine.h.
Referenced by getCurrentState(), notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), notifyOnStateExited(), and postEvent().
|
protected |
Definition at line 177 of file smacc_state_machine.h.
Referenced by getCurrentStateInfo(), notifyOnStateEntryStart(), and updateStatusMessage().
|
private |
Definition at line 186 of file smacc_state_machine.h.
Referenced by postEvent().
|
private |
Definition at line 193 of file smacc_state_machine.h.
Referenced by getGlobalSMData(), setGlobalSMData(), and updateStatusMessage().
|
private |
Definition at line 185 of file smacc_state_machine.h.
Referenced by createSignalConnection(), getGlobalSMData(), getOrthogonal(), lockStateMachine(), notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), requiresComponent(), setGlobalSMData(), state_machine_visualization(), unlockStateMachine(), and updateStatusMessage().
|
protected |
Definition at line 164 of file smacc_state_machine.h.
Referenced by getNode(), getParam(), initializeROS(), ISmaccStateMachine(), onInitialized(), param(), and setParam().
|
protected |
Definition at line 182 of file smacc_state_machine.h.
Referenced by createOrthogonal(), getOrthogonal(), getOrthogonals(), notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), notifyOnStateExited(), notifyOnStateExitting(), and requiresComponent().
|
protected |
Definition at line 165 of file smacc_state_machine.h.
|
private |
Definition at line 197 of file smacc_state_machine.h.
Referenced by ISmaccStateMachine(), and updateStatusMessage().
|
private |
Definition at line 200 of file smacc_state_machine.h.
Referenced by ISmaccStateMachine(), notifyOnRuntimeConfigurationFinished(), notifyOnStateExited(), and postEvent().
|
private |
Definition at line 190 of file smacc_state_machine.h.
Referenced by createSignalConnection(), disconnectSmaccSignalObject(), and notifyOnStateExited().
|
private |
Definition at line 188 of file smacc_state_machine.h.
Referenced by notifyOnRuntimeConfigurationFinished(), notifyOnRuntimeConfigured(), notifyOnStateEntryEnd(), notifyOnStateExited(), notifyOnStateExitting(), smacc::SignalDetector::pollOnce(), and postEvent().
|
private |
Definition at line 211 of file smacc_state_machine.h.
Referenced by buildStateMachineInfo(), getStateMachineInfo(), notifyOnStateEntryStart(), and state_machine_visualization().
|
protected |
Definition at line 168 of file smacc_state_machine.h.
Referenced by initializeROS(), and state_machine_visualization().
|
protected |
Definition at line 169 of file smacc_state_machine.h.
Referenced by initializeROS(), state_machine_visualization(), and updateStatusMessage().
|
private |
Definition at line 202 of file smacc_state_machine.h.
Referenced by getCurrentStateCounter(), and notifyOnStateEntryStart().
|
protected |
Definition at line 179 of file smacc_state_machine.h.
Referenced by state_machine_visualization(), and updateStatusMessage().
|
protected |
Definition at line 167 of file smacc_state_machine.h.
Referenced by onInitialized().
|
protected |
Definition at line 171 of file smacc_state_machine.h.
Referenced by initializeROS().
|
private |
Definition at line 195 of file smacc_state_machine.h.
Referenced by getTransitionLogHistory(), and publishTransition().
|
protected |
Definition at line 170 of file smacc_state_machine.h.
Referenced by initializeROS(), and publishTransition().