1414#include " Robots/RRBaseRobot.h"
1515#include " Robots/RRRobotROS2Interface.h"
1616
17+ void URRAIRobotROSControllerParam::SetParametersFromPawn (ARRAIRobotROSController* InController) const
18+ {
19+ if (!InController)
20+ {
21+ UE_LOG_WITH_INFO_NAMED (LogRapyutaCore, Error, TEXT (" FCoontroller is null" ));
22+ return ;
23+ }
24+ InController->bDebug = bDebug;
25+ InController->OrientationTolerance = OrientationTolerance;
26+ InController->LinearMotionTolerance = LinearMotionTolerance;
27+ InController->bTeleportOnFail = bTeleportOnFail;
28+ InController->Mode = Mode;
29+ InController->RandomMoveBoundingBox = RandomMoveBoundingBox;
30+ InController->GoalSequence = GoalSequence;
31+ InController->GoalSequenceActor = GoalSequenceActor;
32+ InController->OriginActor = OriginActor;
33+ InController->Origin = Origin;
34+
35+ // ROS related parameters
36+ InController->NavStatusPublicationFrequencyHz = NavStatusPublicationFrequencyHz;
37+ InController->SetSpeedTopicName = SetSpeedTopicName;
38+ InController->SetAngularVelTopicName = SetAngularVelTopicName;
39+ InController->SetModeTopicName = SetModeTopicName;
40+ InController->NavStatusTopicName = NavStatusTopicName;
41+ InController->PoseGoalTopicName = PoseGoalTopicName;
42+ InController->ActorGoalTopicName = ActorGoalTopicName;
43+
44+ BPSetParametersFromPawn (InController);
45+ }
46+
1747void ARRAIRobotROSController::OnPossess (APawn* InPawn)
1848{
1949 Super::OnPossess (InPawn);
2050
51+ // Get param from Pawn
52+ URRAIRobotROSControllerParam* param = InPawn->FindComponentByClass <URRAIRobotROSControllerParam>();
53+ if (param)
54+ {
55+ param->SetParametersFromPawn (this );
56+ }
57+
58+ InitParameters ();
59+
2160 /* *
2261 * @todo this won't work with client-server
2362 */
@@ -29,6 +68,26 @@ void ARRAIRobotROSController::OnUnPossess()
2968 Super::OnUnPossess ();
3069}
3170
71+ void ARRAIRobotROSController::InitParameters ()
72+ {
73+ if (OriginActor)
74+ {
75+ Origin = OriginActor->GetTransform ();
76+ }
77+
78+ // Transform to world transform
79+ for (int i = 0 ; i < GoalSequence.Num (); i++)
80+ {
81+ GoalSequence[i] = URRGeneralUtils::GetWorldTransform (Origin, GoalSequence[i], true );
82+ }
83+
84+ // Transform GoalSequenceActor to GoalSequence
85+ for (AActor* actor : GoalSequenceActor)
86+ {
87+ GoalSequence.Add (actor->GetTransform ());
88+ }
89+ }
90+
3291void ARRAIRobotROSController::InitROS2Interface ()
3392{
3493 InitPropertiesFromJSON ();
@@ -1096,7 +1155,8 @@ FTransform ARRAIRobotROSController::GetOrigin()
10961155{
10971156 if (OriginActor)
10981157 {
1099- return OriginActor->GetTransform ();
1158+ Origin = OriginActor->GetTransform ();
1159+ return Origin;
11001160 }
11011161 else
11021162 {
0 commit comments