For most ROS 2 robot applications, choose Reliable for commands, configuration, and critical state, and Best Effort for high-frequency sensor data like camera streams and LiDAR scans. This article explains how QoS profiles work, how to pick the right one, and what happens when publishers and subscribers don’t match.
What Are QoS Profiles in ROS 2?
Quality of Service (QoS) profiles in ROS 2 define the delivery guarantees for messages on a topic. They replace the single, always-reliable mechanism of ROS 1 with a set of policies that let you tune how data is transmitted, buffered, and dropped. The two most visible policies are Reliability and Durability, but a full profile also includes History, Depth, Deadline, and Lifespan.
When a publisher and subscriber use incompatible QoS profiles, the middleware (DDS) refuses to connect them. This is a common source of confusing behavior: a node publishes, another node subscribes, but no messages arrive. The ROS 2 command-line tool ros2 topic info --verbose shows the QoS of existing publishers and subscribers, which is the first place to look when debugging a silent topic.
Reliability: Reliable vs. Best Effort
The Reliability policy has two settings:
- Reliable: The middleware guarantees delivery of every message, retransmitting as needed. This adds overhead and can introduce latency or backpressure when the network is slow.
- Best Effort: Messages are sent once; if lost, they are not retransmitted. This minimizes overhead and latency, but some data may be missing.
In practice, ROS 2’s default QoS is Reliable with a depth of 10. This is safe for most topics, but it can be problematic for high-bandwidth sensor streams. For example, a 30 Hz camera feed with large images can easily overwhelm a reliable connection, causing the publisher to block or drop messages. Best Effort lets the publisher send as fast as it can, and the subscriber simply uses whatever arrives.
How to Choose for Your Robot
Start by categorizing your topics by their role in the system:
- Commands and configuration (e.g.,
/cmd_vel,/goal_pose): use Reliable. Losing a movement command could cause a robot to miss a stop or turn. - Critical state (e.g.,
/odom,/battery_state): use Reliable if the consumer needs every update, or Best Effort if the consumer can tolerate gaps and the data is high-frequency. - High-frequency sensor data (e.g.,
/camera/image_raw,/scan): use Best Effort. A single lost LiDAR scan is rarely catastrophic; a backlog of old scans is worse. - Diagnostics and logging: Reliable is fine if the volume is low, but consider Best Effort for high-rate logs.
When in doubt, test both. Run your robot with a Best Effort subscriber on a sensor topic and check if the data quality is acceptable. If you see occasional drops but the system behaves, Best Effort is the right choice. If you need every sample, switch to Reliable and ensure your network can keep up.
Common Problems and Misconceptions
One frequent issue is mixing QoS profiles without realizing it. For example, RViz2 subscribes to /scan with a Best Effort profile by default, but your publisher uses Reliable. The topic appears in ros2 topic list, but RViz2 shows no data. The fix is to set the publisher to Best Effort or configure the subscriber to Reliable.
Another misconception is that Best Effort means “unreliable” in a negative sense. In robotics, it is often the more appropriate choice for sensor data because it avoids head-of-line blocking. A reliable connection that is stuck retransmitting an old image can delay newer, more relevant data. Best Effort keeps the pipeline flowing.
Depth also matters. A Reliable publisher with a depth of 1 will drop messages if the subscriber is slow, even though it is Reliable. The Reliability policy only guarantees delivery if the middleware can buffer the messages. For bursty data, increase the depth to 10 or more.
Practical Example: Configuring QoS in Code
Here is how you would set a Best Effort profile for a camera publisher in C++:
rclcpp::QoS qos(10);
qos.reliability(RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT);
image_pub = this->create_publisher<sensor_msgs::msg::Image>("image_raw", qos);
In Python, the equivalent is:
from rclpy.qos import QoSProfile, ReliabilityPolicy
qos = QoSProfile(depth=10, reliability=ReliabilityPolicy.BEST_EFFORT)
image_pub = self.create_publisher(Image, 'image_raw', qos)
For a subscriber that needs Reliable, you would set ReliabilityPolicy.RELIABLE. Always match the profile on both sides, or use the qos_overrides parameter in ROS 2 Humble and later to override a specific topic’s QoS without changing code.
QoS and Network Performance
On a real robot, the network between nodes matters. If you run everything on a single machine, the loopback interface is fast and reliable, so Reliable is usually fine. Over Wi-Fi or a congested Ethernet bus, Best Effort can be a lifesaver for sensor data.
Remember that QoS also affects memory usage. A Reliable publisher with a large depth will buffer many messages, consuming RAM. For a 4K camera stream, a depth of 10 could mean several hundred megabytes. Best Effort with a shallow depth keeps memory low.
Frequently Asked Questions
Why is my subscriber not receiving any messages even though the topic exists?
This is almost always a QoS mismatch. Check with ros2 topic info --verbose to see the publisher and subscriber QoS. If the reliability policies differ (one Reliable, one Best Effort), they will not connect. Change one side to match the other.
Can I have a Reliable publisher and a Best Effort subscriber?
No. The QoS policies must be compatible. If the publisher is Reliable and the subscriber is Best Effort, the middleware will not establish a connection. Both must use the same reliability setting, or you must use a middleware that supports bridging, which is not standard.
Is Best Effort okay for odometry?
It depends. If your odometry is used for local planning and runs at 50 Hz, losing a few messages is fine. If it is used for precise mapping or state estimation, you may want Reliable to avoid gaps. Test both and see if the system behaves correctly.
What does depth mean in a QoS profile?
Depth is the number of messages the middleware queues for a subscriber before dropping old ones. A depth of 10 means the last 10 messages are kept. For Reliable, if the subscriber is slow, the queue fills and the publisher may block or drop messages. For Best Effort, the queue simply drops old messages.
Should I use the default QoS for all topics?
No. The default (Reliable, depth 10) is safe but not optimal. For high-bandwidth sensor data, Best Effort is usually better. For low-rate commands, Reliable is best. Evaluate each topic individually.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Infinity Essence in Sailor Piece: Farming and Uses
- Apollo.io Alternatives for Sales Prospecting
- Deploy AI Agents in a Service Desk With Human Oversight
- AIM and Yahoo Profiles: When Did You Last Look?
- Best Smartwatch Under ₹5,000 in India: What to Buy
- Chat History vs Saved Memory in AI Assistants