Skip to main content
#ros2#nodes#topics#services#actions

ROS 2 nodes and data

Launching a node from its package and exploring how nodes exchange data in ROS 2.

#10. Nodes and data communication


Contents


#Definitions

NameDefinitionExamples
NodeA unit of computation in the ROS graphA camera driver publishing images, a filter, a feature extractor, an object detector, or a path planner using the detection
MessageData exchanged between nodes, with fields such as integers, floating-point values, booleans, and stringsTyped data appears in topics, services, actions, and parameter interfaces.

#Running a node with ros2 run

#Start a node

ros2 run <package> <executable>

$ ros2 run turtlesim turtlesim_node
$ ros2 run turtlesim turtle_teleop_key

#View the graph of running nodes

rqt_graph

#List the running nodes

ros2 node list

$ ros2 node list

# Example output
/rqt_gui_py_node_28168
/teleop_turtle
/turtlesim

#Run another instance with a different name

Multiple instances can start with the same node name. Assign distinct names so you can identify them.

$ ros2 run turtlesim turtlesim_node __node:=new_turtle
# Remap the node name to new_turtle.

#Inspect a node with ros2 node info

ros2 node info <node_name>

$ ros2 node info /teleop_turtle

# Output
/teleop_turtle
  Subscribers:
    /parameter_events: rcl_interfaces/msg/ParameterEvent
  Publishers:
    /parameter_events: rcl_interfaces/msg/ParameterEvent
    /rosout: rcl_interfaces/msg/Log
    /turtle1/cmd_vel: geometry_msgs/msg/Twist
  Service Servers:
    /teleop_turtle/describe_parameters: rcl_interfaces/srv/DescribeParameters
    /teleop_turtle/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
    /teleop_turtle/get_parameters: rcl_interfaces/srv/GetParameters
    /teleop_turtle/list_parameters: rcl_interfaces/srv/ListParameters
    /teleop_turtle/set_parameters: rcl_interfaces/srv/SetParameters
    /teleop_turtle/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
  Service Clients:

  Action Servers:

  Action Clients:
    /turtle1/rotate_absolute: turtlesim/action/RotateAbsolute

Connect