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//---------- CONTROL FLOW EVENTS ----------------------------------------------------------
108
109template <typename StateType>
110struct EvStateRequestFinish : sc::event<EvStateRequestFinish<StateType>>
111{
112};
113
114template <typename StateType>
115struct EvSequenceFinished : sc::event<EvSequenceFinished<StateType>>
116{
117};
118
119template <typename TSource>
120struct EvLoopContinue : sc::event<EvLoopContinue<TSource>>
121{
123
125};
126
127template <typename TSource>
128struct EvLoopEnd : sc::event<EvLoopEnd<TSource>>
129{
130 static std::string getDefaultTransitionTag() { return demangledTypeName<ENDLOOP>(); }
131
132 static std::string getDefaultTransitionType() { return demangledTypeName<ENDLOOP>(); }
133};
134
135//---------- CONTROL FLOW EVENTS ----------------------------------------------------------
136template <
137 typename TSource, typename TOrthogonal, typename TMessageType = typename TSource::TMessageType>
138struct EvTopicInitialMessage : sc::event<EvTopicInitialMessage<TSource, TOrthogonal, TMessageType>>
139{
140 // typename EvTopicInitialMessage<SensorBehaviorType>::TMessageType msgData;
141 static std::string getEventLabel()
142 {
143 auto typeinfo = TypeInfo::getTypeInfoFromType<TMessageType>();
144
145 std::string label = typeinfo->getNonTemplatedTypeName();
146 return label;
147 }
148
149 TMessageType msgData;
150};
151
152template <
153 typename TSource, typename TOrthogonal, typename TMessageType = typename TSource::TMessageType>
154struct EvTopicMessage : sc::event<EvTopicMessage<TSource, TOrthogonal, TMessageType>>
155{
156 static std::string getEventLabel()
157 {
158 auto typeinfo = TypeInfo::getTypeInfoFromType<TMessageType>();
159
160 std::string label = typeinfo->getNonTemplatedTypeName();
161 return label;
162 }
163
164 TMessageType msgData;
165};
166} // namespace default_events
167} // namespace smacc2
smacc2::client_bases::ISmaccActionClient * client