ROS2 hz topic (Increase publishing rate)

Hello, I just finished the foundation and basic ROS2 (Python) courses, and been playing around with simple publishers and subscribers on my own machine and realized the sampling (publishing) rate is low ( < 30 Hz). I wonder if there are ways to increase the sampling rate as much as the machine/device allows. For example, getting 100 Hz on IMU data or 60 Hz on camera image data.

I know when constructing the publisher node, we can increase the callback rate, but I’m still capping at 30 Hz or less.

Is this something I need to tune for QoS and DDS stuff? I’m looking to take the intermediate ROS2 course.

Hi @Genozen ,

I have some suggestions that might help. They are:

  1. Remove any print or log statements inside the data publishing node (the IMU data publisher or the camera image frame publisher nodes). Just keep it very straight and simple : read from sensor / device and immediately transport into the respective ROS2 node (after processing the data into required structure / data format).

  2. Make sure you are using threads or individual nodes that run the data acquisition from the sensor and transport it to the respective ROS2 nodes. Do not have a single node work on data acquisition from two or more devices. Use MultiThreadedExecutor with ReentarantCallbackGroups if necessary.

  3. Set the QoS to the fastest mode (when publishing sensor data into ROS2). It is similar to the trade-off between a UDP and TCP in internet protocols. With {history: keep last, depth: 1 to 10, reliability: best effort, durability: volatile}, you will get the fastest data throughput but less reliability. Alternatively, with {history: keep all or keep last with depth, depth: 10 to 100, reliability: reliable, durability: transient local}, you will get most reliable data but the data throughput will be slow and might suffer packet losses.

  4. Check the sensor sampling rate. A sensor rated at 1000 Hz might just be the clock rate or the bit rate. Although actual rate at which a complete data packet received from the sensor might be significantly less than 1000 Hz.

  5. Check for other potential overheads in the computer. A system update or a memory-consuming software would consume resources. Try to close them if possible.

  6. Cable lengths can slowdown data rates. Assuming you have connected a robot to your laptop with a long USB cable, then data-acquisition and data-processing rates will slow down. Also, if you are using long wires between your sensors and your robot’s microcontroller / microcomputer, then also data rates would be slow.

  7. Do a ROS2 update if not updated already. If you are still on Foxy, move to Galactic (reached EoL) or Humble.

That would be all my thoughts!

Regards,
Girish

1 Like

These are very good points, I will consider them. Thank you!

This topic was automatically closed after 7 days. New replies are no longer allowed.