rclUE
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
UROS2NodeComponent Class Reference

Class implementing ROS2 node. More...

#include <ROS2NodeComponent.h>

Inheritance diagram for UROS2NodeComponent:
Inheritance graph
[legend]
Collaboration diagram for UROS2NodeComponent:
Collaboration graph
[legend]

Public Member Functions

 UROS2NodeComponent ()
 A constructor.
 
virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
 Called every frame. More...
 
void Init ()
 Initilize rosnode with rclc_node_init_default. More...
 
void AddPublisher (UROS2Publisher *InPublisher)
 Set this node to UROS2Publisher::OwnerNode of InPublisher and add to Publishers. More...
 
UROS2PublisherCreateLoopPublisherWithClass (const FString &InTopicName, const TSubclassOf< UROS2Publisher > &InPublisherClass, const float InPubFrequency)
 Create a new UROS2Publisher of custom publisher class and add to Node. More...
 
UROS2PublisherCreateLoopPublisher (const FString &InTopicName, const TSubclassOf< UROS2Publisher > &InPublisherClass, const TSubclassOf< UROS2GenericMsg > &InMsgClass, const float InPubFrequency, const FTopicCallback &InUpdateDelegate, const UROS2QoS InQoS=UROS2QoS::Default)
 Create a new UROS2Publisher and add to Node. More...
 
UROS2PublisherCreatePublisherWithClass (const TSubclassOf< UROS2Publisher > &InPublisherClass, const FString &InTopicName=TEXT(""))
 Create a new UROS2Publisher of custom publisher class and add to Node. More...
 
UROS2PublisherCreatePublisher (const FString &InTopicName, const TSubclassOf< UROS2Publisher > &InPublisherClass, const TSubclassOf< UROS2GenericMsg > &InMsgClass, const UROS2QoS InQoS=UROS2QoS::Default)
 Create a new UROS2Publisher and add to Node. More...
 
void AddSubscription (UROS2Subscriber *InSubscriber)
 Methods to register subscribers. More...
 
UROS2SubscriberCreateSubscriber (const FString &InTopicName, const TSubclassOf< UROS2GenericMsg > &InMsgClass, const FSubscriptionCallback &InCallback, const UROS2QoS InQoS=UROS2QoS::Default)
 Create a new UROS2Subscriber and add to Node. More...
 
void AddServiceClient (UROS2ServiceClient *InServiceClient)
 Set this node to UROS2ServiceClient::OwnerNode and add to ServiceClients. More...
 
UROS2ServiceClientCreateServiceClient (const FString &InServiceName, const TSubclassOf< UROS2GenericSrv > &InSrvClass, const FServiceCallback &InResponseDelegate, const UROS2QoS InQoS=UROS2QoS::Services)
 Create a new UROS2ServiceClient and add to Node. More...
 
void AddServiceServer (UROS2ServiceServer *InServiceServer)
 Create ServiceServer with rcl_service_init and add to ServiceServers. More...
 
UROS2ServiceServerCreateServiceServer (const FString &InServiceName, const TSubclassOf< UROS2GenericSrv > &InSrvClass, const FServiceCallback &InCallback, const UROS2QoS InQoS=UROS2QoS::Services)
 Create a new UROS2ServiceServer and add to Node. More...
 
void AddActionClient (UROS2ActionClient *InActionClient)
 Set this node to UROS2ActionClient::OwnerNode and add to ActionClients. More...
 
UROS2ActionClientCreateActionClient (const FString &InActionName, const TSubclassOf< UROS2GenericAction > &InActionClass, const FActionCallback &InGoalResponseDelegate, const FActionCallback &InResultResponseDelegate, const FActionCallback &InFeedbackDelegate, const FSimpleCallback &InCancelResponseDelegate, const UROS2QoS InGoalQoS=UROS2QoS::Services, const UROS2QoS InResultQoS=UROS2QoS::Services, const UROS2QoS InFeedbackQoS=UROS2QoS::Default, const UROS2QoS InCancelQoS=UROS2QoS::Services)
 Create a new UROS2ActionClient and add to Node. More...
 
void AddActionServer (UROS2ActionServer *InActionServer)
 Set this node to UROS2ActionClient::OwnerNode and add to ActionServers. More...
 
UROS2ActionServerCreateActionServer (const FString &InActionName, const TSubclassOf< UROS2GenericAction > &InActionClass, const FActionCallback &InGoalDelegate, const FSimpleCallback &InResultDelegate, const FSimpleCallback &InCancelDelegate, const UROS2QoS InGoalQoS=UROS2QoS::Services, const UROS2QoS InResultQoS=UROS2QoS::Services, const UROS2QoS InFeedbackQoS=UROS2QoS::Default, const UROS2QoS InCancelQoS=UROS2QoS::Services)
 Create a Action Server and add to Node. More...
 

Static Public Member Functions

static UROS2NodeComponentCreateNewNode (UObject *InOwner, const FString &InNodeName, const FString &InNodeNamespace, const FString &InCompName=TEXT("ROS2NodeComponent"), const bool Init=true)
 Create a New Node object. More...
 

Public Attributes

TEnumAsByte< UROS2StateState = UROS2State::Created
 Node state. More...
 
FString Name = TEXT("node")
 
FString Namespace = TEXT("")
 
int NGuardConditions = 0
 wait_set quantities - currently unused More...
 
int NTimers = 0
 
int NEvents = 0
 

Protected Member Functions

virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 Overridable function called whenever this actor is being removed from a level. More...
 
void SpinSome ()
 method used to wait on communication and call delegates when appropriate modeled after executor + actions. More...
 

Protected Attributes

UROS2SupportSupport
 
TArray< UROS2Subscriber * > Subscriptions
 
TArray< UROS2ServiceServer * > ServiceServers
 
TArray< UROS2Publisher * > Publishers
 
TArray< UROS2ServiceClient * > ServiceClients
 
TArray< UROS2ActionClient * > ActionClients
 
TArray< UROS2ActionServer * > ActionServers
 
float LogLastHit = 0.f
 internal property used to log throttle. More...
 

Private Member Functions

void HandleSubscriptions ()
 based on _rclc_default_scheduling of the rclc executor. More...
 
void HandleServiceServers ()
 based on _rclc_default_scheduling of the rclc executor. More...
 
void HandleServiceClients ()
 based on _rclc_default_scheduling of the rclc executor. More...
 
void HandleActionClients ()
 based on _rclc_default_scheduling of the rclc executor. More...
 
void HandleActionServers ()
 based on _rclc_default_scheduling of the rclc executor. More...
 
void InvalidateWaitSet ()
 invalidate #wait_set so that in next spin_some() call the More...
 

Detailed Description

Class implementing ROS2 node.

This class also handles tasks performed by the executor in rclc.

Components of the node and not additional distinct entities publishers, subscribers, services, service clients, action servers

and action clients should register to the node with the appropriate methods (Add*).

UCLASS(ClassGroup = (Custom), Blueprintable, meta = (BlueprintSpawnableComponent))

Member Function Documentation

◆ AddActionClient()

void UROS2NodeComponent::AddActionClient ( UROS2ActionClient InActionClient)

Set this node to UROS2ActionClient::OwnerNode and add to ActionClients.

Parameters
InActionClient

UFUNCTION(BlueprintCallable)

◆ AddActionServer()

void UROS2NodeComponent::AddActionServer ( UROS2ActionServer InActionServer)

Set this node to UROS2ActionClient::OwnerNode and add to ActionServers.

Parameters
InActionServer

UFUNCTION(BlueprintCallable)

◆ AddPublisher()

void UROS2NodeComponent::AddPublisher ( UROS2Publisher InPublisher)

Set this node to UROS2Publisher::OwnerNode of InPublisher and add to Publishers.

Parameters
InPublisher

UFUNCTION(BlueprintCallable)

◆ AddServiceClient()

void UROS2NodeComponent::AddServiceClient ( UROS2ServiceClient InServiceClient)

Set this node to UROS2ServiceClient::OwnerNode and add to ServiceClients.

Parameters
InClient

UFUNCTION(BlueprintCallable)

◆ AddServiceServer()

void UROS2NodeComponent::AddServiceServer ( UROS2ServiceServer InServiceServer)

Create ServiceServer with rcl_service_init and add to ServiceServers.

Parameters
ServiceName
SrvClass
Callback

UFUNCTION(BlueprintCallable)

◆ AddSubscription()

void UROS2NodeComponent::AddSubscription ( UROS2Subscriber InSubscriber)

Methods to register subscribers.

Parameters
TopicName
MsgClass
Callback

UFUNCTION(BlueprintCallable)

◆ CreateActionClient()

UROS2ActionClient* UROS2NodeComponent::CreateActionClient ( const FString &  InActionName,
const TSubclassOf< UROS2GenericAction > &  InActionClass,
const FActionCallback &  InGoalResponseDelegate,
const FActionCallback &  InResultResponseDelegate,
const FActionCallback &  InFeedbackDelegate,
const FSimpleCallback &  InCancelResponseDelegate,
const UROS2QoS  InGoalQoS = UROS2QoS::Services,
const UROS2QoS  InResultQoS = UROS2QoS::Services,
const UROS2QoS  InFeedbackQoS = UROS2QoS::Default,
const UROS2QoS  InCancelQoS = UROS2QoS::Services 
)

Create a new UROS2ActionClient and add to Node.

Parameters
InActionName
InActionClass
InFeedbackDelegate
InResultResponseDelegate
InGoalResponseDelegate
InCancelResponseDelegate
InFeedbackQoS
InResultQoS
InGoalQoS
InCancelQoS
Returns
UROS2ActionClient*

◆ CreateActionServer()

UROS2ActionServer* UROS2NodeComponent::CreateActionServer ( const FString &  InActionName,
const TSubclassOf< UROS2GenericAction > &  InActionClass,
const FActionCallback &  InGoalDelegate,
const FSimpleCallback &  InResultDelegate,
const FSimpleCallback &  InCancelDelegate,
const UROS2QoS  InGoalQoS = UROS2QoS::Services,
const UROS2QoS  InResultQoS = UROS2QoS::Services,
const UROS2QoS  InFeedbackQoS = UROS2QoS::Default,
const UROS2QoS  InCancelQoS = UROS2QoS::Services 
)

Create a Action Server and add to Node.

Parameters
InActionName
InActionClass
InGoalDelegate
InCancelDelegate
InResultDelegate
InFeedbackQoS
InResultQoS
InGoalQoS
InCancelQoS
Returns
UROS2ActionServer*

◆ CreateLoopPublisher()

UROS2Publisher* UROS2NodeComponent::CreateLoopPublisher ( const FString &  InTopicName,
const TSubclassOf< UROS2Publisher > &  InPublisherClass,
const TSubclassOf< UROS2GenericMsg > &  InMsgClass,
const float  InPubFrequency,
const FTopicCallback &  InUpdateDelegate,
const UROS2QoS  InQoS = UROS2QoS::Default 
)

Create a new UROS2Publisher and add to Node.

Parameters
InTopicNameTopic name
InPublisherClassCustom output publisher type class
InMsgClassCustom message type class
InPubFrequencyPublishing frequency
InUpdateDelegateDelegate which is called with given frequency.
InQoSQoS. Default is UROS2QoS::Default

UFUNCTION(BlueprintCallable)

◆ CreateLoopPublisherWithClass()

UROS2Publisher* UROS2NodeComponent::CreateLoopPublisherWithClass ( const FString &  InTopicName,
const TSubclassOf< UROS2Publisher > &  InPublisherClass,
const float  InPubFrequency 
)

Create a new UROS2Publisher of custom publisher class and add to Node.

Custom Publisher class is expected to override #UROS2Publisher::Update which in loop with frequency.

Parameters
InTopicNameTopic name
InPublisherClassCustom output publisher type class
InPubFrequencyPublishing frequency

UFUNCTION(BlueprintCallable)

◆ CreateNewNode()

static UROS2NodeComponent* UROS2NodeComponent::CreateNewNode ( UObject *  InOwner,
const FString &  InNodeName,
const FString &  InNodeNamespace,
const FString &  InCompName = TEXT("ROS2NodeComponent"),
const bool  Init = true 
)
static

Create a New Node object.

Used outside of constructor.

Parameters
InNodeName
InNodeNamespace
InCompName
Returns
UROS2NodeComponent*

UFUNCTION(BlueprintCallable)

◆ CreatePublisher()

UROS2Publisher* UROS2NodeComponent::CreatePublisher ( const FString &  InTopicName,
const TSubclassOf< UROS2Publisher > &  InPublisherClass,
const TSubclassOf< UROS2GenericMsg > &  InMsgClass,
const UROS2QoS  InQoS = UROS2QoS::Default 
)

Create a new UROS2Publisher and add to Node.

Parameters
InTopicNameTopic name
InPublisherClassCustom output publisher type class
InMsgClassCustom message type class
InQoSQoS. Default is UROS2QoS::Default

UFUNCTION(BlueprintCallable)

◆ CreatePublisherWithClass()

UROS2Publisher* UROS2NodeComponent::CreatePublisherWithClass ( const TSubclassOf< UROS2Publisher > &  InPublisherClass,
const FString &  InTopicName = TEXT("") 
)

Create a new UROS2Publisher of custom publisher class and add to Node.

Parameters
InPublisherClass
InTopicName
Returns
UROS2Publisher*

UFUNCTION(BlueprintCallable)

◆ CreateServiceClient()

UROS2ServiceClient* UROS2NodeComponent::CreateServiceClient ( const FString &  InServiceName,
const TSubclassOf< UROS2GenericSrv > &  InSrvClass,
const FServiceCallback &  InResponseDelegate,
const UROS2QoS  InQoS = UROS2QoS::Services 
)

Create a new UROS2ServiceClient and add to Node.

Parameters
InServiceName
InSrvClass
InRequestDelegate
InResponseDelegate
InQoSQoS. Default is UROS2QoS::Default
Returns
UROS2NodeComponent*

UFUNCTION(BlueprintCallable)

◆ CreateServiceServer()

UROS2ServiceServer* UROS2NodeComponent::CreateServiceServer ( const FString &  InServiceName,
const TSubclassOf< UROS2GenericSrv > &  InSrvClass,
const FServiceCallback &  InCallback,
const UROS2QoS  InQoS = UROS2QoS::Services 
)

Create a new UROS2ServiceServer and add to Node.

Parameters
InTopicNameTopic name
InSrvClassCustom message type class
InCallbackCallback function

UFUNCTION(BlueprintCallable)

◆ CreateSubscriber()

UROS2Subscriber* UROS2NodeComponent::CreateSubscriber ( const FString &  InTopicName,
const TSubclassOf< UROS2GenericMsg > &  InMsgClass,
const FSubscriptionCallback &  InCallback,
const UROS2QoS  InQoS = UROS2QoS::Default 
)

Create a new UROS2Subscriber and add to Node.

Parameters
InTopicName
InMsgClass
InCallback
Returns
UROS2Subscriber*

UFUNCTION(BlueprintCallable)

◆ EndPlay()

virtual void UROS2NodeComponent::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
overrideprotectedvirtual

Overridable function called whenever this actor is being removed from a level.

Parameters
EndPlayReason
See also
AActor::EndPlay

◆ HandleActionClients()

void UROS2NodeComponent::HandleActionClients ( )
private

based on _rclc_default_scheduling of the rclc executor.

Called inside SpinSome. rcl_take_response_with_info to get response and execute Callback.

UFUNCTION()

◆ HandleActionServers()

void UROS2NodeComponent::HandleActionServers ( )
private

based on _rclc_default_scheduling of the rclc executor.

Called inside SpinSome. rcl_take_response_with_info to get response and execute Callback.

UFUNCTION()

◆ HandleServiceClients()

void UROS2NodeComponent::HandleServiceClients ( )
private

based on _rclc_default_scheduling of the rclc executor.

Called inside SpinSome. rcl_take_response_with_info to get response and execute Callback.

UFUNCTION()

◆ HandleServiceServers()

void UROS2NodeComponent::HandleServiceServers ( )
private

based on _rclc_default_scheduling of the rclc executor.

Called inside SpinSome. rcl_take_request_with_info to get request, execute Callback and rcl_send_response to send response

UFUNCTION()

◆ HandleSubscriptions()

void UROS2NodeComponent::HandleSubscriptions ( )
private

based on _rclc_default_scheduling of the rclc executor.

Called inside SpinSome. rcl_take to get topic and execute Callback.

UFUNCTION()

◆ Init()

void UROS2NodeComponent::Init ( )

Initilize rosnode with rclc_node_init_default.

This can't be pre-placed in #UROS2NodeComponent::BeginPlay() as the order of rcl(c) instructions could be different/relevant

in each of Child classes

UFUNCTION(BlueprintCallable)

◆ InvalidateWaitSet()

void UROS2NodeComponent::InvalidateWaitSet ( )
private

invalidate #wait_set so that in next spin_some() call the

#wait_set is updated accordingly in SpinSome

See also
[rclc_executor_add_subscription_with_context in

rclc/executor.c](https://github.com/ros2/rclc/blob/243ee63ca369f0fb90397ba9ae0ca1283ab16ad3/rclc/src/rclc/executor.c#L207)

UFUNCTION()

◆ SpinSome()

void UROS2NodeComponent::SpinSome ( )
protected

method used to wait on communication and call delegates when appropriate modeled after executor + actions.

See also
[rclc_executor_spin_some in

rclc/executor.c](https://github.com/ros2/rclc/blob/243ee63ca369f0fb90397ba9ae0ca1283ab16ad3/rclc/src/rclc/executor.c#L1802)

UFUNCTION()

◆ TickComponent()

virtual void UROS2NodeComponent::TickComponent ( float  DeltaTime,
ELevelTick  TickType,
FActorComponentTickFunction *  ThisTickFunction 
)
overridevirtual

Called every frame.

Parameters
DeltaTime
TickType
ThisTickFunction

Member Data Documentation

◆ ActionClients

TArray<UROS2ActionClient*> UROS2NodeComponent::ActionClients
protected

◆ ActionServers

TArray<UROS2ActionServer*> UROS2NodeComponent::ActionServers
protected

◆ LogLastHit

float UROS2NodeComponent::LogLastHit = 0.f
protected

internal property used to log throttle.

UPROPERTY()

◆ Name

FString UROS2NodeComponent::Name = TEXT("node")

◆ Namespace

FString UROS2NodeComponent::Namespace = TEXT("")

◆ NEvents

int UROS2NodeComponent::NEvents = 0

◆ NGuardConditions

int UROS2NodeComponent::NGuardConditions = 0

wait_set quantities - currently unused

UPROPERTY(VisibleAnywhere, Category = "Diagnostics")

◆ NTimers

int UROS2NodeComponent::NTimers = 0

◆ Publishers

TArray<UROS2Publisher*> UROS2NodeComponent::Publishers
protected

◆ ServiceClients

TArray<UROS2ServiceClient*> UROS2NodeComponent::ServiceClients
protected

◆ ServiceServers

TArray<UROS2ServiceServer*> UROS2NodeComponent::ServiceServers
protected

◆ State

TEnumAsByte<UROS2State> UROS2NodeComponent::State = UROS2State::Created

◆ Subscriptions

TArray<UROS2Subscriber*> UROS2NodeComponent::Subscriptions
protected

◆ Support

UROS2Support* UROS2NodeComponent::Support
protected

The documentation for this class was generated from the following file: