SMACC
Loading...
Searching...
No Matches
smacc_state.h
Go to the documentation of this file.
1/*****************************************************************************************************************
2 * ReelRobotix Inc. - Software License Agreement Copyright (c) 2018
3 * Authors: Pablo Inigo Blasco, Brett Aldrich
4 *
5 ******************************************************************************************************************/
6#pragma once
7#include <smacc/common.h>
8
9namespace smacc
10{
12 {
13 public:
15
17
18 inline ros::NodeHandle &getROSNode() { return nh; }
19
20 virtual std::string getClassName();
21
22 template <typename TOrthogonal, typename TBehavior, typename... Args>
23 std::shared_ptr<TBehavior> configure(Args &&... args);
24
25 template <typename SmaccComponentType>
26 void requiresComponent(SmaccComponentType *&storage);
27
28 template <typename SmaccClientType>
29 void requiresClient(SmaccClientType *&storage);
30
31 template <typename T>
32 bool getGlobalSMData(std::string name, T &ret);
33
34 // Store globally in this state machine. (By value parameter )
35 template <typename T>
36 void setGlobalSMData(std::string name, T value);
37
38 template <typename TStateReactor, typename TTriggerEvent, typename TEventList, typename... TEvArgs>
39 std::shared_ptr<TStateReactor> createStateReactor(TEvArgs... args);
40
41 template <typename TStateReactor, typename... TEvArgs>
42 std::shared_ptr<TStateReactor> createStateReactor(TEvArgs... args);
43
44 template <typename TEventGenerator, typename... TEvArgs>
45 std::shared_ptr<TEventGenerator> createEventGenerator(TEvArgs... args);
46
47 template <typename EventType>
48 void postEvent(const EventType &ev);
49
50 template <typename EventType>
51 void postEvent();
52
53 // used for transition logging
54 template <typename TransitionType>
55 void notifyTransition();
56
57 // used for transition logging
58 void notifyTransitionFromTransitionTypeInfo(std::shared_ptr<smacc::introspection::TypeInfo> &transitionTypeInfo);
59
60 inline std::vector<std::shared_ptr<StateReactor>> &getStateReactors() { return stateReactors_; }
61
62 inline std::vector<std::shared_ptr<SmaccEventGenerator>> &getEventGenerators() { return eventGenerators_; }
63
64 // Delegates to ROS param access with the current NodeHandle
65 template <typename T>
66 bool getParam(std::string param_name, T &param_storage);
67
68 // Delegates to ROS param access with the current NodeHandle
69 template <typename T>
70 void setParam(std::string param_name, T param_val);
71
72 //Delegates to ROS param access with the current NodeHandle
73 template <typename T>
74 bool param(std::string param_name, T &param_val, const T &default_val) const;
75
76 template <typename TOrthogonal>
77 TOrthogonal *getOrthogonal();
78
79 template <typename TEventGenerator>
80 TEventGenerator* getEventGenerator();
81
82 template <typename TStateReactor>
83 TStateReactor* getStateReactor();
84
85 protected:
86 std::vector<std::shared_ptr<StateReactor>> stateReactors_;
87 std::vector<std::shared_ptr<smacc::SmaccEventGenerator>> eventGenerators_;
88
89 ros::NodeHandle nh;
90
91 ros::NodeHandle contextNh;
92
94
96 };
97} // namespace smacc
void setParam(std::string param_name, T param_val)
TEventGenerator * getEventGenerator()
void setGlobalSMData(std::string name, T value)
ros::NodeHandle nh
Definition: smacc_state.h:89
std::vector< std::shared_ptr< SmaccEventGenerator > > & getEventGenerators()
Definition: smacc_state.h:62
ISmaccState * getParentState()
Definition: smacc_state.h:16
bool param(std::string param_name, T &param_val, const T &default_val) const
std::shared_ptr< TStateReactor > createStateReactor(TEvArgs... args)
virtual std::string getClassName()
Definition: smacc_state.cpp:6
TStateReactor * getStateReactor()
std::vector< std::shared_ptr< StateReactor > > stateReactors_
Definition: smacc_state.h:86
std::vector< std::shared_ptr< StateReactor > > & getStateReactors()
Definition: smacc_state.h:60
void requiresClient(SmaccClientType *&storage)
virtual ISmaccStateMachine & getStateMachine()=0
std::vector< std::shared_ptr< smacc::SmaccEventGenerator > > eventGenerators_
Definition: smacc_state.h:87
std::shared_ptr< TEventGenerator > createEventGenerator(TEvArgs... args)
bool getParam(std::string param_name, T &param_storage)
void notifyTransitionFromTransitionTypeInfo(std::shared_ptr< smacc::introspection::TypeInfo > &transitionTypeInfo)
Definition: smacc_state.cpp:11
std::shared_ptr< TBehavior > configure(Args &&... args)
ISmaccState * parentState_
Definition: smacc_state.h:93
bool getGlobalSMData(std::string name, T &ret)
ros::NodeHandle & getROSNode()
Definition: smacc_state.h:18
ros::NodeHandle contextNh
Definition: smacc_state.h:91
const smacc::introspection::SmaccStateInfo * stateInfo_
Definition: smacc_state.h:95
TOrthogonal * getOrthogonal()
void requiresComponent(SmaccComponentType *&storage)