Skip to content

Commit

Permalink
mavlink: timesync: readd timesync_status uORB to report Mavlink timesync
Browse files Browse the repository at this point in the history
  • Loading branch information
TSC21 committed Mar 9, 2020
1 parent fef82f8 commit a61b7fe
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion msg/templates/urtps/RtpsTopics.cpp.em
Expand Up @@ -169,10 +169,10 @@ bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
// apply timestamp offset
_timesync->addOffset(msg.timestamp());
msg.serialize(scdr);
ret = true;
@[ if topic == 'Timesync' or topic == 'timesync']@
}
@[ end if]@
ret = true;
_@(topic)_sub.unlockMsg();
}
break;
Expand Down
15 changes: 5 additions & 10 deletions msg/timesync.msg
@@ -1,10 +1,5 @@
uint64 timestamp # time since system start (microseconds)
uint8 sys_id # id of the origin system
uint8 seq # timesync msg sequence
int64 tc1 # time sync timestamp 1
int64 ts1 # time sync timestamp 2

uint64 remote_timestamp # remote system timestamp (microseconds)
int64 observed_offset # raw time offset directly observed from this timesync packet (microseconds)
int64 estimated_offset # smoothed time offset between companion system and PX4 (microseconds)
uint32 round_trip_time # round trip time of this timesync packet (microseconds)
uint64 timestamp # time since system start (microseconds)
uint8 sys_id # id of the origin system
uint8 seq # timesync msg sequence
int64 tc1 # time sync timestamp 1
int64 ts1 # time sync timestamp 2
5 changes: 5 additions & 0 deletions msg/timesync_status.msg
@@ -0,0 +1,5 @@
uint64 timestamp # time since system start (microseconds)
uint64 remote_timestamp # remote system timestamp (microseconds)
int64 observed_offset # raw time offset directly observed from this timesync packet (microseconds)
int64 estimated_offset # smoothed time offset between companion system and PX4 (microseconds)
uint32 round_trip_time # round trip time of this timesync packet (microseconds)
2 changes: 2 additions & 0 deletions msg/tools/uorb_rtps_message_ids.yaml
Expand Up @@ -291,6 +291,8 @@ rtps:
id: 129
- msg: vehicle_trajectory_bezier
id: 130
- msg: timesync_status
id: 131
########## multi topics: begin ##########
- msg: actuator_controls_0
id: 150
Expand Down
4 changes: 2 additions & 2 deletions src/modules/mavlink/mavlink_timesync.cpp
Expand Up @@ -138,15 +138,15 @@ MavlinkTimesync::handle_message(const mavlink_message_t *msg)
}

// Publish status message
timesync_s tsync_status{};
timesync_status_s tsync_status{};

tsync_status.timestamp = hrt_absolute_time();
tsync_status.remote_timestamp = tsync.tc1 / 1000ULL;
tsync_status.observed_offset = offset_us;
tsync_status.estimated_offset = (int64_t)_time_offset;
tsync_status.round_trip_time = rtt_us;

_timesync_pub.publish(tsync_status);
_timesync_status_pub.publish(tsync_status);
}

break;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/mavlink/mavlink_timesync.h
Expand Up @@ -43,7 +43,7 @@
#include "mavlink_bridge_header.h"

#include <uORB/PublicationMulti.hpp>
#include <uORB/topics/timesync.h>
#include <uORB/topics/timesync_status.h>

#include <drivers/drv_hrt.h>

Expand Down Expand Up @@ -132,7 +132,7 @@ class MavlinkTimesync
*/
void reset_filter();

uORB::PublicationMulti<timesync_s> _timesync_pub{ORB_ID(timesync)};
uORB::PublicationMulti<timesync_status_s> _timesync_status_pub{ORB_ID(timesync_status)};

uint32_t _sequence{0};

Expand Down

0 comments on commit a61b7fe

Please sign in to comment.