mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
Clamp RTPS -> uorb timestamps to system time
This commit is contained in:
@@ -218,6 +218,7 @@ void micrortps_start_topics(struct timespec &begin, uint64_t &total_read, uint64
|
|||||||
while (0 < (read = transport_node->read(&topic_ID, data_buffer, BUFFER_SIZE)))
|
while (0 < (read = transport_node->read(&topic_ID, data_buffer, BUFFER_SIZE)))
|
||||||
{
|
{
|
||||||
total_read += read;
|
total_read += read;
|
||||||
|
uint64_t read_time = hrt_absolute_time();
|
||||||
switch (topic_ID)
|
switch (topic_ID)
|
||||||
{
|
{
|
||||||
@[for idx, topic in enumerate(recv_topics)]@
|
@[for idx, topic in enumerate(recv_topics)]@
|
||||||
@@ -225,6 +226,11 @@ void micrortps_start_topics(struct timespec &begin, uint64_t &total_read, uint64
|
|||||||
{
|
{
|
||||||
@(receive_base_types[idx])_s @(topic)_data;
|
@(receive_base_types[idx])_s @(topic)_data;
|
||||||
deserialize_@(receive_base_types[idx])(&reader, &@(topic)_data, data_buffer);
|
deserialize_@(receive_base_types[idx])(&reader, &@(topic)_data, data_buffer);
|
||||||
|
if (@(topic)_data.timestamp > read_time)
|
||||||
|
{
|
||||||
|
// don't allow timestamps from the future
|
||||||
|
@(topic)_data.timestamp = read_time;
|
||||||
|
}
|
||||||
pubs->@(topic)_pub.publish(@(topic)_data);
|
pubs->@(topic)_pub.publish(@(topic)_data);
|
||||||
++received;
|
++received;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user