Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "About Quality of Service settings" Wiki Page #661

Merged
merged 5 commits into from
May 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 194 additions & 61 deletions source/Concepts/About-Quality-of-Service-Settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,104 @@
About Quality of Service settings
=================================


Overview
--------

ROS 2 offers a rich variety of Quality of Service (QoS) policies that allow you to tune communication between nodes.
With the right set of Quality of Service policies, ROS 2 can be as reliable as TCP or as best-effort as UDP, with many, many possible states in between.
Unlike ROS 1, which primarily only supported TCP, ROS 2 benefits from the flexibility of the underlying DDS transport in environments with lossy wireless networks where a "best effort" policy would be more suitable, or in real-time computing systems where the right Quality of Service profile is needed to meet deadlines.
Unlike ROS 1, which primarily only supported TCP, ROS 2 benefits from the flexibility of the underlying DDS transport in environments with lossy wireless networks where a best effort policy would be more suitable, or in real-time computing systems where the right Quality of Service profile is needed to meet deadlines.

A set of QoS "policies" combine to form a QoS "profile".
Given the complexity of choosing the correct QoS policies for a given scenario, ROS 2 provides a set of predefined QoS profiles for common usecases (e.g. sensor data).
At the same time, users are given the flexibility to control specific profiles of the QoS policies.
A set of QoS policies combine to form a QoS profile.
Given the complexity of choosing the correct QoS policies for a given scenario, ROS 2 provides a set of predefined QoS profiles for common use cases (e.g. sensor data).
At the same time, developers are given the flexibility to control specific policies of the QoS profiles.

QoS profiles can be specified for publishers, subscribers, service servers and clients.
QoS profiles can be specified for publishers, subscriptions, service servers and clients.
A QoS profile can be applied independently to each instance of the aforementioned entities, but if different profiles are used, it is possible that they will not connect.


QoS policies
------------

The base QoS profile currently includes settings for the following policies:


* History

* Keep last: only store up to N samples, configurable via the queue depth option.
* Keep all: store all samples, subject to the configured resource limits of the underlying middleware.
* *Keep last*: only store up to N samples, configurable via the queue depth option.
* *Keep all*: store all samples, subject to the configured resource limits of the underlying middleware.

* Depth

* Size of the queue: only honored if used together with “keep last”.
* *Queue size*: only honored if the “history” policy was set to “keep last”.

* Reliability

* Best effort: attempt to deliver samples, but may lose them if the network is not robust.
* Reliable: guarantee that samples are delivered, may retry multiple times.
* *Best effort*: attempt to deliver samples, but may lose them if the network is not robust.
* *Reliable*: guarantee that samples are delivered, may retry multiple times.

* Durability

* Transient local: the publisher becomes responsible for persisting samples for "late-joining" subscribers.
* Volatile: no attempt is made to persist samples.
* *Transient local*: the publisher becomes responsible for persisting samples for “late-joining” subscriptions.
* *Volatile*: no attempt is made to persist samples.

* Deadline

* *Duration*: the expected maximum amount of time between subsequent messages being published to a topic

* Lifespan

For each of the policies there is also the option of “system default”, which uses the default of the underlying middleware which may be defined via DDS vendor tools (e.g. XML configuration files).
DDS itself has a wider range of policies that can be configured.
These policies have been exposed because of their similarity to features in ROS 1; it is possible that in the future more policies will be exposed in ROS 2.
* *Duration*: the maximum amount of time between the publishing and the reception of a message without the message being considered stale or expired (expired messages are silently dropped and are effectively never received).

* Liveliness

* *Automatic*: the system will consider all of the node’s publishers to be alive for another “lease duration” when any one of its publishers has published a message.
* *Manual by topic*: the system will consider the publisher to be alive for another “lease duration” if it manually asserts that it is still alive (via a call to the publisher API).

* Lease Duration

* *Duration*: the maximum period of time a publisher has to indicate that it is alive before the system considers it to have lost liveliness (losing liveliness could be an indication of a failure).

For each of the policies that is not a duration, there is also the option of “system default”, which uses the default of the underlying middleware.
For each of the policies that is a duration, there also exists a “default” option that means the duration is unspecified, which the underlying middleware will usually interpret as an infinitely long duration.

Comparison to ROS 1
^^^^^^^^^^^^^^^^^^^

The history and depth policies in ROS 2 combine to provide functionality akin to the queue size in ROS 1.
The history and depth policies in ROS 2 combine to provide functionality akin to the queue size in ROS 1.

The reliability policy in ROS 2 is akin to the use of either UDPROS (only in ``roscpp``\ ) for "best effort", or TCPROS (ROS 1 default) for reliable.
The reliability policy in ROS 2 is akin to the use of either UDPROS (only in ``roscpp``) for best effort, or TCPROS (ROS 1 default) for reliable.
Note however that even the reliable policy in ROS 2 is implemented using UDP, which allows for multicasting if appropriate.

