RapyutaSimulationPlugins
RRROS2SimulationStateClient.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 
18 
19 // UE
20 
21 #include "Components/ActorComponent.h"
22 
23 #include "CoreMinimal.h"
24 
25 
26 
27 // rclUE
28 
29 #include "ROS2NodeComponent.h"
30 
31 #include "Srvs/ROS2Attach.h"
32 
33 #include "Srvs/ROS2DeleteEntity.h"
34 
35 #include "Srvs/ROS2GetEntityState.h"
36 
37 #include "Srvs/ROS2SetEntityState.h"
38 
39 #include "Srvs/ROS2SpawnEntities.h"
40 
41 #include "Srvs/ROS2SpawnEntity.h"
42 
43 
44 
45 // RapyutaSimulationPlugins
46 
47 #include "Core/RRConversionUtils.h"
48 
49 #include "Core/RRGeneralUtils.h"
50 
51 
52 
53 #include "RRROS2SimulationStateClient.generated.h"
54 
55 
56 
57 class UROS2GenericSrv;
58 
59 class ASimulationState;
60 
61 
62 
78 class RAPYUTASIMULATIONPLUGINS_API URRROS2SimulationStateClient : public UActorComponent
79 
80 {
81 
82 
83 
84 public:
85 
87 
88 
93  UROS2NodeComponent* ROS2Node = nullptr;
94 
95 
96 
98 
99 
104  ASimulationState* ServerSimState = nullptr;
105 
106 
107 
125  virtual void Init(UROS2NodeComponent* InROS2Node);
126 
127 
128 
129  virtual bool IsSupportedForNetworking() const override
130 
131  {
132 
133  return true;
134 
135  }
136 
137 
138 
151  virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
152 
153 
154 
174  void GetEntityStateSrv(UROS2GenericSrv* InService);
175 
176 
177 
195  void SetEntityStateSrv(UROS2GenericSrv* InService);
196 
197 
198 
212  void ServerSetEntityState(const FROSSetEntityStateReq& InRequest);
213 
214 
215 
233  void AttachSrv(UROS2GenericSrv* InService);
234 
235 
236 
250  void ServerAttach(const FROSAttachReq& InRequest);
251 
252 
253 
269  virtual void SpawnEntitySrv(UROS2GenericSrv* InService);
270 
271 
272 
288  virtual void SpawnEntitiesSrv(UROS2GenericSrv* InService);
289 
290 
291 
305  void ServerSpawnEntity(const FROSSpawnEntityReq& InRequest);
306 
307 
308 
324  void DeleteEntitySrv(UROS2GenericSrv* InService);
325 
326 
327 
341  void ServerDeleteEntity(const FROSDeleteEntityReq& InRequest);
342 
343 
344 
358  void ServerAddEntity(AActor* InEntity);
359 
360 
361 
375  void SetNetworkPlayerId(const int32 InNetworkPlayerId)
376 
377  {
378 
379  NetworkPlayerId = InNetworkPlayerId;
380 
381  }
382 
383 
384 
398  int32 GetNetworkPlayerId() const
399 
400  {
401 
402  return NetworkPlayerId;
403 
404  }
405 
406 
407 
408 protected:
409 
410  virtual void OnComponentCreated() override;
411 
412 
413 
415 
416 
422 
423 
424 
425  template<typename T>
426 
427  bool CheckEntity(TMap<FString, T>& InEntities, const FString& InEntityName, const bool bAllowEmpty = false);
428 
429  bool CheckEntity(const FString& InEntityName, const bool bAllowEmpty = false);
430 
431  bool CheckSpawnableEntity(const FString& InEntityName, const bool bAllowEmpty = false);
432 
433  virtual FROSSpawnEntityRes SpawnEntityImpl(FROSSpawnEntityReq& InRequest);
434 
435 };
436 
URRROS2SimulationStateClient::IsSupportedForNetworking
virtual bool IsSupportedForNetworking() const override
Definition: RRROS2SimulationStateClient.h:129
ASimulationState
Provide ROS 2 interface implementations to interact with UE4.
Definition: SimulationState.h:173
URRROS2SimulationStateClient::NetworkPlayerId
int32 NetworkPlayerId
NetworkPlayerId which is used to differenciate client in server.
Definition: RRROS2SimulationStateClient.h:421
RRGeneralUtils.h
General utils.
RRConversionUtils.h
Convertions between ROS and UE, i.e.
URRROS2SimulationStateClient
Provide ROS 2 interfaces to interact with UE4. This provide only ROS 2 interfaces and implementation ...
Definition: RRROS2SimulationStateClient.h:78
URRROS2SimulationStateClient::GetNetworkPlayerId
int32 GetNetworkPlayerId() const
Get Player Id.
Definition: RRROS2SimulationStateClient.h:398
URRROS2SimulationStateClient::SetNetworkPlayerId
void SetNetworkPlayerId(const int32 InNetworkPlayerId)
Set Player Id.
Definition: RRROS2SimulationStateClient.h:375