SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
smacc2::ISmaccStateMachine Class Reference

#include <smacc_state_machine.hpp>

Inheritance diagram for smacc2::ISmaccStateMachine:
Inheritance graph
Collaboration diagram for smacc2::ISmaccStateMachine:
Collaboration graph

Public Member Functions

 ISmaccStateMachine (std::string stateMachineName, 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< smacc2::ISmaccOrthogonal > > & getOrthogonals () const
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, bool throwsException=false)
 
template<typename EventType >
void postEvent (EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
 
template<typename EventType >
void postEvent (EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
 
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 ()
 
std::shared_ptr< SmaccStateInfogetCurrentStateInfo ()
 
void publishTransition (const SmaccTransitionInfo &transitionInfo)
 
virtual void onInitialize ()
 this function should be implemented by the user to create the orthogonals More...
 
void 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)
 
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
 
ISmaccStategetCurrentState () const
 
const SmaccStateMachineInfogetStateMachineInfo ()
 
template<typename InitialStateType >
void buildStateMachineInfo ()
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
std::recursive_mutex & getMutex ()
 

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< SmaccStateInfocurrentStateInfo_
 
smacc2_msgs::msg::SmaccStatus status_msg_
 
std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > orthogonals_
 
std::shared_ptr< SmaccStateMachineInfostateMachineInfo_
 

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_
 
SignalDetectorsignalDetector_
 
uint64_t stateSeqCounter_
 

Friends

class ISmaccState
 
class SignalDetector
 

Detailed Description

Definition at line 64 of file smacc_state_machine.hpp.

Constructor & Destructor Documentation

◆ ISmaccStateMachine()

smacc2::ISmaccStateMachine::ISmaccStateMachine ( std::string  stateMachineName,
SignalDetector signalDetector 
)

Definition at line 35 of file smacc_state_machine.cpp.

37: nh_(nullptr), stateSeqCounter_(0)
38{
39 rclcpp::NodeOptions node_options;
40 // This enables loading arbitrary parameters
41 // However, best practice would be to declare parameters in the corresponding classes
42 // and provide descriptions about expected use
43 // TODO(henningkayser): remove once all parameters are declared inside the components
44 // node_options.automatically_declare_parameters_from_overrides(true);
45
46 nh_ = rclcpp::Node::make_shared(stateMachineName, node_options); //
47 RCLCPP_INFO_STREAM(
48 nh_->get_logger(), "Creating State Machine Base: " << nh_->get_fully_qualified_name());
49
50 signalDetector_ = signalDetector;
52
53 std::string runMode;
54 if (nh_->get_parameter("run_mode", runMode))
55 {
56 if (runMode == "debug")
57 {
59 }
60 else if (runMode == "release")
61 {
63 }
64 else
65 {
66 RCLCPP_ERROR(nh_->get_logger(), "Incorrect run_mode value: %s", runMode.c_str());
67 }
68 }
69 else
70 {
72 }
73}
rclcpp::Node::SharedPtr nh_
void initialize(ISmaccStateMachine *stateMachine)

References smacc2::DEBUG, smacc2::SignalDetector::initialize(), nh_, smacc2::RELEASE, runMode_, and signalDetector_.

Here is the call graph for this function:

◆ ~ISmaccStateMachine()

smacc2::ISmaccStateMachine::~ISmaccStateMachine ( )
virtual

Definition at line 75 of file smacc_state_machine.cpp.

76{
77 RCLCPP_INFO(nh_->get_logger(), "Finishing State Machine");
78}

References nh_.

Member Function Documentation

◆ buildStateMachineInfo()

template<typename InitialStateType >
void smacc2::ISmaccStateMachine::buildStateMachineInfo

Definition at line 739 of file smacc_state_machine_impl.hpp.

740{
741 this->stateMachineInfo_ = std::make_shared<SmaccStateMachineInfo>(this->getNode());
742 this->stateMachineInfo_->buildStateMachineInfo<InitialStateType>();
743 this->stateMachineInfo_->assembleSMStructureMessage(this);
745}
rclcpp::Node::SharedPtr getNode()
std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo_

References checkStateMachineConsistence(), getNode(), and stateMachineInfo_.

Here is the call graph for this function:

◆ checkStateMachineConsistence()

void smacc2::ISmaccStateMachine::checkStateMachineConsistence ( )
protected

Definition at line 229 of file smacc_state_machine.cpp.

230{
231 // transition from an orthogonal that doesn’t exist.
232 // transition from a source that doesn’t exist.
233
234 // std::stringstream errorbuffer;
235 // bool errorFound = false;
236
237 // for (auto &stentry : this->stateMachineInfo_->states)
238 // {
239 // auto stinfo = stentry.second;
240
241 // for (auto &transition : stinfo->transitions_)
242 // {
243 // auto evinfo = transition.eventInfo;
244 // bool found = false;
245 // for (auto &orthogonal : orthogonals_)
246 // {
247 // if (orthogonal.first == evinfo->getOrthogonalName())
248 // {
249 // found = true;
250 // break;
251 // }
252 // }
253
254 // if (!found)
255 // {
256 // errorbuffer << "---------" << std::endl
257 // << "[Consistency Checking] Transition event refers not existing orthogonal." << std::endl
258 // << "State: " << demangleType(*stinfo->tid_) << std::endl
259 // << "Transition: " << transition.transitionTypeInfo->getFullName() << std::endl
260 // << "Orthogonal: " << evinfo->getOrthogonalName() << std::endl
261 // << "---------" << std::endl;
262
263 // errorFound = true;
264 // }
265 // //std::string getEventSourceName();
266 // //std::string getOrthogonalName();
267 // }
268 // }
269
270 // if (errorFound)
271 // {
272 // RCLCPP_WARN_STREAM(nh_->get_logger(),"== STATE MACHINE CONSISTENCY CHECK: ==" << std::endl
273 // << errorbuffer.str() << std::endl
274 // << "=================");
275 // }
276 // cb from a client that doesn’t exist – don’t worry about making clients dynamically.
277}

Referenced by buildStateMachineInfo().

Here is the caller graph for this function:

◆ createOrthogonal()

template<typename TOrthogonal >
void smacc2::ISmaccStateMachine::createOrthogonal
protected

Definition at line 93 of file smacc_state_machine_impl.hpp.

94{
95 //this->lockStateMachine("create orthogonal");
96 std::lock_guard<std::recursive_mutex> guard(m_mutex_);
97 std::string orthogonalkey = demangledTypeName<TOrthogonal>();
98
99 if (orthogonals_.count(orthogonalkey) == 0)
100 {
101 auto ret = std::make_shared<TOrthogonal>();
102 orthogonals_[orthogonalkey] = dynamic_pointer_cast<smacc2::ISmaccOrthogonal>(ret);
103
104 ret->setStateMachine(this);
105
106 RCLCPP_INFO(getLogger(), "%s Orthogonal is created", orthogonalkey.c_str());
107 }
108 else
109 {
110 RCLCPP_WARN_STREAM(
111 getLogger(), "There were already one existing orthogonal of type "
112 << orthogonalkey.c_str() << ". Skipping creation orthogonal request. ");
113 std::stringstream ss;
114 ss << "The existing orthogonals are the following: " << std::endl;
115 for (auto & orthogonal : orthogonals_)
116 {
117 ss << " - " << orthogonal.first << std::endl;
118 }
119 RCLCPP_WARN_STREAM(getLogger(), ss.str());
120 }
121 //this->unlockStateMachine("create orthogonal");
122}
std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > orthogonals_

References getLogger(), m_mutex_, and orthogonals_.

Here is the call graph for this function:

◆ createSignalConnection()

template<typename TSmaccSignal , typename TMemberFunctionPrototype , typename TSmaccObjectType >
boost::signals2::connection smacc2::ISmaccStateMachine::createSignalConnection ( TSmaccSignal &  signal,
TMemberFunctionPrototype  callback,
TSmaccObjectType *  object 
)

Definition at line 411 of file smacc_state_machine_impl.hpp.

413{
414 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
415
416 static_assert(
417 std::is_base_of<ISmaccState, TSmaccObjectType>::value ||
418 std::is_base_of<ISmaccClient, TSmaccObjectType>::value ||
419 std::is_base_of<ISmaccClientBehavior, TSmaccObjectType>::value ||
420 std::is_base_of<StateReactor, TSmaccObjectType>::value ||
421 std::is_base_of<ISmaccComponent, TSmaccObjectType>::value,
422 "Only are accepted smacc types as subscribers for smacc signals");
423
424 typedef decltype(callback) ft;
425 Bind<boost::function_types::function_arity<ft>::value> binder;
426 boost::signals2::connection connection;
427
428 // long life-time objects
429 if (
430 std::is_base_of<ISmaccComponent, TSmaccObjectType>::value ||
431 std::is_base_of<ISmaccClient, TSmaccObjectType>::value ||
432 std::is_base_of<ISmaccOrthogonal, TSmaccObjectType>::value ||
433 std::is_base_of<ISmaccStateMachine, TSmaccObjectType>::value)
434 {
435 connection = binder.bindaux(signal, callback, object, nullptr);
436 }
437 else if (
438 std::is_base_of<ISmaccState, TSmaccObjectType>::value ||
439 std::is_base_of<StateReactor, TSmaccObjectType>::value ||
440 std::is_base_of<ISmaccClientBehavior, TSmaccObjectType>::value)
441 {
442 RCLCPP_INFO(
443 getLogger(),
444 "[StateMachine] life-time constrained smacc signal subscription created. Subscriber is %s",
445 demangledTypeName<TSmaccObjectType>().c_str());
446
447 std::shared_ptr<CallbackCounterSemaphore> callbackCounterSemaphore;
448 if (stateCallbackConnections.count(object))
449 {
450 callbackCounterSemaphore = stateCallbackConnections[object];
451 }
452 else
453 {
454 callbackCounterSemaphore =
455 std::make_shared<CallbackCounterSemaphore>(demangledTypeName<TSmaccObjectType>().c_str());
456 stateCallbackConnections[object] = callbackCounterSemaphore;
457 }
458
459 connection = binder.bindaux(signal, callback, object, callbackCounterSemaphore);
460 callbackCounterSemaphore->addConnection(connection);
461 }
462 else // state life-time objects
463 {
464 RCLCPP_WARN(
465 getLogger(),
466 "[StateMachine] connecting signal to an unknown object with life-time unknown "
467 "behavior. It might provoke "
468 "an exception if the object is destroyed during the execution.");
469
470 connection = binder.bindaux(signal, callback, object, nullptr);
471 }
472
473 return connection;
474}
std::map< void *, std::shared_ptr< CallbackCounterSemaphore > > stateCallbackConnections

References smacc2::utils::Bind< arity >::bindaux(), getLogger(), m_mutex_, and stateCallbackConnections.

Referenced by smacc2::ISmaccClient::connectSignal(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onAborted(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onCancelled(), 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(), smacc2::client_bases::SmaccActionClientBase< ActionType >::onSucceeded(), smacc2::SmaccAsyncClientBehavior::onSuccess(), cl_ros_timer::ClRosTimer::onTimerTick(), cl_ros_timer::CbTimerCountdownLoop::onTimerTick(), and cl_ros_timer::CbTimerCountdownOnce::onTimerTick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnectSmaccSignalObject()

void smacc2::ISmaccStateMachine::disconnectSmaccSignalObject ( void *  object)

Definition at line 80 of file smacc_state_machine.cpp.

81{
82 RCLCPP_INFO(
83 nh_->get_logger(), "[SmaccSignals] object signal disconnecting %ld", (long)object_ptr);
84 if (stateCallbackConnections.count(object_ptr) > 0)
85 {
86 auto callbackSemaphore = stateCallbackConnections[object_ptr];
87 callbackSemaphore->finalize();
88 stateCallbackConnections.erase(object_ptr);
89 }
90 else
91 {
92 RCLCPP_INFO(nh_->get_logger(), "[SmaccSignals] no signals found %ld", (long)object_ptr);
93 }
94}

References nh_, and stateCallbackConnections.

Referenced by notifyOnStateExited(), and smacc2::ISmaccOrthogonal::onDispose().

Here is the caller graph for this function:

◆ eStop()

void smacc2::ISmaccStateMachine::eStop ( )
virtual

◆ getCurrentState()

ISmaccState * smacc2::ISmaccStateMachine::getCurrentState ( ) const
inline

Definition at line 749 of file smacc_state_machine_impl.hpp.

749{ return this->currentState_.back(); }
std::vector< ISmaccState * > currentState_

References currentState_.

◆ getCurrentStateCounter()

uint64_t smacc2::ISmaccStateMachine::getCurrentStateCounter ( ) const
inline

Definition at line 747 of file smacc_state_machine_impl.hpp.

747{ return this->stateSeqCounter_; }

References stateSeqCounter_.

◆ getCurrentStateInfo()

std::shared_ptr< SmaccStateInfo > smacc2::ISmaccStateMachine::getCurrentStateInfo ( )
inline

Definition at line 106 of file smacc_state_machine.hpp.

106{ return currentStateInfo_; }
std::shared_ptr< SmaccStateInfo > currentStateInfo_

References currentStateInfo_.

◆ getGlobalSMData()

template<typename T >
bool smacc2::ISmaccStateMachine::getGlobalSMData ( std::string  name,
T &  ret 
)

Definition at line 224 of file smacc_state_machine_impl.hpp.

225{
226 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
227 // RCLCPP_WARN(getLogger(),"get SM Data lock acquire");
228 bool success = false;
229
230 if (!globalData_.count(name))
231 {
232 // RCLCPP_WARN(getLogger(),"get SM Data - data do not exist");
233 success = false;
234 }
235 else
236 {
237 // RCLCPP_WARN(getLogger(),"get SM DAta -data exist. accessing");
238 try
239 {
240 auto & v = globalData_[name];
241
242 // RCLCPP_WARN(getLogger(),"get SM DAta -data exist. any cast");
243 ret = boost::any_cast<T>(v.second);
244 success = true;
245 // RCLCPP_WARN(getLogger(),"get SM DAta -data exist. success");
246 }
247 catch (boost::bad_any_cast & ex)
248 {
249 RCLCPP_ERROR(getLogger(), "bad any cast: %s", ex.what());
250 success = false;
251 }
252 }
253
254 // RCLCPP_WARN(getLogger(),"get SM Data lock release");
255 return success;
256}
std::map< std::string, std::pair< std::function< std::string()>, boost::any > > globalData_

References getLogger(), globalData_, and m_mutex_.

Referenced by smacc2::ISmaccOrthogonal::getGlobalSMData(), smacc2::ISmaccState::getGlobalSMData(), and mapBehavior().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLogger()

rclcpp::Logger smacc2::ISmaccStateMachine::getLogger ( )
inline

◆ getMutex()

std::recursive_mutex & smacc2::ISmaccStateMachine::getMutex ( )
inline

Definition at line 155 of file smacc_state_machine.hpp.

155{ return this->m_mutex_; }

References m_mutex_.

◆ getNode()

rclcpp::Node::SharedPtr smacc2::ISmaccStateMachine::getNode ( )

◆ getOrthogonal()

template<typename TOrthogonal >
TOrthogonal * smacc2::ISmaccStateMachine::getOrthogonal

Definition at line 55 of file smacc_state_machine_impl.hpp.

56{
57 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
58
59 std::string orthogonalkey = demangledTypeName<TOrthogonal>();
60 TOrthogonal * ret;
61
62 auto it = orthogonals_.find(orthogonalkey);
63
64 if (it != orthogonals_.end())
65 {
66 RCLCPP_DEBUG(
67 getLogger(),
68 "Orthogonal %s resource is being required from some state, client or component. Found "
69 "resource in "
70 "cache.",
71 orthogonalkey.c_str());
72 ret = dynamic_cast<TOrthogonal *>(it->second.get());
73 return ret;
74 }
75 else
76 {
77 std::stringstream ss;
78 ss << "Orthogonal not found " << orthogonalkey.c_str() << std::endl;
79 ss << "The existing orthogonals are the following: " << std::endl;
80 for (auto & orthogonal : orthogonals_)
81 {
82 ss << " - " << orthogonal.first << std::endl;
83 }
84
85 RCLCPP_WARN_STREAM(getLogger(), ss.str());
86
87 return nullptr;
88 }
89}

References getLogger(), m_mutex_, and orthogonals_.

Referenced by smacc2::ISmaccState::getOrthogonal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrthogonals()

const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & smacc2::ISmaccStateMachine::getOrthogonals ( ) const

◆ getStateMachineInfo()

const smacc2::introspection::SmaccStateMachineInfo & smacc2::ISmaccStateMachine::getStateMachineInfo ( )
inline

Definition at line 751 of file smacc_state_machine_impl.hpp.

752{
753 return *this->stateMachineInfo_;
754}

References stateMachineInfo_.

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::getStateInfo().

Here is the caller graph for this function:

◆ getStateMachineName()

std::string smacc2::ISmaccStateMachine::getStateMachineName ( )

Definition at line 224 of file smacc_state_machine.cpp.

225{
226 return demangleSymbol(typeid(*this).name());
227}
std::string demangleSymbol()

References smacc2::introspection::demangleSymbol().

Here is the call graph for this function:

◆ getTransitionLogHistory()

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 185 of file smacc_state_machine.cpp.

189{
190 RCLCPP_WARN(
191 nh_->get_logger(), "Requesting Transition Log History, current size: %ld",
192 this->transitionLogHistory_.size());
193 res->history = this->transitionLogHistory_;
194}
std::vector< smacc2_msgs::msg::SmaccTransitionLogEntry > transitionLogHistory_

References nh_, and transitionLogHistory_.

Referenced by initializeROS().

Here is the caller graph for this function:

◆ initializeROS()

void smacc2::ISmaccStateMachine::initializeROS ( std::string  smshortname)
protected

Definition at line 166 of file smacc_state_machine.cpp.

167{
168 RCLCPP_WARN_STREAM(nh_->get_logger(), "State machine base creation:" << shortname);
169 // STATE MACHINE TOPICS
170 stateMachinePub_ = nh_->create_publisher<smacc2_msgs::msg::SmaccStateMachine>(
171 shortname + "/smacc/state_machine_description", 1);
173 nh_->create_publisher<smacc2_msgs::msg::SmaccStatus>(shortname + "/smacc/status", 1);
174 transitionLogPub_ = nh_->create_publisher<smacc2_msgs::msg::SmaccTransitionLogEntry>(
175 shortname + "/smacc/transition_log", 1);
176
177 // STATE MACHINE SERVICES
178 transitionHistoryService_ = nh_->create_service<smacc2_msgs::srv::SmaccGetTransitionHistory>(
179 shortname + "/smacc/transition_log_history",
180 std::bind(
181 &ISmaccStateMachine::getTransitionLogHistory, this, std::placeholders::_1,
182 std::placeholders::_2, std::placeholders::_3));
183}
rclcpp::Publisher< smacc2_msgs::msg::SmaccStateMachine >::SharedPtr stateMachinePub_
rclcpp::Service< smacc2_msgs::srv::SmaccGetTransitionHistory >::SharedPtr transitionHistoryService_
rclcpp::Publisher< smacc2_msgs::msg::SmaccStatus >::SharedPtr stateMachineStatusPub_
rclcpp::Publisher< smacc2_msgs::msg::SmaccTransitionLogEntry >::SharedPtr transitionLogPub_
void 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)

References getTransitionLogHistory(), nh_, stateMachinePub_, stateMachineStatusPub_, transitionHistoryService_, and transitionLogPub_.

Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockStateMachine()

void smacc2::ISmaccStateMachine::lockStateMachine ( std::string  msg)
private

Definition at line 212 of file smacc_state_machine.cpp.

213{
214 RCLCPP_DEBUG(nh_->get_logger(), "-- locking SM: %s", msg.c_str());
215 m_mutex_.lock();
216}

References m_mutex_, and nh_.

Referenced by notifyOnStateExited().

Here is the caller graph for this function:

◆ mapBehavior()

template<typename StateField , typename BehaviorType >
void smacc2::ISmaccStateMachine::mapBehavior

Definition at line 280 of file smacc_state_machine_impl.hpp.

281{
282 std::string stateFieldName = demangleSymbol(typeid(StateField).name());
283 std::string behaviorType = demangleSymbol(typeid(BehaviorType).name());
284 RCLCPP_INFO(
285 getLogger(), "Mapping state field '%s' to stateReactor '%s'", stateFieldName.c_str(),
286 behaviorType.c_str());
287 SmaccClientBehavior * globalreference;
288 if (!this->getGlobalSMData(stateFieldName, globalreference))
289 {
290 // Using the requires component approach, we force a unique existence
291 // of this component
292 BehaviorType * behavior;
293 this->requiresComponent(behavior);
294 globalreference = dynamic_cast<ISmaccClientBehavior *>(behavior);
295
296 this->setGlobalSMData(stateFieldName, globalreference);
297 }
298}
bool getGlobalSMData(std::string name, T &ret)
void setGlobalSMData(std::string name, T value)
void requiresComponent(SmaccComponentType *&storage, bool throwsException=false)

References smacc2::introspection::demangleSymbol(), getGlobalSMData(), getLogger(), requiresComponent(), and setGlobalSMData().

Here is the call graph for this function:

◆ notifyOnRuntimeConfigurationFinished()

template<typename StateType >
void smacc2::ISmaccStateMachine::notifyOnRuntimeConfigurationFinished ( StateType *  state)

Definition at line 561 of file smacc_state_machine_impl.hpp.

562{
563 for (auto pair : this->orthogonals_)
564 {
565 // RCLCPP_INFO(getLogger(),"ortho onruntime configure: %s", pair.second->getName().c_str());
566 auto & orthogonal = pair.second;
567 orthogonal->runtimeConfigure();
568 }
569
570 {
571 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
572 this->updateStatusMessage();
574
576 }
577}
StateMachineInternalAction stateMachineCurrentAction
void notifyStateConfigured(ISmaccState *currentState)

References currentState_, m_mutex_, smacc2::SignalDetector::notifyStateConfigured(), orthogonals_, signalDetector_, smacc2::STATE_ENTERING, stateMachineCurrentAction, and updateStatusMessage().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyOnRuntimeConfigured()

template<typename StateType >
void smacc2::ISmaccStateMachine::notifyOnRuntimeConfigured ( StateType *  state)

◆ notifyOnStateEntryEnd()

template<typename StateType >
void smacc2::ISmaccStateMachine::notifyOnStateEntryEnd ( StateType *  state)

Definition at line 493 of file smacc_state_machine_impl.hpp.

494{
495 RCLCPP_INFO(
496 getLogger(), "[%s] State OnEntry code finished",
497 demangleSymbol(typeid(StateType).name()).c_str());
498
499 auto currentState = this->currentState_.back();
500 for (auto pair : this->orthogonals_)
501 {
502 RCLCPP_DEBUG(getLogger(), "ortho onentry: %s", pair.second->getName().c_str());
503 auto & orthogonal = pair.second;
504 try
505 {
506 orthogonal->onEntry();
507 }
508 catch (const std::exception & e)
509 {
510 RCLCPP_ERROR(
511 getLogger(),
512 "[Orthogonal %s] Exception on Entry - continuing with next orthogonal. Exception info: %s",
513 pair.second->getName().c_str(), e.what());
514 }
515 }
516
517 for (auto & sr : currentState->getStateReactors())
518 {
519 auto srname = smacc2::demangleSymbol(typeid(*sr).name());
520 RCLCPP_INFO_STREAM(getLogger(), "state reactor onEntry: " << srname);
521 try
522 {
523 sr->onEntry();
524 }
525 catch (const std::exception & e)
526 {
527 RCLCPP_ERROR(
528 getLogger(),
529 "[State Reactor %s] Exception on Entry - continuing with next state reactor. Exception "
530 "info: %s",
531 srname.c_str(), e.what());
532 }
533 }
534
535 for (auto & eg : currentState->getEventGenerators())
536 {
537 auto egname = smacc2::demangleSymbol(typeid(*eg).name());
538 RCLCPP_INFO_STREAM(getLogger(), "event generator onEntry: " << egname);
539 try
540 {
541 eg->onEntry();
542 }
543 catch (const std::exception & e)
544 {
545 RCLCPP_ERROR(
546 getLogger(),
547 "[Event generator %s] Exception on Entry - continuing with next state reactor. Exception "
548 "info: %s",
549 egname.c_str(), e.what());
550 }
551 }
552
553 {
554 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
555 this->updateStatusMessage();
557 }
558}

References currentState_, smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, orthogonals_, smacc2::STATE_RUNNING, stateMachineCurrentAction, and updateStatusMessage().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyOnStateEntryStart()

template<typename StateType >
void smacc2::ISmaccStateMachine::notifyOnStateEntryStart ( StateType *  state)

Definition at line 477 of file smacc_state_machine_impl.hpp.

478{
479 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
480
481 RCLCPP_DEBUG(
482 getLogger(),
483 "[State Machne] Initializing a new state '%s' and updating current state. Getting state "
484 "meta-information. number of orthogonals: %ld",
485 demangleSymbol(typeid(StateType).name()).c_str(), this->orthogonals_.size());
486
488 currentState_.push_back(state);
489 currentStateInfo_ = stateMachineInfo_->getState<StateType>();
490}

References currentState_, currentStateInfo_, smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, orthogonals_, stateMachineInfo_, and stateSeqCounter_.

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::entryStateInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyOnStateExited()

template<typename StateType >
void smacc2::ISmaccStateMachine::notifyOnStateExited ( StateType *  state)

Definition at line 648 of file smacc_state_machine_impl.hpp.

649{
650 this->lockStateMachine("state exit");
651
653
654 auto fullname = demangleSymbol(typeid(StateType).name());
655 RCLCPP_WARN_STREAM(getLogger(), "exiting state: " << fullname);
656
657 RCLCPP_INFO_STREAM(getLogger(), "Notification State Disposing: leaving state" << state);
658 for (auto pair : this->orthogonals_)
659 {
660 auto & orthogonal = pair.second;
661 try
662 {
663 orthogonal->onDispose();
664 }
665 catch (const std::exception & e)
666 {
667 RCLCPP_ERROR(
668 getLogger(),
669 "[Orthogonal %s] Exception onDispose - continuing with next orthogonal. Exception info: %s",
670 pair.second->getName().c_str(), e.what());
671 }
672 }
673
674 for (auto & sr : state->getStateReactors())
675 {
676 auto srname = smacc2::demangleSymbol(typeid(*sr).name()).c_str();
677 RCLCPP_INFO(getLogger(), "state reactor disposing: %s", srname);
678 try
679 {
680 this->disconnectSmaccSignalObject(sr.get());
681 }
682 catch (const std::exception & e)
683 {
684 RCLCPP_ERROR(
685 getLogger(),
686 "[State Reactor %s] Exception on OnDispose - continuing with next state reactor. Exception "
687 "info: %s",
688 srname, e.what());
689 }
690 }
691
692 for (auto & eg : state->getEventGenerators())
693 {
694 auto egname = smacc2::demangleSymbol(typeid(*eg).name()).c_str();
695 RCLCPP_INFO(getLogger(), "state reactor disposing: %s", egname);
696 try
697 {
698 this->disconnectSmaccSignalObject(eg.get());
699 }
700 catch (const std::exception & e)
701 {
702 RCLCPP_ERROR(
703 getLogger(),
704 "[State Reactor %s] Exception on OnDispose - continuing with next state reactor. Exception "
705 "info: %s",
706 egname, e.what());
707 }
708 }
709
710 this->stateCallbackConnections.clear();
711 currentState_.pop_back();
712
713 // then call exit state
714 RCLCPP_WARN_STREAM(getLogger(), "state exit: " << fullname);
715
717 this->unlockStateMachine("state exit");
718}
void lockStateMachine(std::string msg)
void disconnectSmaccSignalObject(void *object)
void unlockStateMachine(std::string msg)
void notifyStateExited(ISmaccState *currentState)

References currentState_, smacc2::introspection::demangleSymbol(), disconnectSmaccSignalObject(), getLogger(), lockStateMachine(), smacc2::SignalDetector::notifyStateExited(), orthogonals_, signalDetector_, stateCallbackConnections, stateMachineCurrentAction, smacc2::TRANSITIONING, and unlockStateMachine().

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyOnStateExitting()

template<typename StateType >
void smacc2::ISmaccStateMachine::notifyOnStateExitting ( StateType *  state)

Definition at line 586 of file smacc_state_machine_impl.hpp.

587{
589 auto fullname = demangleSymbol(typeid(StateType).name());
590 RCLCPP_WARN_STREAM(getLogger(), "exiting state: " << fullname);
591 // this->set_parameter("destroyed", true);
592
593 RCLCPP_INFO_STREAM(getLogger(), "Notification State Exit: leaving state " << state);
594 for (auto pair : this->orthogonals_)
595 {
596 auto & orthogonal = pair.second;
597 try
598 {
599 orthogonal->onExit();
600 }
601 catch (const std::exception & e)
602 {
603 RCLCPP_ERROR(
604 getLogger(),
605 "[Orthogonal %s] Exception onExit - continuing with next orthogonal. Exception info: %s",
606 pair.second->getName().c_str(), e.what());
607 }
608 }
609
610 for (auto & sr : state->getStateReactors())
611 {
612 auto srname = smacc2::demangleSymbol(typeid(*sr).name());
613 RCLCPP_INFO_STREAM(getLogger(), "state reactor OnExit: " << srname);
614 try
615 {
616 sr->onExit();
617 }
618 catch (const std::exception & e)
619 {
620 RCLCPP_ERROR(
621 getLogger(),
622 "[State Reactor %s] Exception on OnExit - continuing with next state reactor. Exception "
623 "info: %s",
624 srname.c_str(), e.what());
625 }
626 }
627
628 for (auto & eg : state->getEventGenerators())
629 {
630 auto egname = smacc2::demangleSymbol(typeid(*eg).name());
631 RCLCPP_INFO_STREAM(getLogger(), "event generator OnExit: " << egname);
632 try
633 {
634 eg->onExit();
635 }
636 catch (const std::exception & e)
637 {
638 RCLCPP_ERROR(
639 getLogger(),
640 "[State Reactor %s] Exception on OnExit - continuing with next state reactor. Exception "
641 "info: %s",
642 egname.c_str(), e.what());
643 }
644 }
645}

References smacc2::introspection::demangleSymbol(), getLogger(), orthogonals_, smacc2::STATE_EXITING, and stateMachineCurrentAction.

Referenced by smacc2::SmaccState< MostDerived, Context, InnerInitial, historyMode >::exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onInitialize()

void smacc2::ISmaccStateMachine::onInitialize ( )
virtual

this function should be implemented by the user to create the orthogonals

Definition at line 157 of file smacc_state_machine.cpp.

157{}

Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().

Here is the caller graph for this function:

◆ onInitialized()

void smacc2::ISmaccStateMachine::onInitialized ( )
protected

Definition at line 159 of file smacc_state_machine.cpp.

160{
161 auto ros_clock = rclcpp::Clock::make_shared();
162 timer_ =
163 rclcpp::create_timer(nh_, ros_clock, 0.5s, [=]() { this->state_machine_visualization(); });
164}
rclcpp::TimerBase::SharedPtr timer_

References nh_, state_machine_visualization(), and timer_.

Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postEvent() [1/2]

template<typename EventType >
void smacc2::ISmaccStateMachine::postEvent ( EventLifeTime  evlifetime = EventLifeTime::ABSOLUTE)

Definition at line 215 of file smacc_state_machine_impl.hpp.

216{
217 auto evname = smacc2::introspection::demangleSymbol<EventType>();
218 RCLCPP_INFO_STREAM(getLogger(), "Event " << evname);
219 auto * ev = new EventType();
220 this->postEvent(ev, evlifetime);
221}
void postEvent(EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)

References getLogger(), and postEvent().

Here is the call graph for this function:

◆ postEvent() [2/2]

template<typename EventType >
void smacc2::ISmaccStateMachine::postEvent ( EventType *  ev,
EventLifeTime  evlifetime = EventLifeTime::ABSOLUTE 
)

Definition at line 177 of file smacc_state_machine_impl.hpp.

178{
179 std::lock_guard<std::recursive_mutex> guard(eventQueueMutex_);
180
181#define eventtypename demangleSymbol<EventType>().c_str()
182
184
185 if (
186 evlifetime == EventLifeTime::CURRENT_STATE &&
189 {
190 RCLCPP_WARN_STREAM(
191 getLogger(),
192 "[ISmaccStateMachine] CURRENT STATE SCOPED EVENT DISCARDED, state is exiting/transitioning "
193 << eventtypename);
194 return;
195 // in this case we may lose/skip events, if this is not right for some cases we should create a
196 // queue to lock the events during the transitions. This issues appeared when a client
197 // asyncbehavior was posting an event meanwhile we were doing the transition, but the main
198 // thread was waiting for its correct finalization (with thread.join)
199 }
200
201 // when a postting event is requested by any component, client, or client behavior
202 // we reach this place. Now, we propagate the events to all the state state reactors to generate
203 // some more events
204
205 RCLCPP_DEBUG_STREAM(getLogger(), "[PostEvent entry point] " << eventtypename);
206 for (auto currentState : currentState_)
207 {
208 propagateEventToStateReactors(currentState, ev);
209 }
210
211 this->signalDetector_->postEvent(ev);
212}
std::recursive_mutex eventQueueMutex_
void propagateEventToStateReactors(ISmaccState *st, EventType *ev)
void postEvent(EventType *ev)
#define eventtypename
void TRACEPOINT(spinOnce)
smacc2_event

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::ISmaccClientBehavior::postEvent(), smacc2::ISmaccState::postEvent(), postEvent(), and smacc2::StateReactor::setOutputEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ propagateEventToStateReactors()

template<typename EventType >
void smacc2::ISmaccStateMachine::propagateEventToStateReactors ( ISmaccState st,
EventType *  ev 
)
private

Definition at line 721 of file smacc_state_machine_impl.hpp.

722{
723 RCLCPP_DEBUG(
724 getLogger(), "PROPAGATING EVENT [%s] TO SRs [%s]: ", demangleSymbol<EventType>().c_str(),
725 st->getClassName().c_str());
726 for (auto & sb : st->getStateReactors())
727 {
728 sb->notifyEvent(ev);
729 }
730
731 auto * pst = st->getParentState();
732 if (pst != nullptr)
733 {
735 }
736}

References smacc2::ISmaccState::getClassName(), getLogger(), smacc2::ISmaccState::getParentState(), smacc2::ISmaccState::getStateReactors(), and propagateEventToStateReactors().

Referenced by postEvent(), and propagateEventToStateReactors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishTransition()

void smacc2::ISmaccStateMachine::publishTransition ( const SmaccTransitionInfo transitionInfo)

Definition at line 147 of file smacc_state_machine.cpp.

148{
149 smacc2_msgs::msg::SmaccTransitionLogEntry transitionLogEntry;
150 transitionLogEntry.timestamp = this->nh_->now();
151 transitionInfoToMsg(transitionInfo, transitionLogEntry.transition);
152 this->transitionLogHistory_.push_back(transitionLogEntry);
153
154 transitionLogPub_->publish(transitionLogEntry);
155}
void transitionInfoToMsg(const SmaccTransitionInfo &transition, smacc2_msgs::msg::SmaccTransition &transitionMsg)
Definition: reflection.cpp:30

References nh_, smacc2::introspection::transitionInfoToMsg(), transitionLogHistory_, and transitionLogPub_.

Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::initiate_impl(), and smacc2::ISmaccState::notifyTransitionFromTransitionTypeInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ requiresComponent()

template<typename SmaccComponentType >
void smacc2::ISmaccStateMachine::requiresComponent ( SmaccComponentType *&  storage,
bool  throwsException = false 
)

Definition at line 126 of file smacc_state_machine_impl.hpp.

127{
128 RCLCPP_DEBUG(
129 getLogger(), "component %s is required",
130 demangleSymbol(typeid(SmaccComponentType).name()).c_str());
131 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
132
133 for (auto ortho : this->orthogonals_)
134 {
135 for (auto & client : ortho.second->clients_)
136 {
137 storage = client->getComponent<SmaccComponentType>();
138 if (storage != nullptr)
139 {
140 return;
141 }
142 }
143 }
144
145 RCLCPP_WARN(
146 getLogger(), "component %s is required but it was not found in any orthogonal",
147 demangleSymbol(typeid(SmaccComponentType).name()).c_str());
148
149 if (throwsException)
150 throw std::runtime_error("component is required but it was not found in any orthogonal");
151
152 // std::string componentkey = demangledTypeName<SmaccComponentType>();
153 // SmaccComponentType *ret;
154
155 // auto it = components_.find(componentkey);
156
157 // if (it == components_.end())
158 // {
159 // RCLCPP_DEBUG(getLogger(),"%s smacc component is required. Creating a new instance.",
160 // componentkey.c_str());
161
162 // ret = new SmaccComponentType();
163 // ret->setStateMachine(this);
164 // components_[componentkey] = static_cast<smacc2::ISmaccComponent *>(ret);
165 // RCLCPP_DEBUG(getLogger(),"%s resource is required. Done.", componentkey.c_str());
166 // }
167 // else
168 // {
169 // RCLCPP_DEBUG(getLogger(),"%s resource is required. Found resource in cache.",
170 // componentkey.c_str()); ret = dynamic_cast<SmaccComponentType *>(it->second);
171 // }
172
173 // storage = ret;
174}

References smacc2::introspection::demangleSymbol(), getLogger(), m_mutex_, and orthogonals_.

Referenced by mapBehavior(), smacc2::ISmaccClientBehavior::requiresComponent(), smacc2::ISmaccOrthogonal::requiresComponent(), and smacc2::ISmaccState::requiresComponent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void smacc2::ISmaccStateMachine::reset ( )
virtual

◆ setGlobalSMData()

template<typename T >
void smacc2::ISmaccStateMachine::setGlobalSMData ( std::string  name,
value 
)

Definition at line 259 of file smacc_state_machine_impl.hpp.

260{
261 {
262 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
263 // RCLCPP_WARN(getLogger(),"set SM Data lock acquire");
264
265 globalData_[name] = {
266 [this, name]()
267 {
268 std::stringstream ss;
269 auto val = any_cast<T>(globalData_[name].second);
270 ss << val;
271 return ss.str();
272 },
273 value};
274 }
275
276 this->updateStatusMessage();
277}

References globalData_, m_mutex_, and updateStatusMessage().

Referenced by mapBehavior(), smacc2::ISmaccOrthogonal::setGlobalSMData(), and smacc2::ISmaccState::setGlobalSMData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ state_machine_visualization()

void smacc2::ISmaccStateMachine::state_machine_visualization ( )

Definition at line 196 of file smacc_state_machine.cpp.

197{
198 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
199
200 smacc2_msgs::msg::SmaccStateMachine state_machine_msg;
201 state_machine_msg.states = stateMachineInfo_->stateMsgs;
202
203 std::sort(
204 state_machine_msg.states.begin(), state_machine_msg.states.end(),
205 [](auto & a, auto & b) { return a.index < b.index; });
206 stateMachinePub_->publish(state_machine_msg);
207
208 status_msg_.header.stamp = this->nh_->now();
210}
smacc2_msgs::msg::SmaccStatus status_msg_

References m_mutex_, nh_, stateMachineInfo_, stateMachinePub_, stateMachineStatusPub_, and status_msg_.

Referenced by onInitialized().

Here is the caller graph for this function:

◆ stop()

void smacc2::ISmaccStateMachine::stop ( )
virtual

Reimplemented in smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >.

Definition at line 100 of file smacc_state_machine.cpp.

100{}

Referenced by smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::stop().

Here is the caller graph for this function:

◆ unlockStateMachine()

void smacc2::ISmaccStateMachine::unlockStateMachine ( std::string  msg)
private

Definition at line 218 of file smacc_state_machine.cpp.

219{
220 RCLCPP_DEBUG(nh_->get_logger(), "-- unlocking SM: %s", msg.c_str());
221 m_mutex_.unlock();
222}

References m_mutex_, and nh_.

Referenced by notifyOnStateExited().

Here is the caller graph for this function:

◆ updateStatusMessage()

void smacc2::ISmaccStateMachine::updateStatusMessage ( )
private

Definition at line 110 of file smacc_state_machine.cpp.

111{
112 std::lock_guard<std::recursive_mutex> lock(m_mutex_);
113
114 if (currentStateInfo_ != nullptr)
115 {
116 RCLCPP_WARN_STREAM(
117 nh_->get_logger(), "[StateMachine] setting state active "
118 << ": " << currentStateInfo_->getFullPath());
119
121 {
122 status_msg_.current_states.clear();
123 std::list<const SmaccStateInfo *> ancestorList;
124 currentStateInfo_->getAncestors(ancestorList);
125
126 for (auto & ancestor : ancestorList)
127 {
128 status_msg_.current_states.push_back(ancestor->toShortName());
129 }
130
131 status_msg_.global_variable_names.clear();
132 status_msg_.global_variable_values.clear();
133
134 for (auto entry : this->globalData_)
135 {
136 status_msg_.global_variable_names.push_back(entry.first);
137 status_msg_.global_variable_values.push_back(
138 entry.second.first()); // <- invoke to_string()
139 }
140
141 status_msg_.header.stamp = this->nh_->now();
143 }
144 }
145}

References currentStateInfo_, smacc2::DEBUG, globalData_, m_mutex_, nh_, runMode_, stateMachineStatusPub_, and status_msg_.

Referenced by notifyOnRuntimeConfigurationFinished(), notifyOnStateEntryEnd(), and setGlobalSMData().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ISmaccState

friend class ISmaccState
friend

Definition at line 220 of file smacc_state_machine.hpp.

◆ SignalDetector

friend class SignalDetector
friend

Definition at line 221 of file smacc_state_machine.hpp.

Member Data Documentation

◆ currentState_

std::vector<ISmaccState *> smacc2::ISmaccStateMachine::currentState_
protected

◆ currentStateInfo_

std::shared_ptr<SmaccStateInfo> smacc2::ISmaccStateMachine::currentStateInfo_
protected

◆ eventQueueMutex_

std::recursive_mutex smacc2::ISmaccStateMachine::eventQueueMutex_
private

Definition at line 192 of file smacc_state_machine.hpp.

Referenced by postEvent().

◆ globalData_

std::map<std::string, std::pair<std::function<std::string()>, boost::any> > smacc2::ISmaccStateMachine::globalData_
private

Definition at line 199 of file smacc_state_machine.hpp.

Referenced by getGlobalSMData(), setGlobalSMData(), and updateStatusMessage().

◆ m_mutex_

std::recursive_mutex smacc2::ISmaccStateMachine::m_mutex_
private

◆ nh_

rclcpp::Node::SharedPtr smacc2::ISmaccStateMachine::nh_
protected

◆ orthogonals_

std::map<std::string, std::shared_ptr<smacc2::ISmaccOrthogonal> > smacc2::ISmaccStateMachine::orthogonals_
protected

◆ runMode_

smacc2::SMRunMode smacc2::ISmaccStateMachine::runMode_
private

Definition at line 204 of file smacc_state_machine.hpp.

Referenced by ISmaccStateMachine(), and updateStatusMessage().

◆ signalDetector_

SignalDetector* smacc2::ISmaccStateMachine::signalDetector_
private

◆ stateCallbackConnections

std::map<void *, std::shared_ptr<CallbackCounterSemaphore> > smacc2::ISmaccStateMachine::stateCallbackConnections
private

◆ stateMachineCurrentAction

StateMachineInternalAction smacc2::ISmaccStateMachine::stateMachineCurrentAction
private

◆ stateMachineInfo_

std::shared_ptr<SmaccStateMachineInfo> smacc2::ISmaccStateMachine::stateMachineInfo_
protected

◆ stateMachinePub_

rclcpp::Publisher<smacc2_msgs::msg::SmaccStateMachine>::SharedPtr smacc2::ISmaccStateMachine::stateMachinePub_
protected

Definition at line 171 of file smacc_state_machine.hpp.

Referenced by initializeROS(), and state_machine_visualization().

◆ stateMachineStatusPub_

rclcpp::Publisher<smacc2_msgs::msg::SmaccStatus>::SharedPtr smacc2::ISmaccStateMachine::stateMachineStatusPub_
protected

◆ stateSeqCounter_

uint64_t smacc2::ISmaccStateMachine::stateSeqCounter_
private

Definition at line 209 of file smacc_state_machine.hpp.

Referenced by getCurrentStateCounter(), and notifyOnStateEntryStart().

◆ status_msg_

smacc2_msgs::msg::SmaccStatus smacc2::ISmaccStateMachine::status_msg_
protected

Definition at line 182 of file smacc_state_machine.hpp.

Referenced by state_machine_visualization(), and updateStatusMessage().

◆ timer_

rclcpp::TimerBase::SharedPtr smacc2::ISmaccStateMachine::timer_
protected

Definition at line 170 of file smacc_state_machine.hpp.

Referenced by onInitialized().

◆ transitionHistoryService_

rclcpp::Service<smacc2_msgs::srv::SmaccGetTransitionHistory>::SharedPtr smacc2::ISmaccStateMachine::transitionHistoryService_
protected

Definition at line 174 of file smacc_state_machine.hpp.

Referenced by initializeROS().

◆ transitionLogHistory_

std::vector<smacc2_msgs::msg::SmaccTransitionLogEntry> smacc2::ISmaccStateMachine::transitionLogHistory_
private

Definition at line 202 of file smacc_state_machine.hpp.

Referenced by getTransitionLogHistory(), and publishTransition().

◆ transitionLogPub_

rclcpp::Publisher<smacc2_msgs::msg::SmaccTransitionLogEntry>::SharedPtr smacc2::ISmaccStateMachine::transitionLogPub_
protected

Definition at line 173 of file smacc_state_machine.hpp.

Referenced by initializeROS(), and publishTransition().


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