19 #include "CoreMinimal.h"
25 #include "ROS2NodeComponent.h"
27 #include "ROS2ServiceClient.h"
47 #include "RRRobotROS2Interface.generated.h"
95 TObjectPtr<ARRBaseRobot> Robot =
nullptr;
125 virtual void Initialize(AActor* Owner)
override;
184 TObjectPtr<URRBaseOdomComponent> OdomComponent =
nullptr;
193 bool bPublishOdom =
true;
202 bool bPublishOdomTf =
false;
211 float OdomPublicationFrequencyHz = 30;
222 FString CmdVelTopicName = TEXT(
"cmd_vel");
251 virtual void JointCmdCallback(
const UROS2GenericMsg* Msg);
262 FString JointCmdTopicName = TEXT(
"ue_joint_commands");
281 void UpdateJointState(UROS2GenericMsg* InMessage);
292 TObjectPtr<UROS2Publisher> JointStatePublisher =
nullptr;
303 float JointStatePublicationFrequencyHz = 30.f;
314 FString JointStateTopicName = TEXT(
"ue_joint_states");
323 bool bWarnAboutMissingLink =
true;
332 TObjectPtr<URRROS2TFsPublisher> JointsTFPublisher =
nullptr;
341 bool bPublishJointTf =
false;
350 float JointTfPublicationFrequencyHz = 1.f;
361 TObjectPtr<URRROS2OdomPublisher> OdomPublisher =
nullptr;
402 virtual void MovementCallback(
const UROS2GenericMsg* Msg);
408 template<
typename TROS2Message,
410 typename TROS2MessageData,
414 typename TRobotMemFuncType = void (TRobot::*)(
const TROS2MessageData&)>
416 FORCEINLINE
void OnMessageReceived(
const TROS2Message* InMsg,
const TRobotMemFuncType& InMemFunc)
420 const auto* msg = Cast<TROS2Message>(InMsg);
426 TROS2MessageData msgData;
428 msg->GetMsg(msgData);
436 AsyncTask(ENamedThreads::GameThread,
438 [
this, InMemFunc, msgData]
442 auto* robot = Cast<TRobot>(Robot);
444 if (IsValid(Cast<UObject>(robot)))
448 ::Invoke(InMemFunc, robot, msgData);
460 template<
typename TROS2Message,
typename TROS2MessageData,
typename TRobot>
462 FORCEINLINE
void OnMessageReceivedFunc(
const TROS2Message* InMsg,
const TFunction<
void(
const TROS2MessageData&)>& InFunc)
470 TROS2MessageData msgData;
472 InMsg->GetMsg(msgData);
480 AsyncTask(ENamedThreads::GameThread,
482 [
this, InFunc, msgData]
486 auto* robot = Cast<TRobot>(Robot);
488 if (IsValid(Cast<UObject>(robot)))
504 template<
typename TService,
typename TServiceRequest>
512 if (
auto* client = ServiceClients.FindRef(InServiceName))
516 TService* service = CastChecked<TService>(client->Service);
518 client->SendRequest(service, InRequest);
522 UE_LOG_WITH_INFO(LogTemp, Warning, TEXT(
"%s [%s] Request made"), *InServiceName, *GetName());
530 UE_LOG_WITH_INFO(LogTemp, Error, TEXT(
"[MakeServiceRequest] [%s] srv client not found"), *InServiceName);
565 ROS2InterfaceClass = URRRobotROS2Interface::StaticClass();