The durability policy combined with a depth of 1 provides functionality similar to that of "latching" subscribers.
The “durability” policy “transient local”, combined with any depth, provides functionality similar to that of “latching” publishers.
The remaining policies in ROS 2 are not akin to anything that is available in ROS 1, meaning that ROS 2 is more featureful than ROS 1 in this respect.
It is possible that in the future, even more QoS policies will be available in ROS 2.


QoS profiles
------------

Profiles allow developers to focus on their applications without worrying about every QoS setting possible.
A QoS profile defines a set of policies that are expected to go well together for a particular use case.

The currently-defined QoS profiles are:
The currently defined QoS profiles are:

* Default QoS settings for publishers and subscriptions

* Default QoS settings for publishers and subscribers

In order to make the transition from ROS 1 to ROS 2, exercising a similar network behavior is desirable.
By default, publishers and subscribers are reliable in ROS 2, have volatile durability, and "keep last" history.
In order to make the transition from ROS 1 to ROS 2 easier, exercising a similar network behavior is desirable.
By default, publishers and subscriptions in ROS 2 have “keep last” for history with a queue size of 10, “reliable” for reliability, “volatile” for durability, and “system default” for liveliness.
Deadline, lifespan, and lease durations are also all set to “default”.

* Services

In the same vein as publishers and subscribers, services are reliable.
In the same vein as publishers and subscriptions, services are reliable.
It is especially important for services to use volatile durability, as otherwise service servers that re-start may receive outdated requests.
While the client is protected from receiving multiple responses, the server is not protected from side-effects of receiving the outdated requests.

* Sensor data

For sensor data, in most cases it's more important to receive readings in a timely fashion, rather than ensuring that all of them arrive.
For sensor data, in most cases its more important to receive readings in a timely fashion, rather than ensuring that all of them arrive.
That is, developers want the latest samples as soon as they are captured, at the expense of maybe losing some.
For that reason the sensor data profile uses best effort reliability and a smaller queue depth.
For that reason the sensor data profile uses best effort reliability and a smaller queue size.

* Parameters

Expand All @@ -91,80 +111,193 @@ The currently-defined QoS profiles are:

* System default

This uses the RMW implementation's default values for all of the policies.
This uses the RMW implementations default values for all of the policies.
Different RMW implementations may have different defaults.

`Click here <https://github.com/ros2/rmw/blob/release-latest/rmw/include/rmw/qos_profiles.h>`__ for the specific policies in use for the above profiles.
`Click here <https://github.com/ros2/rmw/blob/master/rmw/include/rmw/qos_profiles.h>`__ for the specific policies in use for the above profiles.
The settings in these profiles are subject to further tweaks, based on the feedback from the community.

While ROS 2 provides some QoS profiles for common use cases, the use of policies that are defined in DDS allows ROS users to take advantage of the vast knowledge base of existing DDS documentation for configuring QoS profiles for their specific use case.

QoS compatibilities
-------------------

**Note:** This section refers to publisher and subscribers but the content applies to service servers and clients in the same manner.
**Note:** This section refers to publisher and subscriptions but the content applies to service servers and clients in the same manner.

QoS profiles may be configured for publishers and subscriptions independently.
A connection between a publisher and a subscription is only made if the pair has compatible QoS profiles.

QoS profiles may be configured for publishers and subscribers independently.
A connection between a publisher and a subscriber is only made if the pair has compatible QoS profiles.
QoS profile compatibility is determined based on a "Request vs Offerer" model, wherein connections are only made if the requested policy of the subscriber is not more stringent than the that of the publisher.
The less strict of the two policies will be the one used for the connection.
QoS profile compatibility is determined based on a “Request vs Offered” model.
Subscriptions *request* a QoS profile that is the “minimum quality” that it is willing to accept, and publishers *offer* a QoS profile that is the “maximum quality” that it is able to provide.
Connections are only made if every policy of the requested QoS profile is not more stringent than that of the offered QoS profile.
Multiple subscriptions can be connected to a single publisher simultaneously even if their requested QoS profiles are different.
The compatibility between a publisher and a subscription is unaffected by the presence of other publishers and subscriptions.

The QoS policies exposed in ROS 2 that affect compatibility are the durability and reliability policies.
The following tables show the compatibility of the different policy settings and the result:

*Compatibility of QoS durability profiles:*
*Compatibility of reliability QoS policies:*

.. list-table::
:header-rows: 1

* - Publisher
- Subscription
- Compatible
* - Best effort
- Best effort
- Yes
* - Best effort
- Reliable
- No
* - Reliable
- Best effort
- Yes
* - Reliable
- Reliable
- Yes

*Compatibility of durability QoS policies:*

.. list-table::
:header-rows: 1

