Go to the documentation of this file.
19 #include "Components/StaticMeshComponent.h"
21 #include "Components/WidgetComponent.h"
23 #include "CoreMinimal.h"
29 #include "ROS2NodeComponent.h"
51 #include "RRBaseRobot.generated.h"
55 #define RR_VERIFY_DYNAMIC_ROBOT(InRobot) \
57 if (InRobot && (
false == InRobot->IsDynamicRuntimeRobot())) \
61 UE_LOG_WITH_INFO(LogTemp, \
65 TEXT(
"[ClassName:%s] is required to be NOT prefixed with [BP_] or [SKEL_BP] if this is purely a" \
67 "cpp-based robot class!"), \
69 *InRobot->GetClass()->GetName()); \
75 #define RR_VERIFY_STATIC_BP_ROBOT(InRobot) \
77 if (InRobot && (
false == InRobot->IsStaticBPRobot())) \
81 UE_LOG_WITH_INFO(LogTemp, \
85 TEXT(
"[ClassName:%s] is required to be prefixed with [BP_] if this is a blueprint robot class!"), \
87 *InRobot->GetClass()->GetName()); \
93 #define RR_VERIFY_DYNAMIC_OR_STATIC_BP_ROBOT(InRobot) \
191 ARRBaseRobot(
const FObjectInitializer& ObjectInitializer);
201 virtual void BeginPlay()
override;
215 virtual void Tick(
float DeltaSeconds)
override;
236 TObjectPtr<USceneComponent> DefaultRoot =
nullptr;
261 virtual void SetRootOffset(
const FTransform& InRootOffset);
277 return (
false == IsStaticBPRobot());
299 const FString className = GetClass()->GetName();
301 return className.StartsWith(TEXT(
"BP"))
303 || className.StartsWith(TEXT(
"SKEL_BP"));
350 TSubclassOf<URRRobotROS2Interface> ROS2InterfaceClass =
nullptr;
367 TObjectPtr<URRRobotROS2Interface> ROS2Interface =
nullptr;
382 virtual void OnRep_ROS2Interface();
397 bool bStartStopROS2Interface =
false;
412 virtual void OnRep_bStartStopROS2Interface();
426 bool IsAuthorizedInThisClient();
441 TObjectPtr<UROS2Spawnable> ROSSpawnParameters =
nullptr;
458 TObjectPtr<ARRBaseRobot> ServerRobot =
nullptr;
481 void CreateROS2Interface();
502 void InitROS2Interface();
511 bool InitROS2InterfaceImpl();
539 void DeInitROS2Interface();
570 RobotUniqueName = InRobotName;
572 EntityUniqueName = InRobotName;
602 RobotModelName = InName;
604 EntityModelName = InName;
606 if (ActorInfo.IsValid())
610 ActorInfo->EntityModelName = InName;
627 return RobotModelName;
643 return RobotModelName.StartsWith(TEXT(
"UE"), ESearchCase::IgnoreCase);
705 TMap<FString, UStaticMeshComponent*>
Links;
732 virtual bool AddLink(
const FString& InLinkName, UStaticMeshComponent* InMesh);
743 TObjectPtr<UMeshComponent> BaseMeshComp =
nullptr;
764 void SetBaseMeshComp(UMeshComponent* InBaseMeshComp,
bool bInMakeAsRoot =
true,
bool bInDestroyDefaultRoot =
true);
781 TMap<FString, URRJointComponent*>
Joints;
814 virtual bool AddJoint(
const FString& InParentLinkName,
816 const FString& InChildLinkName,
818 const FString& InJointName,
835 bool bInitializeJoints =
true;
844 virtual void StartJointsInitialization();
853 virtual void CheckJointsInitialization();
874 virtual void SetChildComponentsCollisionEnabled(
const bool IsEnable);
898 virtual bool InitSensors(UROS2NodeComponent* InROS2Node);
926 virtual bool ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags)
override;
940 virtual void SetJointState(
const TMap<FString, TArray<float>>& InJointState,
const ERRJointControlType InJointControlType);
972 FVector TargetLinearVel = FVector::ZeroVector;
983 FVector TargetAngularVel = FVector::ZeroVector;
998 virtual void StopMovement();
1011 TObjectPtr<UMovementComponent> MovementComponent =
nullptr;
1050 virtual void SetMoveComponent(UMovementComponent* InMoveComponent);
1073 virtual void SetLinearVel(
const FVector& InLinearVel);
1094 virtual void SetAngularVel(
const FVector& InAngularVel);
1119 virtual void SyncServerLinearMovement(
float InClientTimeStamp,
1121 const FTransform& InClientRobotTransform,
1123 const FVector& InLinearVel);
1148 virtual void SyncServerAngularMovement(
float InClientTimeStamp,
1150 const FRotator& InClientRobotRotation,
1152 const FVector& InAngularVel);
1171 virtual void SetLocalLinearVel(
const FVector& InLinearVel);
1190 virtual void SetLocalAngularVel(
const FVector& InAngularVel);
1201 FTransform RootOffset = FTransform::Identity;
1212 bool bInitRobotVehicleMoveComponent =
true;
1231 void BPConfigureMovementComponent();
1242 bool bMobileRobot =
true;
1253 bool bJointControl =
true;
1277 TObjectPtr<URRUIWidgetComponent> UIWidgetComp =
nullptr;
1288 FTransform UIWidgetOffset = FTransform(FVector(0.f, 0.f, 100.f));
1309 bool CheckUIUserWidget()
const;
1335 virtual void PostInitializeComponents()
override;
1353 virtual bool InitMoveComponent();
1372 void BPPreInitializeComponents();
1391 void BPPostInitializeComponents();
1526 virtual bool InitPropertiesFromJSON();
1545 void BPInitPropertiesFromJSON();
1557 virtual void ConfigureMovementComponent();
1567 virtual void InitUIWidget();
1582 bool bInitializingJoints =
false;
1616 bool res = InitPropertiesFromJSON();
1618 BPInitPropertiesFromJSON();
DECLARE_MULTICAST_DELEGATE_OneParam(FOnRobotCreationDone, bool)
TMap< FString, UStaticMeshComponent * > Links
Definition: RRBaseRobot.h:705
TObjectPtr< URobotVehicleMovementComponent > RobotVehicleMoveComponent
Movecomponent casted to URobotVehicleMovementComponent for utility.
Definition: RRBaseRobot.h:1028
ERRJointControlType
Definition: RRJointComponent.h:50
FORCEINLINE bool IsStaticBPRobot() const
Static BP robot: implemented in BP, possibly inheriting from #ARBaseRobot or its children classes,...
Definition: RRBaseRobot.h:293
FString RobotModelName
Robot Model Name (loaded from URDF/SDF)
Definition: RRBaseRobot.h:589
uint64 GetRobotID() const
Get robot ID.
Definition: RRBaseRobot.h:666
void SetRobotName(const FString &InRobotName)
Set robot unique name.
Definition: RRBaseRobot.h:566
virtual FString GetRobotModelName()
Definition: RRBaseRobot.h:623
virtual void SetRobotModelName(const FString InName)
Definition: RRBaseRobot.h:598
TSubclassOf< UMovementComponent > VehicleMoveComponentClass
Class of the main robot movement component, configurable in child class.
Definition: RRBaseRobot.h:1041
virtual bool InitPropertiesFromJSONAll()
Definition: RRBaseRobot.h:1612
TSubclassOf< UUserWidget > UIUserWidgetClass
Widget class.
Definition: RRBaseRobot.h:1299
Base actor class for all Rapyuta Sim actors:
Definition: RRBaseActor.h:70
BaseComponents which is used when spawning Actor from ROS 2 service in ASimulationState.
Base Robot ROS 2 interface class.
Definition: RRRobotROS2Interface.h:80
Network Player controller provides functionality for client-server. Major functionalites are.
Definition: RRNetworkPlayerController.h:66
FTimerHandle ROS2InitTimer
Definition: RRBaseRobot.h:520
Base Joints class. Other joint class should inherit from this class.
Definition: RRJointComponent.h:81
TMap< UPrimitiveComponent *, FName > OriginalCollisionProfiles
Children UPrimitives components orignal collision profiles.
Definition: RRBaseRobot.h:1603
TMap< FString, URRJointComponent * > Joints
Definition: RRBaseRobot.h:781
virtual void GetLifetimeReplicatedProps(TArray< FLifetimeProperty > &OutLifetimeProps) const override
Returns the properties used for network replication, this needs to be overridden by all actor classes...
@ CLIENT
UMETA(DisplayName = "Client", ToolTip = "robot moves in client first and use rpc to apply movement to...
Base ROS 2 Sensor Component class. Other sensors class should inherit from this class.
Network Game State for client-server.
Definition: RRNetworkGameState.h:40
ERRNetworkAuthorityType
Which server or client has robot movement authority.
Definition: RRBaseRobot.h:124
Base Robot vehicle movement class which is used as part of ARobotVehicle.
FORCEINLINE bool IsBuiltInRobotModel() const
Is static built robot model by the Editor.
Definition: RRBaseRobot.h:639
ERRResourceDataType
Sim resource(Uassets) data types.
Definition: RRObjectCommon.h:174
virtual void PreInitializeComponents() override
Set #GameMode #GameState #GameSingleton #PlayerController.
void SetRobotID(uint64 InRobotID)
Set robot ID.
Definition: RRBaseRobot.h:682
FORCEINLINE bool IsDynamicRuntimeRobot() const
DynamicRuntime robot: Implemented purely in cpp, built & loaded up at runtime from raw CAD + metadata...
Definition: RRBaseRobot.h:273
FOnRobotCreationDone OnRobotCreationDone
Robot creation done delegate.
Definition: RRBaseRobot.h:339
@ SERVER
UMETA(DisplayName = "Server", ToolTip = "robot moves in server first and movement replicates to clien...
Base actor class for all Rapyuta Sim actors.
uint8 bUIWidgetEnabled
Enable widget or not.
Definition: RRBaseRobot.h:1266
FString RobotUniqueName
Definition: RRBaseRobot.h:556
Base Robot class. Other robot class should inherit from this class.
Definition: RRBaseRobot.h:161