Go to the documentation of this file.
21 #include <Components/ActorComponent.h>
23 #include <CoreMinimal.h>
37 #include "ROS2Publisher.generated.h"
83 static UROS2Publisher* CreateLoopPublisherWithClass(UObject* InOwner,
85 const FString& InTopicName,
87 const TSubclassOf<UROS2Publisher>& InPublisherClass,
89 const float InPubFrequency);
124 const FString& InTopicName,
126 const TSubclassOf<UROS2Publisher>& InPublisherClass,
128 const TSubclassOf<UROS2GenericMsg>& InMsgClass,
130 float InPubFrequency,
132 const FTopicCallback& InUpdateDelegate,
134 const UROS2QoS InQoS = UROS2QoS::Default);
159 const TSubclassOf<UROS2Publisher>& InPublisherClass,
161 const FString& InTopicName = TEXT(
""));
194 const FString& InTopicName,
196 const TSubclassOf<UROS2Publisher>& InPublisherClass,
198 const TSubclassOf<UROS2GenericMsg>& InMsgClass,
200 float InPubFrequency,
202 const UROS2QoS InQoS = UROS2QoS::Default);
219 void UpdateAndPublish();
252 template<
typename TUEMessage,
typename TUEStruct>
268 CastChecked<TUEMessage>(TopicMessage)->SetMsg(InMessageData);
315 void StopPublishTimer();
332 void StartPublishTimer();
343 float PublicationFrequencyHz = 1.f;
396 void SetDefaultDelegates();
415 void SetDelegates(
const FTopicCallback& InUpdateDelegate);
434 const void* PublishedMsg =
nullptr;
506 FString TopicName = TEXT(
"");
517 TSubclassOf<UROS2Publisher> PublisherClass = UROS2Publisher::StaticClass();
528 TSubclassOf<UROS2GenericMsg> MsgClass = UROS2GenericMsg::StaticClass();
539 float PublicationFrequencyHz = 1.f;
565 virtual void BeginPlay()
override
569 if (Publisher ==
nullptr)
575 this, TopicName, PublisherClass, MsgClass, PublicationFrequencyHz, UpdateDelegate, QoS);
583 UE_LOG_WITH_INFO(LogTemp, Warning, TEXT(
"Publisher is not created in BeginPlay."));
608 if (Publisher !=
nullptr)
616 Publisher->
QoS = QoS;
653 virtual void BeginPlay()
override
657 if (Publisher ==
nullptr)
669 UE_LOG_WITH_INFO(LogTemp, Warning, TEXT(
"Publisher class is not created in BeginPlay."));
673 UActorComponent::BeginPlay();
FTopicCallback UpdateDelegate
Delegate which is Bound with UpdateMessage by SetDefaultDelegates.
Definition: ROS2Publisher.h:354
Custom timer manager. This try to execute delegate at a given fixed rate.
Definition: rclcUtilities.h:356
FTopicCallback UpdateDelegate
this is pass to UROS2Publisher::UpdateDelegate in #BeginPlay
Definition: ROS2Publisher.h:561
virtual void UpdateMessage(UROS2GenericMsg *InMessage)
Update msg. Should be implemented in child class.
Definition: ROS2Publisher.h:373
ROS2 Publisher class.
Definition: ROS2Publisher.h:54
virtual void SetParams()
Pass this class's parameter TopicName, PublicationFrequencyHz, QoS to Publisher.
Definition: ROS2Publisher.h:604
#define UE_LOG_WITH_INFO(CategoryName, Verbosity,...)
Definition: logUtilities.h:83
FString TopicName
this information is redundant with Topic, but it's needed to initialize it
Definition: ROS2Topic.h:170
virtual void Destroy()
Destroy topic and TopicMessage.
UROS2QoS
used to set QoS policies
Definition: rclcUtilities.h:177
UROS2QoS QoS
Quality of service.
Definition: ROS2Topic.h:216
void Publish(const TUEStruct &InMessageData)
Publish a message.
Definition: ROS2Publisher.h:254
static UROS2Publisher * CreateLoopPublisherWithClass(UObject *InOwner, const FString &InTopicName, const TSubclassOf< UROS2Publisher > &InPublisherClass, const float InPubFrequency)
Create a new UROS2Publisher of custom publisher class and andd to Node.
static UROS2Publisher * CreateLoopPublisher(UObject *InOwner, const FString &InTopicName, const TSubclassOf< UROS2Publisher > &InPublisherClass, const TSubclassOf< UROS2GenericMsg > &InMsgClass, float InPubFrequency, const FTopicCallback &InUpdateDelegate, const UROS2QoS InQoS=UROS2QoS::Default)
Create a Loop Publisher object.
virtual void InitializeTopicComponent()
Initialize ROS2 Topic. Should be implemented in UROS2Publisher and UROS2Subscriber.
Class implementing ROS2 topic.
ROS2 topic class. Parent class of UROS2Publisher and UROS2Subscriber.
Definition: ROS2Topic.h:86
This should be refactored with other generic ROS2 types (Msgs, Sensors, Actions).
float PublicationFrequencyHz
Publish frequency. if this value > 0, this will update and publish msg periodically.
Definition: ROS2Publisher.h:343
FTimerHandle TimerHandle
Timer handler for periodic publisher.
Definition: ROS2Publisher.h:428
#define UE_LOG_WITH_INFO_NAMED(CategoryName, Verbosity,...)
Definition: logUtilities.h:139
@ Initialized
UMETA(DisplayName = "Created"),.
Definition: rclcUtilities.h:158
This should be refactored with other generic ROS2 types (Msgs, Sensors, Actions).
Definition: ROS2GenericMsg.h:46
ROS2 Publisher Component. Wrapper of UROS2Publisher for BP.
Definition: ROS2Publisher.h:482
ROS2 Custom Publisher Component. Wrapper of UROS2Publisher for BP.
Definition: ROS2Publisher.h:647
Class implementing ROS2 node.
rcl_publisher_t RclPublisher
ROS2 publisher.
Definition: ROS2Publisher.h:440