rclUE
ROS2Topic.h
Go to the documentation of this file.
1 
17 #pragma once
18 
19 
20 
21 #include <Components/ActorComponent.h>
22 
23 #include <CoreMinimal.h>
24 
25 
26 
27 // rclUE
28 
29 #include "Msgs/ROS2GenericMsg.h"
30 
31 #include "ROS2NodeComponent.h"
32 
33 #include "rclcUtilities.h"
34 
35 
36 
37 #include "ROS2Topic.generated.h"
38 
39 
40 
41 DECLARE_LOG_CATEGORY_EXTERN(LogROS2Topic, Log, All);
42 
43 
44 
57 #define IS_TOPIC_INITED(InNode, InName, OutRes) \
58 
59  IS_ROS2NODE_INITED(InNode, InName, OutRes); \
60 
61  if (State != UROS2State::Initialized) \
62 
63  { \
64 
65  UE_LOG_WITH_INFO( \
66 
67  LogROS2Topic, Warning, TEXT("[%s] Publisher/Subscriber is not initialized yet. Please initialize Action."), *InName); \
68 
69  OutRes = false; \
70 
71  }
72 
73 
74 
88 class RCLUE_API UROS2Topic : public UObject
89 
90 {
91 
92 
93 
94 public:
95 
106  virtual bool InitializeWithROS2(UROS2NodeComponent* InROS2Node);
107 
108 
109 
127  virtual bool Init();
128 
129 
130 
144  virtual bool InitializeMessage();
145 
146 
147 
161  virtual void Destroy();
162 
163 
164 
166 
167 
172  FString TopicName;
173 
174 
175 
177 
178 
183  TSubclassOf<UROS2GenericMsg> MsgClass;
184 
185 
186 
188 
189 
194  UROS2NodeComponent* OwnerNode = nullptr;
195 
196 
197 
199 
200 
205  TEnumAsByte<UROS2State> State = UROS2State::Created;
206 
207 
208 
210 
212 
213 
218  UROS2QoS QoS = UROS2QoS::Default;
219 
220 
221 
266  TOptional<rmw_qos_profile_t> QoSProfile;
267 
268 
269 
271 
272 
278 
279 
280 
281 protected:
282 
295  rmw_qos_profile_t GetEffectiveQoS() const
296 
297  {
298 
299  if (QoSProfile.IsSet())
300 
301  {
302 
303  return QoSProfile.GetValue();
304 
305  }
306 
307  return QoS_LUT[QoS];
308 
309  }
310 
311 
312 
326  virtual void InitializeTopicComponent();
327 
328 };
329 
IS_ROS2NODE_INITED
#define IS_ROS2NODE_INITED(InNode, InName, OutRes)
Check UROS2NodeComponent is initialized or not.
Definition: ROS2NodeComponent.h:731
UROS2Topic::QoSProfile
TOptional< rmw_qos_profile_t > QoSProfile
Optional custom QoS profile.
Definition: ROS2Topic.h:266
UROS2QoS
UROS2QoS
used to set QoS policies
Definition: rclcUtilities.h:177
UROS2Topic::GetEffectiveQoS
rmw_qos_profile_t GetEffectiveQoS() const
Get the effective QoS profile to use for this topic.
Definition: ROS2Topic.h:295
UROS2Topic::MsgClass
TSubclassOf< UROS2GenericMsg > MsgClass
this information is redundant with Topic, but it's needed to initialize it
Definition: ROS2Topic.h:183
rclcUtilities.h
Header containing utilities and includes that are needed/useful in almost any class in rclUE.
QoS_LUT
static const TMap< UROS2QoS, rmw_qos_profile_t > QoS_LUT
Look-Up Table matching enum with rcl profiles.
Definition: rclcUtilities.h:319
UROS2Topic::TopicMessage
UROS2GenericMsg * TopicMessage
Message Instance.
Definition: ROS2Topic.h:277
UROS2NodeComponent
Class implementing ROS2 node.
Definition: ROS2NodeComponent.h:782
UROS2Topic
ROS2 topic class. Parent class of UROS2Publisher and UROS2Subscriber.
Definition: ROS2Topic.h:88
ROS2GenericMsg.h
This should be refactored with other generic ROS2 types (Msgs, Sensors, Actions).
Initialized
@ Initialized
UMETA(DisplayName = "Created"),.
Definition: rclcUtilities.h:158
UROS2GenericMsg
This should be refactored with other generic ROS2 types (Msgs, Sensors, Actions).
Definition: ROS2GenericMsg.h:46
ROS2NodeComponent.h
Class implementing ROS2 node.