-
Notifications
You must be signed in to change notification settings - Fork 21
Description
I am having an issue using the source_timestamp and reception_timestamp on a SampleInfo instance retrieved via fastdds.DataReader.take(). Specifically, I want to call to_ns() on the source_timestamp and reception_timestamp and am getting the following error. I have outlined my findings below and would appreciate any help!
terminate called after throwing an instance of 'Swig::DirectorMethodException'
what(): SWIG director method error. In method 'on_data_available': AttributeError: 'SwigPyObject' object has no attribute 'to_ns'
I have created the following function, get_data(), which is being used in the callback function to a SubscriberListener class I've created, which overrides the on_data_available( ) method of the fastdds.DataReader.
def get_data(data: fastdds.LoanableCollection, reader: fastdds.DataReader):
infos: fastdds.SampleInfoSeq = fastdds.SampleInfoSeq()
ret: fastdds.ReturnCode_t = reader.take(data, infos)
if ret == fastdds.ReturnCode_t.RETCODE_OK:
return (data, infos)
else:
return None
def callback(reader: fastdds.DataReader):
data_seq = GeneratedClassSeq()
data = get_data(data_seq, reader)
reception_ns = data[1][0].reception_timestamp.to_ns() # line that throws error
Now, I've checked the generated python bindings in fastdds.py, and do not understand what the issue is. The SampleInfoSeq class defines that I'm using defines __getItem__(), which I am using to get a SampleInfo instance. The SampleInfo class has properties reception_timestamp and source_timestamp, as defined below, which I am accessing via .reception_timestamp. I'm expecting the resultant object from that call to be of type Time_t, which according to fastdds.py has the to_ns() function, but I cannot properly call it.
From fastdds.py:
class SampleInfo(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
...
source_timestamp = property(_fastdds_python.SampleInfo_source_timestamp_get, _fastdds_python.SampleInfo_source_timestamp_set)
reception_timestamp = property(_fastdds_python.SampleInfo_reception_timestamp_get, _fastdds_python.SampleInfo_reception_timestamp_set)
...
class Time_t(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
INFINITE_SECONDS = _fastdds_python.Time_t_INFINITE_SECONDS
INFINITE_NANOSECONDS = _fastdds_python.Time_t_INFINITE_NANOSECONDS
seconds = property(_fastdds_python.Time_t_seconds_get, _fastdds_python.Time_t_seconds_set)
nanosec = property(_fastdds_python.Time_t_nanosec_get, _fastdds_python.Time_t_nanosec_set)
def __init__(self, *args):
_fastdds_python.Time_t_swiginit(self, _fastdds_python.new_Time_t(*args))
def fraction(self, *args):
return _fastdds_python.Time_t_fraction(self, *args)
def to_ns(self):
return _fastdds_python.Time_t_to_ns(self)
...
Documentation Referenced: