C++ Question: SampleInfo::reception_timestamp() not available?

4 posts / 0 new
Last post
Offline
Last seen: 4 years 5 months ago
Joined: 03/12/2018
Posts: 32
C++ Question: SampleInfo::reception_timestamp() not available?

I'm using DDS 5.3.0.3, programming in modern C++.  I'm writing an application to subscribe to data.  I'd like to observe the timestamps - both send-time and receive-time.

I'm able to access the send-time, but the receive-time fails to compile:

 

200: auto samples = dataReader_[index].take();
201: for (auto & samp : samples)
202: {
203:     if (samp.info().valid())
204:     {
205:         dds::core::Time currSendTime = samp.info().source_timestamp();
206:         dds::core::Time currReceiveTime = samp.info().reception_timestamp();

The compile error is:

RxController.cpp:206:75: error: 'const InfoType {aka const class dds::sub::TSampleInfo<rti::sub::SampleInfoImpl>}' has no member named 'reception_timestamp'; did you mean 'source_timestamp'?
| dds::core::Time currReceiveTime = samp.info().reception_timestamp();
| ^~~~~~~~~~~~~~~~~~~

Looking in the SampleInfoImpl.hpp and TSampleInfo.hpp, I can see that "reception_timestamp() is treated as an "extension".  It is in SampleInfoImpl.hpp but not TSampleInfo.hpp.

Am I making a silly mistake here?

 

 

Offline
Last seen: 4 years 5 months ago
Joined: 03/12/2018
Posts: 32

I was able to fix this with some code additions in the TSamplInfo header:

 

--- include/ndds/hpp/dds/sub/TSampleInfo.hpp
+++ include/ndds/hpp/dds/sub/TSampleInfo.hpp
@@ -61,6 +61,14 @@ public:
 }
 /**
+ * @brief Get the timestamp when the sample was received by a DataReader.
+ */
+ dds::core::Time reception_timestamp() const
+ {
+ return this->delegate().reception_timestamp();
+ }
+
+ /**
 * @brief Get the dds::sub::status::DataState of the sample.
 *
 * The DataState encapsulates the sample's dds::sub::status::InstanceState,
Offline
Last seen: 4 years 5 months ago
Joined: 03/12/2018
Posts: 32

I am rather unhappy that I had to change DDS header code to get a documented "reception timestamp" feature (althougn it is documented as an RTI extension to DDS...).  I feel this puts me into the territory of "unsupported"

Is there an alternative (supported) solution to allow me to get the reception timestamp?  Should I file a support request to have RTI fix the code?  Or am I just looking in the wrong place, and the data is available in some other [supported] way?

 

 

 

Offline
Last seen: 2 months 3 weeks ago
Joined: 04/02/2013
Posts: 196

Hi,

SampleInfo::reception_timestamp() is an RTI extension (it's not DDS-standard). To access extension member functions, you need to use the overloaded arrow (->) operator, as described in the API reference here.

This is how your code would look like after this change:

dds::core::Time currSendTime = samp.info().source_timestamp();
dds::core::Time currReceiveTime = samp.info()->reception_timestamp();

I hope this helps,

Alex