SMACC2
Loading...
Searching...
No Matches
smacc_default_events.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft 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#pragma once
22
24
25#include <boost/statechart/event.hpp>
26#include <boost/statechart/state.hpp>
27
28namespace smacc2
29{
30
31namespace default_events
32{
33using namespace smacc2::introspection;
35
36//-------------- ACTION EVENTS --------------------------------------------------------
37template <typename ActionFeedback, typename TOrthogonal>
38struct EvActionFeedback : sc::event<EvActionFeedback<ActionFeedback, TOrthogonal>>
39{
41 ActionFeedback feedbackMessage;
42};
43
44template <typename TSource, typename TOrthogonal>
45struct EvActionResult : sc::event<EvActionResult<TSource, TOrthogonal>>
46{
47 typename TSource::WrappedResult resultMessage;
48};
49
50template <typename TSource, typename TOrthogonal>
51struct EvActionSucceeded : sc::event<EvActionSucceeded<TSource, TOrthogonal>>
52{
53 typename TSource::WrappedResult resultMessage;
54
55 static std::string getEventLabel()
56 {
57 // show ros message type
58 std::string label;
60 return label;
61 }
62
63 static std::string getDefaultTransitionTag() { return demangledTypeName<SUCCESS>(); }
64
65 static std::string getDefaultTransitionType() { return demangledTypeName<SUCCESS>(); }
66};
67
68template <typename TSource, typename TOrthogonal>
69struct EvActionAborted : sc::event<EvActionAborted<TSource, TOrthogonal>>
70{
71 typename TSource::WrappedResult resultMessage;
72
73 static std::string getEventLabel()
74 {
75 // show ros message type
76 std::string label;
78 return label;
79 }
80
81 static std::string getDefaultTransitionTag() { return demangledTypeName<ABORT>(); }
82
83 static std::string getDefaultTransitionType() { return demangledTypeName<ABORT>(); }
84};
85
86template <typename TSource, typename TOrthogonal>
87struct EvActionCancelled : sc::event<EvActionCancelled<TSource, TOrthogonal>>
88{
89 typename TSource::WrappedResult resultMessage;
90
91 static std::string getEventLabel()
92 {
93 // show ros message type
94 std::string label;
96 return label;
97 }
98
99 static std::string getDefaultTransitionTag() { return demangledTypeName<CANCEL>(); }
100
101 static std::string getDefaultTransitionType() { return demangledTypeName<CANCEL>(); }
102};
103
104//-------------- SERVICE EVENTS --------------------------------------------------------
105template <typename TSource, typename TOrthogonal, typename TResponse>
106struct EvServiceResponse : sc::event<EvServiceResponse<TSource, TOrthogonal, TResponse>>
107{
108 TResponse response;
109
110 static std::string getEventLabel()
111 {
112 std::string label;
113 EventLabel<TSource>(label);
114 return label;
115 }
116
117 static std::string getDefaultTransitionTag() { return demangledTypeName<SUCCESS>(); }
118
119 static std::string getDefaultTransitionType() { return demangledTypeName<SUCCESS>(); }
120};
121
122template <typename TSource, typename TOrthogonal>
123struct EvServiceRequestSent : sc::event<EvServiceRequestSent<TSource, TOrthogonal>>
124{
125 static std::string getEventLabel()
126 {
127 std::string label;
128 EventLabel<TSource>(label);
129 return label;
130 }
131};
132
133template <typename TSource, typename TOrthogonal>
134struct EvServiceFailure : sc::event<EvServiceFailure<TSource, TOrthogonal>>
135{
136 static std::string getEventLabel()
137 {
138 std::string label;
139 EventLabel<TSource>(label);
140 return label;
141 }
142
143 static std::string getDefaultTransitionTag() { return demangledTypeName<ABORT>(); }
144
145 static std::string getDefaultTransitionType() { return demangledTypeName<ABORT>(); }
146};
147
148//---------- CONTROL FLOW EVENTS ----------------------------------------------------------
149
150template <typename StateType>
151struct EvStateRequestFinish : sc::event<EvStateRequestFinish<StateType>>
152{
153};
154
155template <typename StateType>
156struct EvSequenceFinished : sc::event<EvSequenceFinished<StateType>>
157{
158};
159
160template <typename TSource>
161struct EvLoopContinue : sc::event<EvLoopContinue<TSource>>
162{
164
166};
167
168template <typename TSource>
169struct EvLoopEnd : sc::event<EvLoopEnd<TSource>>
170{
171 static std::string getDefaultTransitionTag() { return demangledTypeName<ENDLOOP>(); }
172
173 static std::string getDefaultTransitionType() { return demangledTypeName<ENDLOOP>(); }
174};
175
176//---------- CONTROL FLOW EVENTS ----------------------------------------------------------
177template <
178 typename TSource, typename TOrthogonal, typename TMessageType = typename TSource::TMessageType>
179struct EvTopicInitialMessage : sc::event<EvTopicInitialMessage<TSource, TOrthogonal, TMessageType>>
180{
181 static std::string getEventLabel()
182 {
184
185 std::string label = typeinfo->getNonTemplatedTypeName();
186 return label;
187 }
188
189 TMessageType msgData;
190};
191
192template <
193 typename TSource, typename TOrthogonal, typename TMessageType = typename TSource::TMessageType>
194struct EvTopicMessage : sc::event<EvTopicMessage<TSource, TOrthogonal, TMessageType>>
195{
196 static std::string getEventLabel()
197 {
199
200 std::string label = typeinfo->getNonTemplatedTypeName();
201 return label;
202 }
203
204 TMessageType msgData;
205};
206} // namespace default_events
207} // namespace smacc2
static TypeInfo::Ptr getTypeInfoFromType()
std::enable_if< HasEventLabel< T >::value, void >::type EventLabel(std::string &label)
std::string demangledTypeName()
smacc2::client_bases::ISmaccActionClient * client