Skip to content
New issue

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

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

Already on GitHub? # to your account

Incorrect behavior with latency budget qos #4580

Open
1 task done
mirusu400 opened this issue Mar 19, 2024 · 1 comment
Open
1 task done

Incorrect behavior with latency budget qos #4580

mirusu400 opened this issue Mar 19, 2024 · 1 comment
Labels
in progress Issue or PR which is being reviewed

Comments

@mirusu400
Copy link

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

According to your documentation, there is a compatibility rule for the latency budget QoS policy. The DataWriter duration must be lower or equal to the DataReader duration.

So, based on the reasons described above, I expected that if I created the DataWriter and DataReader with the QoS described below, the listener would trigger an alert

DataWriterQos wqos = DATAWRITER_QOS_DEFAULT;
wqos.latency_budget().duration = Duration_t(900000000 * 1e-9);

DataReaderQos rqos = DATAREADER_QOS_DEFAULT;
rqos.latency_budget().duration = Duration_t(600000000 * 1e-9);

Current behavior

However, when I run the code, there is no alert.

Steps to reproduce

Here is the sample main.cpp file.

#include "HelloWorldPubSubTypes.h"
#include <unistd.h>

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include <fastrtps/attributes/PublisherAttributes.h>
#include <fastdds/dds/publisher/Publisher.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include <fastdds/dds/publisher/DataWriter.hpp>
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/publisher/DataWriterListener.hpp>
#include <fastrtps/attributes/SubscriberAttributes.h>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/core/status/SubscriptionMatchedStatus.hpp>

using namespace eprosima::fastdds::dds;


class PubListener : public DataWriterListener{
public:
    PubListener()
        : matched_(0)
        , firstConnected_(false)
    {
    }

    void on_offered_incompatible_qos(DataWriter* writer, const OfferedIncompatibleQosStatus& status){
        std::cout << " [ WRITER : on_offered_incompatible_qos ] " << status.last_policy_id << std::endl;
    }

    int matched_;
    bool firstConnected_;

} writer_listener_;

class CustomDataReaderListener : public DataReaderListener{
public:
    CustomDataReaderListener()
        : matched_(0)
        , samples_(0)
    {
    }

    void on_data_available(DataReader* reader){
        SampleInfo info;
        if (reader->take_next_sample(&hello_, &info) == ReturnCode_t::RETCODE_OK){
            if (info.instance_state == ALIVE_INSTANCE_STATE){
                samples_++;
                std::cout << "< READER : on_data_available > reader get message " << hello_.message() << " from " << hello_.index() << " RECEIVED" << std::endl;
            }
        }
    }
    void on_requested_incompatible_qos(DataReader* reader, const RequestedIncompatibleQosStatus& status){
        std::cout << " < READER : on_requested_incompatible_qos > " << status.last_policy_id << std::endl;
    }

    HelloWorld hello_;
    int matched_;
    uint32_t samples_;

} reader_listener_;

int main(){
    DomainParticipantFactory* factory = DomainParticipantFactory::get_instance();

    DomainParticipant* participant_ = factory->create_participant(0, PARTICIPANT_QOS_DEFAULT);

    TypeSupport type_(new HelloWorldPubSubType());
    type_.register_type(participant_);

    Topic* topic_ = participant_->create_topic("Topic1", "HelloWorld", TOPIC_QOS_DEFAULT);

    Publisher* publisher_ = participant_->create_publisher(PUBLISHER_QOS_DEFAULT, nullptr);

    /* setting the writer qos */
    DataWriterQos wqos = DATAWRITER_QOS_DEFAULT;
    wqos.latency_budget().duration = Duration_t(921824426 * 1e-9);

    /* create writer */
    DataWriter* writer_ = publisher_->create_datawriter(topic_, wqos, &writer_listener_);

    Subscriber* subscriber_ = participant_->create_subscriber(SUBSCRIBER_QOS_DEFAULT, nullptr);

    /* setting the reader qos */
    DataReaderQos rqos = DATAREADER_QOS_DEFAULT;
    rqos.latency_budget().duration = Duration_t(604916512 * 1e-9);

    /* create reader */
    DataReader* reader_ = subscriber_->create_datareader(topic_, rqos, &reader_listener_);

    /* wirter write the message */
    HelloWorld hello;
    hello.index(1);
    hello.message("HelloWorld");
    std::cout << "Message: " << hello.message() << " with index: " << hello.index() << " SENT" << std::endl;
    writer_->write(&hello);

    sleep(1);

    if (reader_ != nullptr) subscriber_->delete_datareader(reader_);
    if (writer_ != nullptr) publisher_->delete_datawriter(writer_);
    if (subscriber_ != nullptr) participant_->delete_subscriber(subscriber_);
    if (publisher_ != nullptr) participant_->delete_publisher(publisher_);
    if (topic_ != nullptr) participant_->delete_topic(topic_);
    DomainParticipantFactory::get_instance()->delete_participant(participant_);

    return 0;
}

Here are my PoC project.
fast_dds_latency_budget.zip

Fast DDS version/commit

I checked it with FastDDS v2.11.1, but I think this is still not worked with latest commit (e53a72a)

Platform/Architecture

Ubuntu Focal 20.04 amd64

Transport layer

Default configuration, UDPv4 & SHM, Intra-process

Additional context

No response

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

@mirusu400 mirusu400 added the triage Issue pending classification label Mar 19, 2024
@JesusPoderoso
Copy link
Contributor

Hi @mirusu400, thanks for the report.
We will take a look at it in the following days and come back with some feedback.

@JesusPoderoso JesusPoderoso added in progress Issue or PR which is being reviewed and removed triage Issue pending classification labels Mar 19, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in progress Issue or PR which is being reviewed
Projects
None yet
Development

No branches or pull requests

2 participants