SMACC2
|
#include <smacc_state_machine.hpp>
Protected Member Functions | |
void | checkStateMachineConsistence () |
void | initializeROS (std::string smshortname) |
void | onInitialized () |
template<typename TOrthogonal > | |
void | createOrthogonal () |
Protected Attributes | |
rclcpp::Node::SharedPtr | nh_ |
rclcpp::TimerBase::SharedPtr | timer_ |
rclcpp::Publisher< smacc2_msgs::msg::SmaccStateMachine >::SharedPtr | stateMachinePub_ |
rclcpp::Publisher< smacc2_msgs::msg::SmaccStatus >::SharedPtr | stateMachineStatusPub_ |
rclcpp::Publisher< smacc2_msgs::msg::SmaccTransitionLogEntry >::SharedPtr | transitionLogPub_ |
rclcpp::Service< smacc2_msgs::srv::SmaccGetTransitionHistory >::SharedPtr | transitionHistoryService_ |
std::vector< ISmaccState * > | currentState_ |
std::shared_ptr< SmaccStateInfo > | currentStateInfo_ |
smacc2_msgs::msg::SmaccStatus | status_msg_ |
std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > | orthogonals_ |
std::vector< boost::signals2::scoped_connection > | longLivedSignalConnections_ |
std::shared_ptr< SmaccStateMachineInfo > | stateMachineInfo_ |
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< smacc2_msgs::msg::SmaccTransitionLogEntry > | transitionLogHistory_ |
smacc2::SMRunMode | runMode_ |
SignalDetector * | signalDetector_ |
int64_t | stateSeqCounter_ |
Friends | |
class | ISmaccState |
class | SignalDetector |
Definition at line 64 of file smacc_state_machine.hpp.
smacc2::ISmaccStateMachine::ISmaccStateMachine | ( | std::string | stateMachineName, |
SignalDetector * | signalDetector, | ||
rclcpp::NodeOptions | nodeOptions = rclcpp::NodeOptions() |
||
) |
Definition at line 35 of file smacc_state_machine.cpp.
References smacc2::DEBUG, smacc2::SignalDetector::initialize(), nh_, smacc2::RELEASE, runMode_, and signalDetector_.
|
virtual |
Definition at line 74 of file smacc_state_machine.cpp.
References nh_.
void smacc2::ISmaccStateMachine::buildStateMachineInfo | ( | ) |
Definition at line 747 of file smacc_state_machine_impl.hpp.
References checkStateMachineConsistence(), getNode(), and stateMachineInfo_.
|
protected |
Definition at line 228 of file smacc_state_machine.cpp.
Referenced by buildStateMachineInfo().
|
protected |
Definition at line 93 of file smacc_state_machine_impl.hpp.
References getLogger(), m_mutex_, and orthogonals_.
boost::signals2::connection smacc2::ISmaccStateMachine::createSignalConnection | ( | TSmaccSignal & | signal, |
TMemberFunctionPrototype | callback, | ||
TSmaccObjectType * | object | ||
) |
Definition at line 412 of file smacc_state_machine_impl.hpp.
References smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, and stateCallbackConnections.
Referenced by smacc2::ISmaccClient::connectSignal(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled(), cl_nav2z::CbNavigateNextWaypoint::onEntry(), cl_nitrosz::CbNavigateNextWaypoint::onEntry(), smacc2::SmaccAsyncClientBehavior::onFailure(), smacc2::SmaccAsyncClientBehavior::onFinished(), smacc2::components::CpTopicSubscriber< MessageType >::onFirstMessageReceived(), smacc2::client_bases::SmaccSubscriberClient< MessageType >::onFirstMessageReceived(), cl_keyboard::ClKeyboard::OnKeyPress(), smacc2::components::CpTopicSubscriber< MessageType >::onMessageReceived(), smacc2::client_bases::SmaccSubscriberClient< MessageType >::onMessageReceived(), cl_multirole_sensor::ClMultiroleSensor< MessageType >::onMessageTimeout(), cl_moveit2z::ClMoveit2z::onMotionExecutionFailed(), cl_moveit2z::ClMoveit2z::onMotionExecutionSuccedded(), cl_http::ClHttp::onResponseReceived(), smacc2::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded(), smacc2::SmaccAsyncClientBehavior::onSuccess(), cl_ros_timer::ClRosTimer::onTimerTick(), cl_ros_timer::CbTimerCountdownLoop::onTimerTick(), cl_ros_timer::CbTimerCountdownOnce::onTimerTick(), cl_nav2z::CbNav2ZClientBehaviorBase::sendGoal(), cl_nitrosz::CbNav2ZClientBehaviorBase::sendGoal(), cl_nav2z::CpWaypointNavigator::sendNextGoal(), and cl_nitrosz::CpWaypointNavigator::sendNextGoal().
Definition at line 79 of file smacc_state_machine.cpp.
References nh_, and stateCallbackConnections.
Referenced by notifyOnStateExited(), and smacc2::ISmaccOrthogonal::onDispose().
|
virtual |
Reimplemented in smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.
Definition at line 101 of file smacc_state_machine.cpp.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::eStop().
|
inline |
Definition at line 85 of file smacc_state_machine.hpp.
|
inline |
Definition at line 757 of file smacc_state_machine_impl.hpp.
References currentState_.
Referenced by cl_nav2z::CpWaypointNavigator::sendNextGoal(), and cl_nitrosz::CpWaypointNavigator::sendNextGoal().
|
inline |
|
inline |
Definition at line 118 of file smacc_state_machine.hpp.
References currentStateInfo_.
Definition at line 225 of file smacc_state_machine_impl.hpp.
References getLogger(), globalData_, and m_mutex_.
Referenced by smacc2::ISmaccOrthogonal::getGlobalSMData(), and mapBehavior().
|
inline |
Definition at line 165 of file smacc_state_machine.hpp.
References nh_.
Referenced by createOrthogonal(), createSignalConnection(), getGlobalSMData(), getOrthogonal(), smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl(), mapBehavior(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), notifyOnStateExited(), notifyOnStateExitting(), postEvent(), postEvent(), propagateEventToStateReactors(), and requiresComponent().
|
inline |
rclcpp::Node::SharedPtr smacc2::ISmaccStateMachine::getNode | ( | ) |
Definition at line 95 of file smacc_state_machine.cpp.
References nh_.
Referenced by buildStateMachineInfo(), smacc2::ISmaccClient::getNode(), smacc2::ISmaccOrthogonal::getNode(), smacc2::SignalDetector::getNode(), smacc2::ISmaccClientBehavior::getNode(), smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl(), and smacc2::SignalDetector::pollOnce().
TOrthogonal * smacc2::ISmaccStateMachine::getOrthogonal | ( | ) |
Definition at line 55 of file smacc_state_machine_impl.hpp.
References getLogger(), m_mutex_, and orthogonals_.
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & smacc2::ISmaccStateMachine::getOrthogonals | ( | ) | const |
Definition at line 104 of file smacc_state_machine.cpp.
References orthogonals_.
Referenced by smacc2::introspection::SmaccStateMachineInfo::assembleSMStructureMessage(), smacc2::SignalDetector::findUpdatableClientsAndComponents(), smacc2::SignalDetector::findUpdatableStateElements(), and smacc2::ISmaccOrthogonal::requiresClient().
|
inline |
Definition at line 759 of file smacc_state_machine_impl.hpp.
References stateMachineInfo_.
std::string smacc2::ISmaccStateMachine::getStateMachineName | ( | ) |
Definition at line 223 of file smacc_state_machine.cpp.
References smacc2::introspection::demangleSymbol().
void smacc2::ISmaccStateMachine::getTransitionLogHistory | ( | const std::shared_ptr< rmw_request_id_t > | request_header, |
const std::shared_ptr< smacc2_msgs::srv::SmaccGetTransitionHistory::Request > | req, | ||
std::shared_ptr< smacc2_msgs::srv::SmaccGetTransitionHistory::Response > | res | ||
) |
Definition at line 184 of file smacc_state_machine.cpp.
References nh_, and transitionLogHistory_.
Referenced by initializeROS().
|
protected |
Definition at line 165 of file smacc_state_machine.cpp.
References getTransitionLogHistory(), nh_, stateMachinePub_, stateMachineStatusPub_, transitionHistoryService_, and transitionLogPub_.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
|
private |
Definition at line 211 of file smacc_state_machine.cpp.
Referenced by notifyOnStateExited().
void smacc2::ISmaccStateMachine::mapBehavior | ( | ) |
Definition at line 281 of file smacc_state_machine_impl.hpp.
References smacc2::introspection::demangleSymbol(), getGlobalSMData(), getLogger(), requiresComponent(), and setGlobalSMData().
Definition at line 569 of file smacc_state_machine_impl.hpp.
References currentState_, m_mutex_, smacc2::SignalDetector::notifyStateConfigured(), orthogonals_, signalDetector_, smacc2::STATE_ENTERING, stateMachineCurrentAction, and updateStatusMessage().
Definition at line 588 of file smacc_state_machine_impl.hpp.
References smacc2::STATE_CONFIGURING, and stateMachineCurrentAction.
Definition at line 501 of file smacc_state_machine_impl.hpp.
References currentState_, smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, orthogonals_, smacc2::STATE_RUNNING, stateMachineCurrentAction, and updateStatusMessage().
Definition at line 485 of file smacc_state_machine_impl.hpp.
References currentState_, currentStateInfo_, smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, orthogonals_, stateMachineInfo_, and stateSeqCounter_.
Definition at line 656 of file smacc_state_machine_impl.hpp.
References currentState_, smacc2::introspection::demangleSymbol(), disconnectSmaccSignalObject(), getLogger(), lockStateMachine(), smacc2::SignalDetector::notifyStateExited(), orthogonals_, signalDetector_, stateCallbackConnections, stateMachineCurrentAction, smacc2::TRANSITIONING, and unlockStateMachine().
Definition at line 594 of file smacc_state_machine_impl.hpp.
References smacc2::introspection::demangleSymbol(), getLogger(), orthogonals_, smacc2::STATE_EXITING, and stateMachineCurrentAction.
|
virtual |
this function should be implemented by the user to create the orthogonals
Definition at line 156 of file smacc_state_machine.cpp.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
|
protected |
Definition at line 158 of file smacc_state_machine.cpp.
References nh_, state_machine_visualization(), and timer_.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
void smacc2::ISmaccStateMachine::postEvent | ( | EventLifeTime | evlifetime = EventLifeTime::ABSOLUTE | ) |
Definition at line 216 of file smacc_state_machine_impl.hpp.
References getLogger(), and postEvent().
void smacc2::ISmaccStateMachine::postEvent | ( | EventType * | ev, |
EventLifeTime | evlifetime = EventLifeTime::ABSOLUTE |
||
) |
Definition at line 178 of file smacc_state_machine_impl.hpp.
References smacc2::CURRENT_STATE, currentState_, eventQueueMutex_, eventtypename, getLogger(), smacc2::SignalDetector::postEvent(), propagateEventToStateReactors(), signalDetector_, smacc2_event, smacc2::STATE_EXITING, stateMachineCurrentAction, TRACEPOINT(), and smacc2::TRANSITIONING.
Referenced by smacc2::ISmaccComponent::postEvent(), smacc2::ISmaccClient::postEvent(), smacc2::ISmaccComponent::postEvent(), smacc2::ISmaccClient::postEvent(), smacc2::ISmaccClientBehavior::postEvent(), and postEvent().
|
private |
Definition at line 729 of file smacc_state_machine_impl.hpp.
References getLogger(), and propagateEventToStateReactors().
Referenced by postEvent(), and propagateEventToStateReactors().
void smacc2::ISmaccStateMachine::publishTransition | ( | const SmaccTransitionInfo & | transitionInfo | ) |
Definition at line 146 of file smacc_state_machine.cpp.
References nh_, smacc2::introspection::transitionInfoToMsg(), transitionLogHistory_, and transitionLogPub_.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().
void smacc2::ISmaccStateMachine::requiresComponent | ( | SmaccComponentType *& | storage, |
bool | throwsExceptionIfNotExist = false |
||
) |
Definition at line 127 of file smacc_state_machine_impl.hpp.
References smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, and orthogonals_.
Referenced by mapBehavior(), smacc2::ISmaccOrthogonal::requiresComponent(), and smacc2::ISmaccClientBehavior::requiresComponent().
|
virtual |
Reimplemented in smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.
Definition at line 97 of file smacc_state_machine.cpp.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::reset().
Definition at line 260 of file smacc_state_machine_impl.hpp.
References globalData_, m_mutex_, and updateStatusMessage().
Referenced by mapBehavior(), and smacc2::ISmaccOrthogonal::setGlobalSMData().
void smacc2::ISmaccStateMachine::state_machine_visualization | ( | ) |
Definition at line 195 of file smacc_state_machine.cpp.
References m_mutex_, nh_, stateMachineInfo_, stateMachinePub_, stateMachineStatusPub_, and status_msg_.
Referenced by onInitialized().
|
virtual |
Reimplemented in smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.
Definition at line 99 of file smacc_state_machine.cpp.
Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::stop().
|
private |
Definition at line 217 of file smacc_state_machine.cpp.
Referenced by notifyOnStateExited().
|
private |
Definition at line 109 of file smacc_state_machine.cpp.
References currentStateInfo_, smacc2::DEBUG, globalData_, m_mutex_, nh_, runMode_, stateMachineStatusPub_, and status_msg_.
Referenced by notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), and setGlobalSMData().
|
friend |
Definition at line 234 of file smacc_state_machine.hpp.
|
friend |
Definition at line 235 of file smacc_state_machine.hpp.
|
protected |
Definition at line 190 of file smacc_state_machine.hpp.
Referenced by getCurrentState(), notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), notifyOnStateExited(), and postEvent().
|
protected |
Definition at line 192 of file smacc_state_machine.hpp.
Referenced by getCurrentStateInfo(), notifyOnStateEntryStart(), and updateStatusMessage().
|
private |
Definition at line 206 of file smacc_state_machine.hpp.
Referenced by postEvent().
|
private |
Definition at line 213 of file smacc_state_machine.hpp.
Referenced by getGlobalSMData(), setGlobalSMData(), and updateStatusMessage().
|
protected |
Definition at line 199 of file smacc_state_machine.hpp.
|
private |
Definition at line 205 of file smacc_state_machine.hpp.
Referenced by createOrthogonal(), createSignalConnection(), getGlobalSMData(), getMutex(), getOrthogonal(), lockStateMachine(), notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), smacc2::SignalDetector::pollOnce(), requiresComponent(), setGlobalSMData(), state_machine_visualization(), unlockStateMachine(), and updateStatusMessage().
|
protected |
Definition at line 180 of file smacc_state_machine.hpp.
Referenced by disconnectSmaccSignalObject(), getLogger(), getNode(), getTransitionLogHistory(), initializeROS(), ISmaccStateMachine(), lockStateMachine(), onInitialized(), publishTransition(), state_machine_visualization(), unlockStateMachine(), updateStatusMessage(), and ~ISmaccStateMachine().
|
protected |
Definition at line 197 of file smacc_state_machine.hpp.
Referenced by createOrthogonal(), getOrthogonal(), getOrthogonals(), notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), notifyOnStateEntryStart(), notifyOnStateExited(), notifyOnStateExitting(), and requiresComponent().
|
private |
Definition at line 218 of file smacc_state_machine.hpp.
Referenced by ISmaccStateMachine(), and updateStatusMessage().
|
private |
Definition at line 221 of file smacc_state_machine.hpp.
Referenced by ISmaccStateMachine(), notifyOnRuntimeConfigurationFinished(), notifyOnStateExited(), and postEvent().
|
private |
Definition at line 210 of file smacc_state_machine.hpp.
Referenced by createSignalConnection(), disconnectSmaccSignalObject(), and notifyOnStateExited().
|
private |
Definition at line 208 of file smacc_state_machine.hpp.
Referenced by notifyOnRuntimeConfigurationFinished(), notifyOnRuntimeConfigured(), notifyOnStateEntryEnd(), notifyOnStateExited(), notifyOnStateExitting(), smacc2::SignalDetector::pollOnce(), and postEvent().
|
protected |
Definition at line 202 of file smacc_state_machine.hpp.
Referenced by buildStateMachineInfo(), getStateMachineInfo(), smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl(), notifyOnStateEntryStart(), and state_machine_visualization().
|
protected |
Definition at line 183 of file smacc_state_machine.hpp.
Referenced by initializeROS(), and state_machine_visualization().
|
protected |
Definition at line 184 of file smacc_state_machine.hpp.
Referenced by initializeROS(), state_machine_visualization(), and updateStatusMessage().
|
private |
Definition at line 223 of file smacc_state_machine.hpp.
Referenced by getCurrentStateCounter(), and notifyOnStateEntryStart().
|
protected |
Definition at line 194 of file smacc_state_machine.hpp.
Referenced by state_machine_visualization(), and updateStatusMessage().
|
protected |
Definition at line 182 of file smacc_state_machine.hpp.
Referenced by onInitialized().
|
protected |
Definition at line 186 of file smacc_state_machine.hpp.
Referenced by initializeROS().
|
private |
Definition at line 216 of file smacc_state_machine.hpp.
Referenced by getTransitionLogHistory(), and publishTransition().
|
protected |
Definition at line 185 of file smacc_state_machine.hpp.
Referenced by initializeROS(), and publishTransition().