diff --git a/Source/rclUE/Public/ROS2ActionClient.h b/Source/rclUE/Public/ROS2ActionClient.h index 5262a2b9..a69d7d38 100644 --- a/Source/rclUE/Public/ROS2ActionClient.h +++ b/Source/rclUE/Public/ROS2ActionClient.h @@ -186,7 +186,8 @@ class RCLUE_API UROS2ActionClientComponent : public UActorComponent FActionCallback FeedbackDelegate; FSimpleCallback CancelResponseDelegate; - virtual void BeginPlay() override + UFUNCTION(BlueprintCallable) + virtual void DefaultCreateActionClient() { if (ActionClient == nullptr) { @@ -202,6 +203,11 @@ class RCLUE_API UROS2ActionClientComponent : public UActorComponent FeedbackQoS, CancelQoS); } + } + + virtual void BeginPlay() override + { + DefaultCreateActionClient(); Super::BeginPlay(); }; }; diff --git a/Source/rclUE/Public/ROS2ActionServer.h b/Source/rclUE/Public/ROS2ActionServer.h index f832d28d..b352ada1 100644 --- a/Source/rclUE/Public/ROS2ActionServer.h +++ b/Source/rclUE/Public/ROS2ActionServer.h @@ -156,7 +156,8 @@ class RCLUE_API UROS2ActionServerComponent : public UActorComponent FSimpleCallback ResultDelegate; FSimpleCallback CancelDelegate; - virtual void BeginPlay() override + UFUNCTION(BlueprintCallable) + virtual void DefaultCreateActionServer() { if (ActionServer == nullptr) { @@ -171,6 +172,11 @@ class RCLUE_API UROS2ActionServerComponent : public UActorComponent FeedbackQoS, CancelQoS); } + } + + virtual void BeginPlay() override + { + DefaultCreateActionServer(); Super::BeginPlay(); }; }; diff --git a/Source/rclUE/Public/ROS2Publisher.h b/Source/rclUE/Public/ROS2Publisher.h index 8f4f1ebb..291db6b7 100644 --- a/Source/rclUE/Public/ROS2Publisher.h +++ b/Source/rclUE/Public/ROS2Publisher.h @@ -304,16 +304,17 @@ class RCLUE_API UROS2CustomPublisherComponent : public UActorComponent UPROPERTY(EditAnywhere, BlueprintReadWrite) float PublicationFrequencyHz = 1.f; - virtual void BeginPlay() override + UFUNCTION(BlueprintCallable) + virtual void DefaultCreatePublisher() { if (Publisher == nullptr) { Publisher = UROS2Publisher::CreateLoopPublisherWithClass(this, TopicName, PublisherClass, PublicationFrequencyHz); } - else - { - UE_LOG_WITH_INFO(LogTemp, Warning, TEXT("Publisher class is not created in BeginPlay.")); - } + } + virtual void BeginPlay() override + { + DefaultCreatePublisher(); Super::BeginPlay(); }; }; diff --git a/Source/rclUE/Public/ROS2ServiceClient.h b/Source/rclUE/Public/ROS2ServiceClient.h index 819bd9e4..363ab63a 100644 --- a/Source/rclUE/Public/ROS2ServiceClient.h +++ b/Source/rclUE/Public/ROS2ServiceClient.h @@ -162,12 +162,17 @@ class RCLUE_API UROS2ServiceClientComponent : public UActorComponent UPROPERTY(EditAnywhere, BlueprintReadWrite) FServiceCallback ResponseDelegate; - virtual void BeginPlay() override + UFUNCTION(BlueprintCallable) + virtual void DefaultCreateServiceClient() { if (ServiceClient == nullptr) { ServiceClient = UROS2ServiceClient::CreateServiceClient(this, ServiceName, SrvClass, ResponseDelegate, QoS); } + } + virtual void BeginPlay() override + { + DefaultCreateServiceClient(); Super::BeginPlay(); }; }; diff --git a/Source/rclUE/Public/ROS2ServiceServer.h b/Source/rclUE/Public/ROS2ServiceServer.h index ddf9ef8f..b7308773 100644 --- a/Source/rclUE/Public/ROS2ServiceServer.h +++ b/Source/rclUE/Public/ROS2ServiceServer.h @@ -113,12 +113,17 @@ class RCLUE_API UROS2ServiceServerComponent : public UActorComponent UPROPERTY(EditAnywhere, BlueprintReadWrite) FServiceCallback SrvCallback; - virtual void BeginPlay() override + UFUNCTION(BlueprintCallable) + virtual void DefaultCreateServiceServer() { if (ServiceServer == nullptr) { ServiceServer = UROS2ServiceServer::CreateServiceServer(this, ServiceName, SrvClass, SrvCallback, QoS); } + } + virtual void BeginPlay() override + { + DefaultCreateServiceServer(); Super::BeginPlay(); }; }; diff --git a/Source/rclUE/Public/ROS2Subscriber.h b/Source/rclUE/Public/ROS2Subscriber.h index 8e929d73..cc4785bd 100644 --- a/Source/rclUE/Public/ROS2Subscriber.h +++ b/Source/rclUE/Public/ROS2Subscriber.h @@ -101,12 +101,18 @@ class RCLUE_API UROS2SubscriberComponent : public UActorComponent UPROPERTY(EditAnywhere, BlueprintReadWrite) FSubscriptionCallback Callback; - virtual void BeginPlay() override + UFUNCTION(BlueprintCallable) + virtual void DefaultCreateSubscriber() { if (Subscriber == nullptr) { Subscriber = UROS2Subscriber::CreateSubscriber(this, TopicName, MsgClass, Callback, QoS); } + } + + virtual void BeginPlay() override + { + DefaultCreateSubscriber(); Super::BeginPlay(); }; };