23#include <boost/any.hpp>
35#include <smacc2_msgs/msg/smacc_state_machine.hpp>
36#include <smacc2_msgs/msg/smacc_status.hpp>
37#include <smacc2_msgs/msg/smacc_transition_log_entry.hpp>
38#include <smacc2_msgs/srv/smacc_get_transition_history.hpp>
72 const rclcpp::NodeOptions & nodeOptions = rclcpp::NodeOptions());
95 template <
typename TOrthogonal>
100 template <
typename TOrthogonal,
typename TClientBehavior>
108 const std::map<std::string, std::shared_ptr<smacc2::ISmaccOrthogonal>> &
getOrthogonals()
const;
112 template <
typename SmaccComponentType>
117 template <
typename SmaccComponentType>
124 template <
typename EventType>
128 template <
typename EventType>
130 const boost::intrusive_ptr<EventType> & evHolder,
133 template <
typename EventType>
137 template <
typename T>
141 template <
typename T>
158 const std::string & stateName,
const std::string & what);
161 const std::shared_ptr<rmw_request_id_t> request_header,
162 const std::shared_ptr<smacc2_msgs::srv::SmaccGetTransitionHistory::Request> req,
163 std::shared_ptr<smacc2_msgs::srv::SmaccGetTransitionHistory::Response> res);
165 template <
typename TSmaccSignal,
typename TMemberFunctionPrototype,
typename TSmaccObjectType>
167 TSmaccSignal & signal, TMemberFunctionPrototype callback, TSmaccObjectType *
object);
175 template <
typename T>
181 template <
typename StateType>
184 template <
typename StateType>
187 template <
typename StateType>
190 template <
typename StateType>
193 template <
typename StateType>
196 template <
typename StateType>
205 template <
typename InitialStateType>
208 rclcpp::Node::SharedPtr
getNode();
221 template <
typename TOrthogonal>
225 rclcpp::Node::SharedPtr
nh_;
245 std::map<std::string, std::shared_ptr<smacc2::ISmaccOrthogonal>>
orthogonals_;
264 std::map<std::string, std::pair<std::function<std::string()>, boost::any>>
globalData_;
284 template <
typename EventType>
std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > orthogonals_
void setGlobalSMData(const std::string &name, T value)
smacc2::SMRunMode runMode_
std::vector< ISmaccState * > currentState_
std::recursive_mutex eventQueueMutex_
virtual ~ISmaccStateMachine()
std::string getStateMachineName()
void publishTransition(const SmaccTransitionInfo &transitionInfo)
rclcpp::Publisher< smacc2_msgs::msg::SmaccStateMachine >::SharedPtr stateMachinePub_
std::shared_ptr< SmaccStateInfo > currentStateInfo_
TClientBehavior * getClientBehavior(int index=0)
rclcpp::Node::SharedPtr getNode()
std::map< std::string, std::pair< std::function< std::string()>, boost::any > > globalData_
std::deque< smacc2_msgs::msg::SmaccTransitionLogEntry > transitionLogHistory_
virtual void onUnhandledStInitializationFailure(const std::string &stateName, const std::string &what)
rclcpp::Service< smacc2_msgs::srv::SmaccGetTransitionHistory >::SharedPtr transitionHistoryService_
virtual void onInitialize()
this function should be implemented by the user to create the orthogonals
ISmaccStateMachine(const ISmaccStateMachine &)=delete
ISmaccStateMachine(ISmaccStateMachine &&)=delete
void joinAsyncClientBehaviorThreads()
TOrthogonal * getOrthogonal()
void buildStateMachineInfo()
std::atomic< StateMachineInternalAction > stateMachineCurrentAction
void notifyOnRuntimeConfigurationFinished(StateType *state)
void disconnectSmaccSignalObject(void *object_ptr)
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals() const
std::recursive_mutex m_mutex_
rclcpp::Publisher< smacc2_msgs::msg::SmaccStatus >::SharedPtr stateMachineStatusPub_
ISmaccStateMachine(std::string stateMachineName, SignalDetector *signalDetector, const rclcpp::NodeOptions &nodeOptions=rclcpp::NodeOptions())
bool getGlobalSMData(const std::string &name, T &ret)
void notifyOnStateExited(StateType *state)
void notifyOnStateEntryEnd(StateType *state)
void propagateEventToStateReactors(ISmaccState *st, EventType *ev)
const SmaccStateMachineInfo & getStateMachineInfo()
rclcpp::Node::SharedPtr nh_
size_t transitionLogHistorySize_
static thread_local int reactorWalkDepth_
std::shared_ptr< SmaccStateInfo > getCurrentStateInfo()
void initializeROS(const std::string &shortname)
int64_t getCurrentStateCounter() const
ISmaccStateMachine & operator=(const ISmaccStateMachine &)=delete
void unlockStateMachine(const std::string &msg)
rclcpp::TimerBase::SharedPtr timer_
rclcpp::Publisher< smacc2_msgs::msg::SmaccTransitionLogEntry >::SharedPtr transitionLogPub_
ISmaccState * getCurrentState() const
void checkStateMachineConsistence()
void notifyOnStateExiting(StateType *state)
SignalDetector * signalDetector_
std::map< void *, std::shared_ptr< CallbackCounterSemaphore > > stateCallbackConnections
void lockStateMachine(const std::string &msg)
rclcpp::Logger getLogger()
void notifyOnRuntimeConfigured(StateType *state)
ISmaccStateMachine & operator=(ISmaccStateMachine &&)=delete
std::mutex transitionLogMutex_
smacc2_msgs::msg::SmaccStatus status_msg_
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType, ISmaccOrthogonal *first=nullptr)
void state_machine_visualization()
std::enable_if_t< std::is_polymorphic< T >::value > disconnectSmaccSignalObject(T *object)
std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo_
void postEvent(EventType *ev, EventLifeTime evlifetime=EventLifeTime::ABSOLUTE)
rclcpp::Publisher< smacc2_msgs::msg::SmaccEvent >::SharedPtr eventsLogPub_
void updateStatusMessage()
std::recursive_mutex & getMutex()
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)
void notifyOnStateEntryStart(StateType *state)
boost::signals2::connection SmaccSignalConnection
StateMachineInternalAction
@ STATE_MACHINE_INITIALIZING