Instance-Specific Waitset

3 posts / 0 new
Last post
Offline
Last seen: 3 months 1 week ago
Joined: 06/14/2024
Posts: 4
Instance-Specific Waitset

Hi,

I have an application that is subscribing to data on a specific instance. Code to do this works fine, as per the RTI worked examples:

dds::sub::LoanedSamples<DataType> samples = reader.select().max_samples(1).instance(instance_handle).read();

for (const auto& sample : samples) {
    if (sample.info().valid()) {

        std::cout << "Subscribed to InstanceID: " << sample.data().InstanceID() << std::endl;
        DataType dataOut = sample.data();

    }
}

Prior to this read command, I want my subscriber to wait until new data arrives on that specific instance. From the RTI worked examples, the waitset command to do this is:

status_condition.enabled_statuses(dds::core::status::StatusMask::data_available());
dds::core::cond::WaitSet waitset;
waitset += status_condition;

and then waitset.wait() prior to the code above.

However, (and I could be wrong here as I'm fairly new to DDS), but this waitset condition will trigger if data from any instance is published on the topic. However, I want to write a waitset condition that only triggers if new data from a specific InstanceID arrives on the topic. I have multiple publishers all writing to the same topic, but with different InstanceIDs. Each publisher has a paired subscriber that's only interested in data from that specific InstanceID.

Hopefully that makes sense.

Please can someone point me to the relevant doc page or write a simple example that I can follow?

Thank you :-) !

 

 

Keywords:
Offline
Last seen: 1 month 2 weeks ago
Joined: 04/02/2013
Posts: 196
Howard's picture
Offline
Last seen: 2 days 4 hours ago
Joined: 11/29/2012
Posts: 608

So, I'm not sure what your use case is.  But what you're doing isn't really "subscribing" to an instance of a Topic.  What your code does, and will do with Waitsets and QueryConditions as directed by Alex, is to process data for a specific instance.

The difference?

Well, the DataReader (the actual DDS entity that subscribes to data) will get ALL data for the Topic.  Your code just selectively takes (or reads in your case) data samples for a specific instance.  The data received for other instances are just left in the DataReader's local cache...which will eventually take up more and more memory or get overwritten depending on the DataReader's QoS settings.

If you really wanty your DataReader to only receive data for a single instance (or multiple instances), you should look into Content-Filtered topics...

See:

https://community.rti.com/static/documentation/connext-dds/7.3.0/doc/manuals/connext_dds_professional/users_manual/users_manual/Overview.htm#topics_3596570972_148852