RapyutaSimulationPlugins
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ARRNetworkPlayerController Class Reference

Network Player controller provides functionality for client-server. Major functionalites are. More...

#include <RRNetworkPlayerController.h>

Inheritance diagram for ARRNetworkPlayerController:
Inheritance graph
[legend]
Collaboration diagram for ARRNetworkPlayerController:
Collaboration graph
[legend]

Public Member Functions

 ARRNetworkPlayerController ()
 
virtual void Tick (float DeltaSeconds) override
 
void GetLifetimeReplicatedProps (TArray< FLifetimeProperty > &OutLifetimeProps) const override
 Returns the properties used for network replication, this needs to be overridden by all actor classes with native. More...
 
virtual void OnRep_SimStateClient ()
 Function called with #SimStateClient replication. Initialize ROS2SimStateClient. More...
 
void CreateROS2SimStateClient (const TSubclassOf< URRROS2SimulationStateClient > &InSimStateClientClass)
 Create ROS2SimStateClient without initializing yet. More...
 
void ClientInitSimStateClientROS2 ()
 Init SimStateClient ROS 2 Component, e.g. SimStateClientROS2Node, SimStateClientClockPublisher. More...
 
void ServerSetPlayerName (const FString &InPlayerName)
 Set player name in server. More...
 
virtual float GetLocalTime ()
 
void RequestServerTimeUpdate ()
 [Time Sync Step1] Request server time update from client via ServerRequestLocalClockUpdate More...
 
void ServerRequestLocalClockUpdate (float InClientRequestTime)
 [Time Sync Step2] Called from the client and execute in the server via RPC. More...
 
void ClientSendLocalClockUpdate (float InClientRequestTime, float InServerCurrentTime)
 [Time Sync Step3] Called from the server and execute in the client via RPC. More...
 
void UpdateLocalClock (float InDeltaSeconds)
 Increase local clock's time by delta seconds. More...
 
virtual void ServerSetLinearVel (ARRBaseRobot *InServerRobot, float InClientTimeStamp, const FTransform &InClientRobotTransform, const FVector &InLinearVel)
 Set server linear velocity to #RobotVehicleMoveComponent. Non player object can use this method to call RPC. More...
 
virtual void ServerSetAngularVel (ARRBaseRobot *InServerRobot, float InClientTimeStamp, const FRotator &InClientRobotRotation, const FVector &InAngularVel)
 Set server angular velocity to #RobotVehicleMoveComponent. Non player object can use this method to call RPC. More...
 

Public Attributes

UROS2NodeComponent * SimStateClientROS2Node = nullptr
 Sim ROS 2 node in each client. Created only in the client. More...
 
URRROS2ClockPublisherSimStateClientClockPublisher = nullptr
 /clock publisher More...
 
ASimulationStateServerSimState = nullptr
 Pointer to ServerSimState. ROS2SimStateClient in each client use this to execute sim-wide operation in the server. More...
 
URRROS2SimulationStateClientROS2SimStateClient = nullptr
 ROS 2 Sim state client. Provide ROS 2 interface of sim-wide operations implemented by ServerSimState. More...
 
FString PlayerName
 Controller's PlayerName. More...
 
FTimerHandle ClockRequestTimerHandle
 Timer handle used by RequestServerTime(). This will used to sync simulation time. More...
 
float LocalTime = 0.0f
 Local clock time. More...
 

Protected Member Functions

virtual void BeginPlay () override
 Standalone game mode will call this method to call #ClientInitSimStateClientROS2lient. More...
 
virtual void ReceivedPlayer () override
 

Detailed Description

Network Player controller provides functionality for client-server. Major functionalites are.

UCLASS()

Constructor & Destructor Documentation

◆ ARRNetworkPlayerController()

ARRNetworkPlayerController::ARRNetworkPlayerController ( )

Member Function Documentation

◆ BeginPlay()

virtual void ARRNetworkPlayerController::BeginPlay ( )
overrideprotectedvirtual

Standalone game mode will call this method to call #ClientInitSimStateClientROS2lient.

Client server game mode will start timer to sync time with server.

◆ ClientInitSimStateClientROS2()

void ARRNetworkPlayerController::ClientInitSimStateClientROS2 ( )

◆ ClientSendLocalClockUpdate()

void ARRNetworkPlayerController::ClientSendLocalClockUpdate ( float  InClientRequestTime,
float  InServerCurrentTime 
)

[Time Sync Step3] Called from the server and execute in the client via RPC.

Sync client time with InServerCurrentTime + delay compendation.

Delay is estimated as 0.5 * (current client time - InClientRequestTime)

Parameters
InClientRequestTimeClient time when client calls ServerRequestLocalClockUpdate
InServerCurrentTimeServer time when server call this method

UFUNCTION(Client, Reliable)

◆ CreateROS2SimStateClient()

void ARRNetworkPlayerController::CreateROS2SimStateClient ( const TSubclassOf< URRROS2SimulationStateClient > &  InSimStateClientClass)

Create ROS2SimStateClient without initializing yet.

