Skip to content

Commit

Permalink
Fix non-defined duration Qos in configuration example (#5001)
Browse files Browse the repository at this point in the history
* Refs #19563: Fix Durability QoS setup in configuration example

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #19563: Update Readme with default values

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: JesusPoderoso <[email protected]>
  • Loading branch information
JesusPoderoso authored Jul 9, 2024
1 parent 9b09ada commit 252ff37
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 19 deletions.
10 changes: 5 additions & 5 deletions examples/cpp/configuration/CLIParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class CLIParser
int32_t max_samples = 5000;
int32_t max_instances = 10;
int32_t max_samples_per_instance = 400;
uint32_t deadline = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t lifespan = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t liveliness_lease = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t liveliness_assert = fastdds::Duration_t::INFINITE_SECONDS - 1;
uint32_t deadline = 0;
uint32_t lifespan = 0;
uint32_t liveliness_lease = 0;
uint32_t liveliness_assert = 0;
std::string partitions = "";
std::string profile_participant = "";
std::string topic_name = "configuration_topic";
Expand Down Expand Up @@ -76,7 +76,7 @@ class CLIParser
struct publisher_config : public entity_config
{
uint16_t wait = 0;
uint32_t ack_keep_duration = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t ack_keep_duration = 0;
uint32_t interval = 100;
uint32_t msg_size = 10;
uint32_t ownership_strength = 0;
Expand Down
30 changes: 22 additions & 8 deletions examples/cpp/configuration/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,30 @@ PublisherApp::PublisherApp(
"DataWriter initialization failed: ownership strength is only valid with exclusive ownership");
}
writer_qos.ownership_strength().value = config.ownership_strength;
writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
if (config.deadline > 0)
{
writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
}
writer_qos.reliable_writer_qos().disable_positive_acks.enabled = config.disable_positive_ack;
writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t(
config.ack_keep_duration * 1e-3);
writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
if (config.ack_keep_duration > 0)
{
writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t(
config.ack_keep_duration * 1e-3);
}
if (config.lifespan > 0)
{
writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
}
writer_qos.liveliness().kind = config.liveliness;
writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(
config.liveliness_lease * 1e-3);
writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
if (config.liveliness_lease > 0)
{
writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3);
}
if (config.liveliness_assert > 0)
{
writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
}
writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all());
}
else
Expand Down
7 changes: 7 additions & 0 deletions examples/cpp/configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Otherwise, the entities are considered incompatible (and they will not match).
The argument **``-i``** ``<period>`` or **``--interval``** ``<period>`` configures the **publisher** application with the sending samples period (in milliseconds).
It should be always **greater** than the deadline period, otherwise ``on_offered_deadline_missed`` will be triggered any time a sample is sent.

If **``--deadline``** is not configured, it takes the _eProsima Fast DDS_ default value (infinite).

## Disable positive ACKs QoS

Using argument **``--disable-positive-ack``** will configure the corresponding endpoint to **not** exchange positive acknowledge messages.
Expand Down Expand Up @@ -172,6 +174,8 @@ The following table represents the compatibility matrix (compatible ✔️ vs in

The argument **``--ack-keep-duration``** ``<duration>`` configures the **publisher** application with the duration (in milliseconds) it keeps the data before considering it as acknowledged.

If **``--ack-keep-duration``** is not configured, it takes the _eProsima Fast DDS_ default value (infinite).

## Durability QoS

Using argument **``--transient-local``** will configure the corresponding endpoint with **``TRANSIENT_LOCAL``** durability QoS.
Expand Down Expand Up @@ -282,6 +286,9 @@ The following table represents the compatibility matrix (compatible ✔️ vs in
The argument **``-i``** ``<period>`` or **``--interval``** ``<period>`` configures the **publisher** application with the sending samples period (in milliseconds).
It should be always **lower** than the liveliness lease duration, otherwise liveliness will be lost after sending each sample and recovered when sending the next sample.


If **``--liveliness``** or **``--liveliness-assert``** are not configured, they take the _eProsima Fast DDS_ default values (infinite).

## Ownership QoS

Using argument **``-o``** or **``--ownership``** will configure the corresponding endpoint with **``EXCLUSIVE``** [ownership QoS kind](https://fast-dds.docs.eprosima.com/en/latest/fastdds/dds_layer/core/policy/standardQosPolicies.html#ownershipqospolicykind).
Expand Down
23 changes: 17 additions & 6 deletions examples/cpp/configuration/SubscriberApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,25 @@ SubscriberApp::SubscriberApp(
reader_qos.resource_limits().max_instances = config.max_instances;
reader_qos.resource_limits().max_samples_per_instance = config.max_samples_per_instance;
reader_qos.ownership().kind = config.ownership;
reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
if (config.deadline > 0)
{
reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
}
reader_qos.reliable_reader_qos().disable_positive_acks.enabled = config.disable_positive_ack;
reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
if (config.lifespan > 0)
{
reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
}
reader_qos.liveliness().kind = config.liveliness;
reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(
config.liveliness_lease * 1e-3);
reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
if (config.liveliness_lease > 0)
{
reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3);
}
if (config.liveliness_assert > 0)
{
reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
}
reader_ = subscriber_->create_datareader(topic_, reader_qos, this, StatusMask::all());
}
else
Expand Down

0 comments on commit 252ff37

Please sign in to comment.