rclUE
ROS2Service.h
Go to the documentation of this file.
1 
15 // Class implementing ROS2 service clients
16 
17 // Service type is defined by SrvClass
18 
19 
20 
21 #pragma once
22 
23 
24 
25 // UE
26 
27 #include "Components/ActorComponent.h"
28 
29 #include "CoreMinimal.h"
30 
31 
32 
33 // rclUE
34 
35 #include "ROS2NodeComponent.h"
36 
37 #include "Srvs/ROS2GenericSrv.h"
38 
39 
40 
41 #include "ROS2Service.generated.h"
42 
43 
44 
45 DECLARE_LOG_CATEGORY_EXTERN(LogROS2Srv, Log, All);
46 
47 
48 
49 #define IS_SRV_INITED(InNode, InName, OutRes) \
50 
51  IS_ROS2NODE_INITED(InNode, InName, OutRes); \
52 
53  \
54 
55  if (State != UROS2State::Initialized) \
56 
57  { \
58 
59  UE_LOG_WITH_INFO( \
60 
61  LogROS2Srv, Warning, TEXT("[%s] Service Client/Server is not initialized yet. Please initialize Action."), *InName); \
62 
63  OutRes = false; \
64 
65  }
66 
67 
68 
84 class RCLUE_API UROS2Service : public UObject
85 
86 {
87 
88 
89 
90 public:
91 
106  virtual bool InitializeWithROS2(UROS2NodeComponent* InROS2Node);
107 
108 
109 
127  virtual bool Init();
128 
129 
130 
148  virtual bool InitializeService();
149 
150 
151 
165  virtual void Destroy();
166 
167 
168 
177  virtual void ProcessReady();
178 
179 
180 
182 
183 
188  FString ServiceName;
189 
190 
191 
193 
194 
199  TSubclassOf<UROS2GenericSrv> SrvClass;
200 
201 
202 
204 
205 
211 
212 
213 
215 
216 
221  TEnumAsByte<UROS2State> State = UROS2State::Created;
222 
223 
224 
226 
227 
233 
234 
235 
237 
239 
240 
246 
247 
248 
249 protected:
250 
252 
253  bool Ready;
254 
255 
256 
270  virtual void InitializeServiceComponent();
271 
272 };
273 
UROS2Service::Service
UROS2GenericSrv * Service
Service Instance.
Definition: ROS2Service.h:232
UROS2Service
Class implementing ROS2 service clients.
Definition: ROS2Service.h:84
UROS2QoS::Services
@ Services
UMETA(DisplayName = "Parameters"),.
ROS2GenericSrv.h
This should be refactored with other generic ROS2 types (Msgs, Sensors, Actions).
IS_ROS2NODE_INITED
#define IS_ROS2NODE_INITED(InNode, InName, OutRes)
Check UROS2NodeComponent is initialized or not.
Definition: ROS2NodeComponent.h:731
UROS2QoS
UROS2QoS
used to set QoS policies
Definition: rclcUtilities.h:177
UROS2GenericSrv
This should be refactored with other generic ROS2 types (Msgs, Sensors, Actions).
Definition: ROS2GenericSrv.h:50
UROS2Service::SrvClass
TSubclassOf< UROS2GenericSrv > SrvClass
type of Srv class
Definition: ROS2Service.h:199
UROS2NodeComponent
Class implementing ROS2 node.
Definition: ROS2NodeComponent.h:782
UROS2Service::OwnerNode
UROS2NodeComponent * OwnerNode
ROS2Node which own this service client.
Definition: ROS2Service.h:210
UROS2Service::Ready
bool Ready
Service is ready or not.
Definition: ROS2Service.h:253
Initialized
@ Initialized
UMETA(DisplayName = "Created"),.
Definition: rclcUtilities.h:158
ROS2NodeComponent.h
Class implementing ROS2 node.