-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move components duplication refactored for RobotVehicle class and AMRVehicle class * Add StatePublisher class * Add InversionFactor variable in RobotVehicleMovementComponent Co-authored-by: duc <[email protected]>
- Loading branch information
1 parent
acdb584
commit abf5f5c
Showing
10 changed files
with
302 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Source/RapyutaSimulationPlugins/Private/Tools/StatePublisher.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2020-2021 Rapyuta Robotics Co., Ltd. | ||
|
||
#include "Tools/StatePublisher.h" | ||
|
||
// rclUE | ||
#include "ROS2Node.h" | ||
|
||
// RapyutaSimulationPlugins | ||
#include "Tools/SimulationState.h" | ||
|
||
void UStatePublisher::RegisterPublisher(AROS2Node* Node) | ||
{ | ||
for (auto i = 0; i < StatesToPublish.Num(); i++) | ||
{ | ||
Node->AddPublisher(this); | ||
} | ||
} | ||
|
||
void UStatePublisher::PublishState(UROS2GenericMsg* Msg) | ||
{ | ||
UROS2EntityStateMsg* StateMsg = Cast<UROS2EntityStateMsg>(Msg); | ||
if ((StateMsg != nullptr) && StatesToPublish.IsValidIndex(Idx)) | ||
{ | ||
StateMsg->SetMsg(StatesToPublish[Idx]); | ||
Idx = (Idx + 1 == StatesToPublish.Num()) ? 0 : Idx + 1; // ue4 does not seem to have a modulo operator for integers | ||
// (it does have one for floats: FGenericPlatformMath::FMod) | ||
check(Idx < StatesToPublish.Num()); | ||
} | ||
} | ||
|
||
void UStatePublisher::Bind() | ||
{ | ||
UpdateDelegate.BindDynamic(this, &UStatePublisher::PublishState); | ||
} | ||
|
||
void UStatePublisher::AddEntityToPublish(const FString& InName, | ||
const FVector& InPosition, | ||
const FRotator& InOrientation, | ||
const FString& InRefFrame) | ||
{ | ||
FROSEntityState BodyState; | ||
BodyState.name = InName; | ||
BodyState.pose_position_x = InPosition.X; | ||
BodyState.pose_position_y = -InPosition.Y; | ||
BodyState.pose_position_z = InPosition.Z; | ||
BodyState.pose_orientation = InOrientation.Quaternion(); | ||
BodyState.pose_orientation.X = -BodyState.pose_orientation.X; | ||
BodyState.pose_orientation.Z = -BodyState.pose_orientation.Z; | ||
BodyState.reference_frame = InRefFrame; | ||
StatesToPublish.Add(BodyState); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.