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