SMACC2
st_state_1.hpp
Go to the documentation of this file.
1// Copyright 2021 MyName/MyCompany Inc.
2// Copyright 2021 RobosoftAI Inc. (template)
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include "rclcpp/rclcpp.hpp"
19#include "smacc2/smacc.hpp"
20
21// CLIENTS
22#include "ros_timer_client/cl_ros_timer.hpp"
23#include "ros_timer_client/client_behaviors/cb_timer_countdown_loop.hpp"
24#include "ros_timer_client/client_behaviors/cb_timer_countdown_once.hpp"
25
26// ORTHOGONALS
27using $sm_name$::OrTimer; // This is an example variable - feel free to delete it.
28
29namespace $sm_name$
30{
31// SMACC2 clases
35
39
41
42// STATE DECLARATION
43struct State1 : smacc2::SmaccState<State1, $SmName$>
44{
45 using SmaccState::SmaccState;
46
47 // TRANSITION TABLE - adjust as needed
48 typedef boost::mpl::list<
49
50 Transition<EvTimer<CbTimerCountdownOnce, OrTimer>, State2, SUCCESS>
51
53
54 // STATE FUNCTIONS
55 static void staticConfigure()
56 {
57 // START: Example code - change needed
58 configure_orthogonal<OrTimer, CbTimerCountdownLoop>(3); // EvTimer triggers each 3 client ticks
59 configure_orthogonal<OrTimer, CbTimerCountdownOnce>(5); // EvTimer triggers once at 10 client ticks
60 // END: Example code - change or delete as needed
61 }
62
64
65 void onEntry()
66 {
67 // START: Example code - change or delete as needed
68 RCLCPP_INFO(getLogger(), " On Entry!");
69 // END: Example code - change or delete as needed
70 }
71
72 void onExit()
73 {
74 // START: Example code - change or delete as needed
75 // Use Blackboard to get global state-machine data - example - feel free to delete it.
76 std::string output_message_note;
77 getGlobalSMData("output_message_note", output_message_note);
78 RCLCPP_INFO(getLogger(), (output_message_note + " On Exit!").c_str());
79 // END: Example code - change or delete as needed
80 }
81};
82}
rclcpp::Logger getLogger()
Definition: smacc_state.hpp:36
bool getGlobalSMData(std::string name, T &ret)
boost::mpl::list< Transition< EvTimer< CbTimerCountdownOnce, OrTimer >, State2, SUCCESS > > reactions
Definition: st_state_1.hpp:52
static void staticConfigure()
Definition: st_state_1.hpp:55
void runtimeConfigure()
Definition: st_state_1.hpp:63