Topic QoS Configuration

Fine-tune communication reliability and persistence.

Quality of Service (QoS) profiles allow you to tune how data is handled between nodes. You can configure whether to prioritize speed (Best Effort) or data integrity (Reliable), and whether late-joining nodes should receive past data (Transient Local).

Core Concepts

Understanding the trade-offs in ROS2 communication.

  • Reliability - Reliable vs. Best Effort.

    • Reliable: Guarantees delivery. Retries if packets are lost. (Good for services/control).

    • Best Effort: Fire and forget. Fast, but drops data if network is bad. (Good for sensor streams).

  • Durability - Volatile vs. Transient Local.

    • Volatile: No history. Late joiners only see new data.

    • Transient Local: The publisher “saves” the last \(N\) messages. Late joiners get the last known value immediately. (Good for maps/configuration).

  • History - Keep Last vs. Keep All.

    • Keep Last: Only store a fixed queue of \(N\) samples. Oldest are dropped.

    • Keep All: Store everything (subject to resource limits).


Configuration Parameters

The QoSConfig class provides a wrapper to easily set these policies in Kompass.

  • history - qos.HistoryPolicy
    Configuration of samples to store.
    Default: KEEP_LAST

  • queue_size - int
    The depth of the queue. Only honored if history is set to KEEP_LAST.
    Range: [5, 100]
    Default: 10

  • reliability - qos.ReliabilityPolicy
    Samples deliverance guarantee.
    Default: RELIABLE

  • durability - qos.DurabilityPolicy
    Controls whether published samples are stored for late-joiners.
    Default: VOLATILE

Usage Example

from kompass.ros import Topic, QoSConfig
from rclpy import qos

# 1. Define the Profile
# Example: A profile for a Map topic (Needs to be reliable and available to late joiners)
qos_map_profile = QoSConfig(
    history=qos.HistoryPolicy.KEEP_LAST,
    queue_size=1,
    reliability=qos.ReliabilityPolicy.RELIABLE,
    durability=qos.DurabilityPolicy.TRANSIENT_LOCAL
)

# 2. Apply to Topic
topic = Topic(
    name='/local_map',
    msg_type='OccupancyGrid',
    qos_profile=qos_map_profile
)