ROS2 Nodes and Topics
Nodes
Nodes are the basic processing units in ROS that performs a specific task or function within a ROS 2 system. It is an executable computer programming file. Nodes can communicate with each other by sending and receiving messages through a middleware layer provided by ROS 2.
A node may publish data to any number of topics and simultaneously have subscriptions to any number of topics.
Topics
Topics are best for unidirectional streaming. A request/response model is handled by a service. Fixed data is handled by a parameter server.
Examples
A robot control node may have topics for sensor data, motor commands, and status updates.
A drone node may have topics for receiving sensor data such as GPS, IMU, and camera images. It may also have topics for publishing control commands such as velocity, position, and orientation.
A mobile robot node may have topics for receiving sensor data such as laser scans, camera images, and odometry. It may also have topics for publishing control commands such as velocity, position, and orientation.