* - Publisher
- Subscriber
- Connection
- Result
- Subscription
- Compatible
* - Volatile
- Volatile
- Yes
- Volatile
* - Volatile
- Transient local
- No
- -
* - Transient local
- Volatile
- Yes
- Volatile
* - Transient local
- Transient local
- Yes
- Transient local

*Compatibility of deadline QoS policies:*
Copy link
Contributor

@maryaB-osr maryaB-osr May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some value in adding a simple key, maybe just for the tables that use symbols or maybe for the entire table section. Something like

x, y = arbitrary custom value
● = undefined (?)

Copy link
Member Author

@mm318 mm318 May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a short description of x and y and removed appearances of (which were meant to represent N/A).


*Compatibility of QoS reliability profiles:*
Assume *x* and *y* are arbitrary valid duration values.

.. list-table::
:header-rows: 1

* - Publisher
- Subscriber
- Connection
- Result
* - Best effort
- Best effort
- Subscription
- Compatible
* - Default
- Default
- Yes
- Best effort
* - Best effort
- Reliable
* - Default
- *x*
- No
- -
* - Reliable
- Best effort
* - *x*
- Default
- Yes
- Best effort
* - Reliable
- Reliable
* - *x*
- *x*
- Yes
* - *x*
- *y* (where *y* > *x*)
- Yes
* - *x*
- *y* (where *y* < *x*)
- No

*Compatibility of liveliness QoS policies:*

.. list-table::
:header-rows: 1

* - Publisher
- Subscription
- Compatible
* - Automatic
- Automatic
- Yes
* - Automatic
- Manual by topic
- No
* - Manual by topic
- Automatic
- Yes
* - Manual by topic
- Manual by topic
- Yes
- Reliable

*Compatibility of lease duration QoS policies:*

Assume *x* and *y* are arbitrary valid duration values.

.. list-table::
:header-rows: 1

* - Publisher
- Subscription
- Compatible
* - Default
- Default
- Yes
* - Default
- *x*
- No
* - *x*
- Default
- Yes
* - *x*
- *x*
- Yes
* - *x*
- *y* (where *y* > *x*)
- Yes
* - *x*
- *y* (where *y* < *x*)
- No

In order for a connection to be made, all of the policies that affect compatibility must be compatible.
That is, even if a publisher-subscriber pair has compatible reliability QoS profiles, if they have incompatible durability QoS profiles a connection will not be made, and vice-versa.
For example, even if a requested and offered QoS profile pair has compatible reliability QoS policies, but they have incompatible durability QoS policies, a connection will still not be made.

When connections are not made, no messages will be passed between the publisher and subscription.
There are mechanisms to detect this situation, which will be covered in a later section.

Comparison to ROS 1
^^^^^^^^^^^^^^^^^^^

Historically in ROS 1, any publisher and subscriber with the same message type on the same topic would be connected.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misunderstanding the context but it seems like you changed every other "subscriber" to "subscription"; maybe you missed this one?

Suggested change
Historically in ROS 1, any publisher and subscriber with the same message type on the same topic would be connected.
Historically in ROS 1, any publisher and subscription with the same message type on the same topic would be connected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to use "subscriber" when referencing ROS 1, but "subscription" when referring to ROS 2.

The possibility of incompatible requested and offered QoS profiles is something new to be aware of when using ROS 2.


QoS events
----------

Some QoS policies have possible events related to them.
Developers may provide each publisher and subscription with callback functions that are triggered by these QoS events and handle them in a way they see fit, similar to how messages received on a topic are handled.

Developers may subscribe to the following QoS events that are associated with a publisher:

* Offered deadline missed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little unclear here which callbacks apply to which objects, maybe split this out into a "Subcription Callbacks" and "Publisher Callbacks" section? Are there callbacks that are common to both, or are there just matching pairs for each?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are just matching pairs, although the callbacks of each pair are very similar to each other.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have split the list into two separate lists, one for publisher callbacks and one for subscription callbacks.


The publisher has not published a message within the expected duration that was set out by the deadline QoS policy.

* Liveliness lost

The publisher has failed to indicate its liveliness within the lease duration.

* Offered incompatible QoS

The publisher has encountered a subscription on the same topic that is requesting a QoS profile that the offered QoS profile cannot satisfy, resulting in no connection between the publisher and that subscription.

Developers may subscribe to the following QoS events that are associated with a subscription:

* Requested deadline missed

The subscription has not received a message within the expected duration that was set out by the deadline QoS policy.

* Liveliness changed

The subscription has noticed that one or more publishers on the subscribed topic has failed to indicate their liveliness within the lease duration.

* Requested incompatible QoS

The subscription has encountered a publisher on the same topic that is offering a QoS profile that does not satisfy the requested QoS profile, resulting in no connection between the subscription and that publisher.