SMACC2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType > Struct Template Reference

State Machine. More...

#include <smacc_state_machine_base.hpp>

Inheritance diagram for smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >:
Inheritance graph
Collaboration diagram for smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >:
Collaboration graph

Public Member Functions

 SmaccStateMachineBase (my_context ctx, SignalDetector *signalDetector, rclcpp::NodeOptions node_options=rclcpp::NodeOptions())
 
virtual ~SmaccStateMachineBase ()
 
void reset () override
 
void stop () override
 
void eStop () override
 
void initiate_impl () override
 
- Public Member Functions inherited from smacc2::ISmaccStateMachine
 ISmaccStateMachine (std::string stateMachineName, SignalDetector *signalDetector, rclcpp::NodeOptions nodeOptions=rclcpp::NodeOptions())
 
virtual ~ISmaccStateMachine ()
 
template<typename TOrthogonal >
TOrthogonalgetOrthogonal ()
 
template<typename TOrthogonal , typename TClientBehavior >
TClientBehaviorgetClientBehavior (int index=0)
 
const std::map< std::string, std::shared_ptr< smacc2::ISmaccOrthogonal > > & getOrthogonals () const
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, bool throwsExceptionIfNotExist=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
 
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)
 
int64_t getCurrentStateCounter () const
 
ISmaccStategetCurrentState () const
 
const SmaccStateMachineInfogetStateMachineInfo ()
 
template<typename InitialStateType >
void buildStateMachineInfo ()
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
std::recursive_mutex & getMutex ()
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccStateMachine
void checkStateMachineConsistence ()
 
void initializeROS (std::string smshortname)
 
void onInitialized ()
 
template<typename TOrthogonal >
void createOrthogonal ()
 
- Protected Attributes inherited from smacc2::ISmaccStateMachine
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::vector< boost::signals2::scoped_connection > longLivedSignalConnections_
 
std::shared_ptr< SmaccStateMachineInfostateMachineInfo_
 

Detailed Description

template<typename DerivedStateMachine, typename InitialStateType>
struct smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >

State Machine.

Definition at line 30 of file smacc_state_machine_base.hpp.

Constructor & Destructor Documentation

◆ SmaccStateMachineBase()

smacc2::SmaccStateMachineBase< DerivedStateMachine, InitialStateType >::SmaccStateMachineBase ( my_context  ctx,
SignalDetector signalDetector,
rclcpp::NodeOptions  node_options = rclcpp::NodeOptions() 
)
inline

Definition at line 36 of file smacc_state_machine_base.hpp.

40 smacc2::utils::cleanShortTypeName<DerivedStateMachine>(), signalDetector, node_options),
42 DerivedStateMachine, InitialStateType, SmaccFifoScheduler, SmaccAllocator>(ctx)
43 {
44 }
ISmaccStateMachine(std::string stateMachineName, SignalDetector *signalDetector, rclcpp::NodeOptions nodeOptions=rclcpp::NodeOptions())
boost::statechart::fifo_scheduler< SmaccFifoWorker, SmaccAllocator > SmaccFifoScheduler
std::allocator< boost::statechart::none > SmaccAllocator

◆ ~SmaccStateMachineBase()

Definition at line 46 of file smacc_state_machine_base.hpp.

47 {
48 //updateCurrentState<InitialStateType>(false);
49 }

Member Function Documentation

◆ eStop()

Reimplemented from smacc2::ISmaccStateMachine.

Definition at line 64 of file smacc_state_machine_base.hpp.

65 {
67 this->terminate();
68 }

References smacc2::ISmaccStateMachine::eStop().

Here is the call graph for this function:

◆ initiate_impl()

Definition at line 70 of file smacc_state_machine_base.hpp.

71 {
72 globalNh_ = this->getNode();
73
74 // this is before because this creates orthogonals
75 this->onInitialize();
76
77 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] Introspecting state machine via typeWalker");
78 this->buildStateMachineInfo<InitialStateType>();
79
80 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] initiate_impl");
81 auto shortname = smacc2::utils::cleanShortTypeName(typeid(DerivedStateMachine));
82
83 this->initializeROS(shortname);
84
85 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] Initializing ROS communication mechanisms");
86 this->onInitialized();
87
88 // publish startup state machine transition info
89 auto transitionInfo = std::make_shared<SmaccTransitionInfo>();
90 transitionInfo->destinyState = this->stateMachineInfo_->getState<InitialStateType>();
91 this->publishTransition(*transitionInfo);
92
93 RCLCPP_INFO(getLogger(), "[SmaccStateMachine] Initializing state machine");
94 sc::state_machine<DerivedStateMachine, InitialStateType, SmaccAllocator>::initiate();
95 }
void publishTransition(const SmaccTransitionInfo &transitionInfo)
rclcpp::Node::SharedPtr getNode()
virtual void onInitialize()
this function should be implemented by the user to create the orthogonals
void initializeROS(std::string smshortname)
std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo_
rclcpp::Node::SharedPtr globalNh_
std::string cleanShortTypeName()
Definition common.hpp:62

References smacc2::utils::cleanShortTypeName(), smacc2::ISmaccStateMachine::getLogger(), smacc2::ISmaccStateMachine::getNode(), smacc2::introspection::globalNh_, smacc2::ISmaccStateMachine::initializeROS(), smacc2::ISmaccStateMachine::onInitialize(), smacc2::ISmaccStateMachine::onInitialized(), smacc2::ISmaccStateMachine::publishTransition(), and smacc2::ISmaccStateMachine::stateMachineInfo_.

Here is the call graph for this function:

◆ reset()

Reimplemented from smacc2::ISmaccStateMachine.

Definition at line 51 of file smacc_state_machine_base.hpp.

References smacc2::ISmaccStateMachine::reset().

Here is the call graph for this function:

◆ stop()

Reimplemented from smacc2::ISmaccStateMachine.

Definition at line 58 of file smacc_state_machine_base.hpp.

59 {
61 this->terminate();
62 }

References smacc2::ISmaccStateMachine::stop().

Here is the call graph for this function:

The documentation for this struct was generated from the following file: