RapyutaSimulationPlugins
RRBaseROS2Interface.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 
16 
17 // UE
18 
19 #include "CoreMinimal.h"
20 
21 
22 
23 // rclUE
24 
25 #include "ROS2NodeComponent.h"
26 
27 #include "ROS2ServiceClient.h"
28 
29 #include "Tools/ROS2Spawnable.h"
30 
32 
34 
35 
36 
37 // RapyutaSimulationPlugins
38 
39 #include "Core/RRUObjectUtils.h"
40 
42 
43 
44 
45 #include "RRBaseROS2Interface.generated.h"
46 
47 
48 
49 class ARRBaseRobot;
50 
80 class RAPYUTASIMULATIONPLUGINS_API URRBaseROS2Interface : public UObject
81 
82 {
83 
84 
85 
86 #define RR_ROBOT_ROS2_SUBSCRIBE_TO_TOPIC(InTopicName, InMsgClass, InCallback) \
87 
88  ROS2_CREATE_SUBSCRIBER(RobotROS2Node, this, InTopicName, InMsgClass, InCallback)
89 
90 
91 
92 public:
93 
94  virtual bool IsSupportedForNetworking() const override
95 
96  {
97 
98  return true;
99 
100  }
101 
102 
103 
116  void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
117 
118 
119 
121 
123 
124 
129  TObjectPtr<UROS2NodeComponent> RobotROS2Node = nullptr;
130 
131 
132 
134 
135 
140  TObjectPtr<UROS2Spawnable> ROSSpawnParameters = nullptr;
141 
142 
143 
145 
147 
148 
153  FString DefautlROSNamespace = TEXT("");
154 
155 
156 
172  virtual void Initialize(AActor* Owner);
173 
174 
175 
184  virtual void InitInterfaces();
185 
186 
187 
201  void BPInitialize();
202 
203 
204 
215  virtual void DeInitialize();
216 
217 
218 
229  virtual void InitRobotROS2Node(AActor* Owner);
230 
231 
232 
243  virtual void InitROS2NodeParam(AActor* Owner);
244 
245 
246 
258  virtual void SetupROSParams(){};
259 
260 
261 
273  void BPSetupROSParams();
274 
275 
276 
289 
290  {
291 
292  SetupROSParams();
293 
294  BPSetupROSParams();
295 
296  }
297 
298 
299 
301 
303 
304 
309  TMap<FString, UROS2Publisher*> Publishers;
310 
311 
312 
314 
316 
317 
322  TMap<FString, UROS2Subscriber*> Subscribers;
323 
324 
325 
327 
329 
330 
335  TMap<FString, UROS2ServiceClient*> ServiceClients;
336 
337 
338 
340 
342 
343 
348  TMap<FString, UROS2ServiceServer*> ServiceServers;
349 
350 
351 
353 
355 
356 
361  TMap<FString, UROS2ActionClient*> ActionClients;
362 
363 
364 
366 
368 
369 
374  TMap<FString, UROS2ActionServer*> ActionServers;
375 
376 
377 
391  virtual bool InitPublishers();
392 
393 
394 
408  virtual void StopPublishers();
409 
410 
411 
425  virtual bool InitSubscriptions();
426 
427 
428 
442  virtual bool InitServiceClients();
443 
444 
445 
459  virtual bool InitServiceServers();
460 
461 
462 
476  virtual bool InitActionClients();
477 
478 
479 
493  virtual bool InitActionServers();
494 
495 };
496 
497 
498 
514 class RAPYUTASIMULATIONPLUGINS_API URRBaseROS2InterfaceComponent : public UActorComponent
515 
516 {
517 
518 public:
519 
520  virtual void BeginPlay() override;
521 
522 
523 
524 
529  TObjectPtr<URRBaseROS2Interface> ROS2Interface = nullptr;
530 
531 
532 
533 
538  TSubclassOf<URRBaseROS2Interface> ROS2InterfaceClass = URRBaseROS2Interface::StaticClass();
539 
540 
541 
543 
545 
546 
551  void AddAllSubComponentToROSInterface();
552 
553 };
554 
URRBaseROS2Interface::ActionClients
TMap< FString, UROS2ActionClient * > ActionClients
You can add your publishers here to ask ROS2Interface to manage.
Definition: RRBaseROS2Interface.h:361
URRBaseROS2Interface::SetupROSParamsAll
void SetupROSParamsAll()
Call SetupROSParams and BPSetupROSParams.
Definition: RRBaseROS2Interface.h:288
URRBaseROS2InterfaceComponent
Wrapper class of URRBaseROS2Interfaceas component.
Definition: RRBaseROS2Interface.h:514
URRBaseROS2Interface
Base Robot ROS 2 interface class.
Definition: RRBaseROS2Interface.h:80
RRROS2OdomPublisher.h
Odometry Topic and TF publisher of ARRBaseRobot.
ROS2Spawnable.h
BaseComponents which is used when spawning Actor from ROS 2 service in ASimulationState.
RRUObjectUtils.h
UObject general utils.
URRBaseROS2Interface::ActionServers
TMap< FString, UROS2ActionServer * > ActionServers
You can add your publishers here to ask ROS2Interface to manage.
Definition: RRBaseROS2Interface.h:374
URRBaseROS2Interface::Publishers
TMap< FString, UROS2Publisher * > Publishers
You can add your publishers here to ask ROS2Interface to manage.
Definition: RRBaseROS2Interface.h:309
URRBaseROS2Interface::ServiceServers
TMap< FString, UROS2ServiceServer * > ServiceServers
You can add your publishers here to ask ROS2Interface to manage.
Definition: RRBaseROS2Interface.h:348
RRBaseOdomComponent.h
Base Odom Component which provides actor pose changes.
URRBaseROS2Interface::Subscribers
TMap< FString, UROS2Subscriber * > Subscribers
You can add your subscribers here to ask ROS2Interface to manage.
Definition: RRBaseROS2Interface.h:322
URRBaseROS2Interface::ServiceClients
TMap< FString, UROS2ServiceClient * > ServiceClients
You can add your publishers here to ask ROS2Interface to manage.
Definition: RRBaseROS2Interface.h:335
URRBaseROS2Interface::SetupROSParams
virtual void SetupROSParams()
Setup ROS Params, overridable by child classes to config custom ROS 2 Interface's params.
Definition: RRBaseROS2Interface.h:258
RRROS2TFPublisher.h
TF publisher class.
URRBaseROS2Interface::IsSupportedForNetworking
virtual bool IsSupportedForNetworking() const override
Definition: RRBaseROS2Interface.h:94
ARRBaseRobot
Base Robot class. Other robot class should inherit from this class.
Definition: RRBaseRobot.h:161