Parameters
InSimStateClientClass

UFUNCTION(BlueprintCallable)

◆ GetLifetimeReplicatedProps()

void ARRNetworkPlayerController::GetLifetimeReplicatedProps ( TArray< FLifetimeProperty > &  OutLifetimeProps) const
override

Returns the properties used for network replication, this needs to be overridden by all actor classes with native.

replicated properties

Parameters
OutLifetimePropsOutput lifetime properties

◆ GetLocalTime()

virtual float ARRNetworkPlayerController::GetLocalTime ( )
inlinevirtual

◆ OnRep_SimStateClient()

virtual void ARRNetworkPlayerController::OnRep_SimStateClient ( )
virtual

Function called with #SimStateClient replication. Initialize ROS2SimStateClient.

UFUNCTION(BlueprintCallable)

◆ ReceivedPlayer()

virtual void ARRNetworkPlayerController::ReceivedPlayer ( )
overrideprotectedvirtual

◆ RequestServerTimeUpdate()

void ARRNetworkPlayerController::RequestServerTimeUpdate ( )

[Time Sync Step1] Request server time update from client via ServerRequestLocalClockUpdate

◆ ServerRequestLocalClockUpdate()

void ARRNetworkPlayerController::ServerRequestLocalClockUpdate ( float  InClientRequestTime)

[Time Sync Step2] Called from the client and execute in the server via RPC.

Get current server time and call ClientSendLocalClockUpdate with current server time and given InClientRequestTime

Parameters
InClientRequestTimeClient Time when client call this method.

UFUNCTION(Server, Reliable)

◆ ServerSetAngularVel()

virtual void ARRNetworkPlayerController::ServerSetAngularVel ( ARRBaseRobot InServerRobot,
float  InClientTimeStamp,
const FRotator &  InClientRobotRotation,
const FVector &  InAngularVel 
)
virtual

Set server angular velocity to #RobotVehicleMoveComponent. Non player object can use this method to call RPC.

Parameters
InServerRobottarget server-owned robot
InClientTimeStamp
InClientRobotRotation
InAngularVel
Note
This method is because RRBaseRobot can't use rpc since it is not controlled/possessed by the Player.

UFUNCTION(BlueprintCallable, Server, Reliable)

◆ ServerSetLinearVel()

virtual void ARRNetworkPlayerController::ServerSetLinearVel ( ARRBaseRobot InServerRobot,
float  InClientTimeStamp,
const FTransform &  InClientRobotTransform,
const FVector &  InLinearVel 
)
virtual

Set server linear velocity to #RobotVehicleMoveComponent. Non player object can use this method to call RPC.

Parameters
InServerRobottarget server-owned robot
InClientTimeStamp
InClientRobotPosition
InLinearVel
Note
This method is because RRBaseRobot can't use rpc since it is not controlled/possessed by the Player.

UFUNCTION(BlueprintCallable, Server, Reliable)

◆ ServerSetPlayerName()

void ARRNetworkPlayerController::ServerSetPlayerName ( const FString &  InPlayerName)

Set player name in server.

UFUNCTION(Server, Reliable)

◆ Tick()

virtual void ARRNetworkPlayerController::Tick ( float  DeltaSeconds)
overridevirtual

◆ UpdateLocalClock()

void ARRNetworkPlayerController::UpdateLocalClock ( float  InDeltaSeconds)

Increase local clock's time by delta seconds.

Parameters
InDeltaSeconds

Member Data Documentation

◆ ClockRequestTimerHandle

FTimerHandle ARRNetworkPlayerController::ClockRequestTimerHandle

Timer handle used by RequestServerTime(). This will used to sync simulation time.

UPROPERTY(VisibleAnywhere, BlueprintReadOnly)

◆ LocalTime

float ARRNetworkPlayerController::LocalTime = 0.0f

Local clock time.

UPROPERTY()

◆ PlayerName

FString ARRNetworkPlayerController::PlayerName

◆ ROS2SimStateClient

URRROS2SimulationStateClient* ARRNetworkPlayerController::ROS2SimStateClient = nullptr

ROS 2 Sim state client. Provide ROS 2 interface of sim-wide operations implemented by ServerSimState.

UPROPERTY(Transient, Replicated, ReplicatedUsing = OnRep_SimStateClient)

◆ ServerSimState

ASimulationState* ARRNetworkPlayerController::ServerSimState = nullptr

Pointer to ServerSimState. ROS2SimStateClient in each client use this to execute sim-wide operation in the server.

UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = "true"), Replicated)

◆ SimStateClientClockPublisher

URRROS2ClockPublisher* ARRNetworkPlayerController::SimStateClientClockPublisher = nullptr

/clock publisher

UPROPERTY(BlueprintReadOnly)

◆ SimStateClientROS2Node

UROS2NodeComponent* ARRNetworkPlayerController::SimStateClientROS2Node = nullptr

Sim ROS 2 node in each client. Created only in the client.

UPROPERTY(Transient)


The documentation for this class was generated from the following file: