RosNodeΒΆ

Inherits: RefCounted

A ROS 2 Node that manages publishers, subscribers, and other communication interfaces.

DescriptionΒΆ

The RosNode is the primary interface for interacting with the ROS 2 network. It provides factory methods to create publishers, subscribers, clients, and services, and allows management of node-level parameters and timers.

A node must be initialized using init() before it can be used to create other communication components.

MethodsΒΆ

int

count_publishers(topic: String)

int

count_subscribers(topic: String)

RosActionClient

create_action_client(action_name: String, action_type: Variant, qos: RosQoS = null)

RosActionServer

create_action_server(action_name: String, action_type: Variant, execute_callback: Callable, goal_callback: Callable = Callable(), qos: RosQoS = null)

RosClient

create_client(srv_name: String, srv_type: Variant, qos: RosQoS = null)

RosPublisher

create_publisher(topic: String, type: Variant, qos: RosQoS = null)

RosService

create_service(srv_name: String, srv_type: Variant, callback: Callable, qos: RosQoS = null)

RosSubscriber

create_subscription(topic: String, type: Variant, callback: Callable, qos: RosQoS = null)

RosTfBroadcaster

create_tf_broadcaster()

RosTfListener

create_tf_listener()

RosTimer

create_timer(seconds: float, callback: Callable)

void

declare_parameter(name: String, default_value: Variant)

String

get_name() const

String

get_namespace() const

Variant

get_parameter(name: String)

Dictionary

get_topic_names_and_types()

void

init(node_name: String, namespace: String = "")

RosMsg

now()

String

resolve_frame(frame_id: String)

void

set_parameter(name: String, value: Variant)


SignalsΒΆ

parameter_changed(name: String, value: Variant) πŸ”—

Emitted whenever a node parameter is updated by an external tool or by set_parameter() locally.


Method DescriptionsΒΆ

int count_publishers(topic: String) πŸ”—

Returns the number of publishers currently active on a specific topic in the ROS 2 graph.


int count_subscribers(topic: String) πŸ”—

Returns the number of subscribers currently active on a specific topic in the ROS 2 graph.


RosActionClient create_action_client(action_name: String, action_type: Variant, qos: RosQoS = null) πŸ”—

Creates and returns a RosActionClient for the specified action_name and action_type (e.g. "example_interfaces/action/Fibonacci"). Use qos to configure the Quality of Service for the action client.


RosActionServer create_action_server(action_name: String, action_type: Variant, execute_callback: Callable, goal_callback: Callable = Callable(), qos: RosQoS = null) πŸ”—

Creates and returns a RosActionServer for the specified action_name and action_type. Incoming goals are auto-accepted and handed to execute_callback on the main thread as a RosServerGoalHandle, which must be driven to a terminal state. The goal_callback can optionally be used to reject goals. Use qos to configure the Quality of Service for the action server. See RosActionServer for a full example.


RosClient create_client(srv_name: String, srv_type: Variant, qos: RosQoS = null) πŸ”—

Creates and returns a RosClient for the specified service name and type. Use qos to configure the Quality of Service for the client.


RosPublisher create_publisher(topic: String, type: Variant, qos: RosQoS = null) πŸ”—

Creates and returns a RosPublisher to send messages to a specific topic. Use qos to configure the Quality of Service for the publisher.


RosService create_service(srv_name: String, srv_type: Variant, callback: Callable, qos: RosQoS = null) πŸ”—

Creates and returns a RosService server for the specified service name and type. The callback is triggered whenever a request is received. Use qos to configure the Quality of Service for the service server.


RosSubscriber create_subscription(topic: String, type: Variant, callback: Callable, qos: RosQoS = null) πŸ”—

Creates and returns a RosSubscriber to receive messages from a specific topic. The callback is triggered for every new message received, always on the Godot main thread. Use qos to configure the Quality of Service for the subscription.


RosTfBroadcaster create_tf_broadcaster() πŸ”—

Creates and returns a RosTfBroadcaster for publishing coordinate transforms into the TF2 system.


RosTfListener create_tf_listener() πŸ”—

Creates and returns a RosTfListener for looking up coordinate transforms in the TF2 system.


RosTimer create_timer(seconds: float, callback: Callable) πŸ”—

Creates and returns a RosTimer that triggers the callback at the specified seconds interval, synced with the ROS 2 executor's clock.


void declare_parameter(name: String, default_value: Variant) πŸ”—

Declares a parameter on the node with a default_value. Parameters must be declared before they can be retrieved or modified by external tools.


String get_name() const πŸ”—

Returns the name of the node as registered in the ROS 2 graph.


String get_namespace() const πŸ”—

Returns the namespace of the node.


Variant get_parameter(name: String) πŸ”—

Returns the current value of the parameter with the specified name.


Dictionary get_topic_names_and_types() πŸ”—

Returns a Dictionary containing all currently active topic names as keys and their associated message types as values.


void init(node_name: String, namespace: String = "") πŸ”—

Initializes the node with a node_name and an optional namespace. This must be called before using any other functions of the node.


RosMsg now() πŸ”—

Returns the current ROS 2 system time as a RosMsg of type builtin_interfaces/msg/Time.


String resolve_frame(frame_id: String) πŸ”—

Prepends the node's namespace to a frame_id if it is not already absolute, helping resolve local frame names in multi-agent simulations.


void set_parameter(name: String, value: Variant) πŸ”—

Sets the value of a previously declared parameter on the node.