Skip to content

Commit

Permalink
add bp api to create (#141) (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: yuokamoto <yuokamoto1988@gmail.com>
  • Loading branch information
github-actions[bot] and yuokamoto committed Apr 22, 2024
1 parent 422f4bb commit 3e69d57
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
8 changes: 7 additions & 1 deletion Source/rclUE/Public/ROS2ActionClient.h
Expand Up @@ -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)
{
Expand All @@ -202,6 +203,11 @@ class RCLUE_API UROS2ActionClientComponent : public UActorComponent
FeedbackQoS,
CancelQoS);
}
}

virtual void BeginPlay() override
{
DefaultCreateActionClient();
Super::BeginPlay();
};
};
8 changes: 7 additions & 1 deletion Source/rclUE/Public/ROS2ActionServer.h
Expand Up @@ -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)
{
Expand All @@ -171,6 +172,11 @@ class RCLUE_API UROS2ActionServerComponent : public UActorComponent
FeedbackQoS,
CancelQoS);
}
}

virtual void BeginPlay() override
{
DefaultCreateActionServer();
Super::BeginPlay();
};
};
11 changes: 6 additions & 5 deletions Source/rclUE/Public/ROS2Publisher.h
Expand Up @@ -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();
};
};
7 changes: 6 additions & 1 deletion Source/rclUE/Public/ROS2ServiceClient.h
Expand Up @@ -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();
};
};
7 changes: 6 additions & 1 deletion Source/rclUE/Public/ROS2ServiceServer.h
Expand Up @@ -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();
};
};
8 changes: 7 additions & 1 deletion Source/rclUE/Public/ROS2Subscriber.h
Expand Up @@ -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();
};
};

0 comments on commit 3e69d57

Please sign in to comment.