ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Dealing with several sensors

asked 2017-10-10 11:01:59 -0500

ta gravatar image

Hi, I'm wondering about best practices (when it comes to performance or robustness for instance) for dealing with several sensors. Imagine our robot has 5 IR sensors and 2 sonars, is it better to handle the communication with all the IR sensors with one node and the communication with the 2 sonars with another node and then publish on two different ROS topics messages with the relevant sensors' data or is it better to handle the communication with 7 nodes (5 for the IR and 2 for the sensors) that all publish messages on a unique topic associated with that node (7 topics therefore).


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-10-10 21:13:51 -0500

ahendrix gravatar image

This mostly depends on how your sensors are hooked up to your computer.

The general rule of thumb for ROS nodes that interface with hardware is to have one ROS node for each unique interface, usually because the operating system only allows a single process to access that resource. So for example if you have a single serial port or USB device, you'll probably want a single process, but if you have sensors on a network or one sensor per serial port, it's usually easier to run one node for each device.

If possible, it's generally much easier to write a node that handles a single sensor.

As for how to choose topics, I've seen systems that publish one topic per sensor, and systems that combine data from multiple sensors (of the same type) on a single topic. In either case, it's important to set the correct frame_id on each message so that the subscriber knows the correct TF frame for that sensor data. Most subscribers (such as navigation and move_base) expect one topic per sensor, so I recommend that unless you have a custom system.

edit flag offensive delete link more

Question Tools


Asked: 2017-10-10 11:01:59 -0500

Seen: 1,393 times

Last updated: Oct 10 '17