RapyutaSimulationPlugins
RRNetworkPlayerController.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 
14 
15 // UE
16 
17 #include "GameFramework/Pawn.h"
18 
19 #include "GameFramework/PlayerController.h"
20 
21 #include "UnrealClient.h"
22 
23 
24 
25 // rclUE
26 
27 #include "ROS2NodeComponent.h"
28 
29 
30 
31 // RapyutaSimulationPlugins
32 
33 #include "Core/RRActorCommon.h"
34 
35 #include "Robots/RRBaseRobot.h"
36 
38 
40 
41 #include "Tools/SimulationState.h"
42 
43 
44 
45 #include "RRNetworkPlayerController.generated.h"
46 
47 
48 
66 class RAPYUTASIMULATIONPLUGINS_API ARRNetworkPlayerController : public APlayerController
67 
68 {
69 
70 public:
71 
73 
74 
75 
76  virtual void Tick(float DeltaSeconds) override;
77 
78 
79 
92  void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
93 
94 
95 
97 
98 
103  UROS2NodeComponent* SimStateClientROS2Node = nullptr;
104 
105 
106 
108 
109 
114  URRROS2ClockPublisher* SimStateClientClockPublisher = nullptr;
115 
116 
117 
118  // SIM STATE & ROS 2 STATE CLIENT
119 
121 
122 
127  ASimulationState* ServerSimState = nullptr;
128 
129 
130 
132 
133 
138  URRROS2SimulationStateClient* ROS2SimStateClient = nullptr;
139 
140 
141 
153  virtual void OnRep_SimStateClient();
154 
155 
156 
157  // PLAYER
158 
160 
161 
166  FString PlayerName;
167 
168 
169 
185  void CreateROS2SimStateClient(const TSubclassOf<URRROS2SimulationStateClient>& InSimStateClientClass);
186 
187 
188 
200  void ClientInitSimStateClientROS2();
201 
202 
203 
215  void ServerSetPlayerName(const FString& InPlayerName);
216 
217 
218 
219  // LOCAL CLOCK
220 
222 
223 
229 
230 
231 
233 
234 
239  float LocalTime = 0.0f;
240 
241  virtual float GetLocalTime()
242 
243  {
244 
245  return LocalTime;
246 
247  }
248 
249 
250 
257  void RequestServerTimeUpdate();
258 
259 
260 
278  void ServerRequestLocalClockUpdate(float InClientRequestTime);
279 
280 
281 
303  void ClientSendLocalClockUpdate(float InClientRequestTime, float InServerCurrentTime);
304 
305 
306 
315  void UpdateLocalClock(float InDeltaSeconds);
316 
317 
318 
340  virtual void ServerSetLinearVel(ARRBaseRobot* InServerRobot,
341 
342  float InClientTimeStamp,
343 
344  const FTransform& InClientRobotTransform,
345 
346  const FVector& InLinearVel);
347 
348 
349 
371  virtual void ServerSetAngularVel(ARRBaseRobot* InServerRobot,
372 
373  float InClientTimeStamp,
374 
375  const FRotator& InClientRobotRotation,
376 
377  const FVector& InAngularVel);
378 
379 
380 
381 protected:
382 
393  virtual void BeginPlay() override;
394 
395  virtual void ReceivedPlayer() override;
396 
397 };
398 
ASimulationState
Provide ROS 2 interface implementations to interact with UE4.
Definition: SimulationState.h:173
RRBaseRobot.h
Base Robot class. Other robot class can inherit from this class.
URRROS2ClockPublisher
Clock publisher class. Get elapsed time by UGameplayStatics.
Definition: RRROS2ClockPublisher.h:48
RRROS2ClockPublisher.h
Clock publisher class. Get elapsed time by UGameplayStatics::GetTimeSeconds
SimulationState.h
SimulationState class provides ROS 2 interface implementation to interact with UE4.
ARRNetworkPlayerController
Network Player controller provides functionality for client-server. Major functionalites are.
Definition: RRNetworkPlayerController.h:66
ARRNetworkPlayerController::PlayerName
FString PlayerName
Controller's PlayerName.
Definition: RRNetworkPlayerController.h:166
RRROS2SimulationStateClient.h
RRROS2SimulationStateClient class provides ROS 2 service interfaces to interact with UE4.
ARRNetworkPlayerController::ClockRequestTimerHandle
FTimerHandle ClockRequestTimerHandle
Timer handle used by RequestServerTime(). This will used to sync simulation time.
Definition: RRNetworkPlayerController.h:228
ARRNetworkPlayerController::GetLocalTime
virtual float GetLocalTime()
Definition: RRNetworkPlayerController.h:241
RRActorCommon.h
Asset utils.
URRROS2SimulationStateClient
Provide ROS 2 interfaces to interact with UE4. This provide only ROS 2 interfaces and implementation ...
Definition: RRROS2SimulationStateClient.h:78
ARRBaseRobot
Base Robot class. Other robot class should inherit from this class.
Definition: RRBaseRobot.h:161