SMACC2
sm_dance_bot.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
21#include <smacc2/smacc.hpp>
22
23#include <sensor_msgs/msg/laser_scan.hpp>
24
25// CLIENT BEHAVIORS
26#include <ros_timer_client/client_behaviors/cb_ros_timer.hpp>
27
29
32
33using namespace cl_nav2z;
34
37
40
43
47
49
50using namespace sm_dance_bot::cl_lidar;
51using namespace sm_dance_bot::cl_service3;
54using namespace sm_dance_bot::cl_led;
55
56//STATE REACTORS
60
61using namespace smacc2::state_reactors;
62
63// ORTHOGONALS
72
73namespace sm_dance_bot
74{
75//STATE FORWARD DECLARATIONS
78
82
89
94
95//SUPERSTATE FORWARD DECLARATIONS
96//MODE STATES FORWARD DECLARATIONS
99
100namespace SS1
101{
102class SsRadialPattern1;
103}
104
105namespace SS2
106{
107class SsRadialPattern2;
108}
109
110namespace SS3
111{
112class SsRadialPattern3;
113}
114
115namespace SS4
116{
117class SsFPattern1;
118}
119
120namespace SS5
121{
122class SsSPattern1;
123}
124
125// custom smd_dance_bot event
126struct EvGlobalError : sc::event<EvGlobalError>
127{
128};
129
130} // namespace sm_dance_bot
131
132using namespace sm_dance_bot;
133using namespace cl_ros_timer;
134using namespace smacc2;
135
136namespace sm_dance_bot
137{
140struct SmDanceBot : public smacc2::SmaccStateMachineBase<SmDanceBot, MsDanceBotRunMode>
141{
144
145 typedef mpl::bool_<false> shallow_history;
146 typedef mpl::bool_<false> deep_history;
147 typedef mpl::bool_<false> inherited_deep_history;
148
149 using SmaccStateMachineBase::SmaccStateMachineBase;
150
151 void onInitialize() override
152 {
153 this->setGlobalSMData("counter_1", counter_1);
154 this->setGlobalSMData("rt_ready_flag", rt_ready_flag);
155
156 this->createOrthogonal<OrNavigation>();
157 this->createOrthogonal<OrObstaclePerception>();
158 this->createOrthogonal<OrLED>();
159 this->createOrthogonal<OrTemperatureSensor>();
160 this->createOrthogonal<OrStringPublisher>();
161 this->createOrthogonal<OrService3>();
162 this->createOrthogonal<OrTimer>();
163 this->createOrthogonal<OrUpdatablePublisher>();
164 }
165};
166
167} // namespace sm_dance_bot
168
169//MODE STATES
171
173
174//SUPERSTATES
180
181//STATES
184
186
void setGlobalSMData(std::string name, T value)
Advanced example of state machine with smacc that shows multiple techniques for the development of st...
mpl::bool_< false > shallow_history
mpl::bool_< false > inherited_deep_history
mpl::bool_< false > deep_history
void onInitialize() override
this function should be implemented by the user to create the orthogonals