66 int64_t offset_ns = (tsync.
ts1 + now_ns - 2*tsync.
tc1) / 2;
71 ROS_INFO(
"Detected time offset of %0.3f s.", offset_ns/1e9);
72 ROS_DEBUG(
"FCU time: %0.3f, System time: %0.3f", tsync.
tc1*1e-9, tsync.
ts1*1e-9);
88 int64_t boot_ns = (int64_t)boot_ms*1000000;
93 ROS_ERROR_THROTTLE(1,
"negative time calculated from FCU: boot_ns=%ld, offset_ns=%ld. Using system time",
107 int64_t boot_ns = (int64_t) boot_us * 1000;
112 ROS_ERROR_THROTTLE(1,
"negative time calculated from FCU: boot_ns=%ld, offset_ns=%ld. Using system time",
113 boot_ns, offset_ns_);
123 mavlink_message_t msg;
static void mavlink_msg_timesync_decode(const mavlink_message_t *msg, mavlink_timesync_t *timesync)
Decode a timesync message into a struct.
Time & fromNSec(uint64_t t)
#define MAVLINK_MSG_ID_TIMESYNC
void register_mavlink_listener(MavlinkListenerInterface *const listener)
Register a listener for mavlink messages.
void timer_callback(const ros::TimerEvent &event)
TimeManager(MavlinkComm *comm)
#define ROS_ERROR_THROTTLE(period,...)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
ros::Time get_ros_time_ms(uint32_t boot_ms)
virtual void handle_mavlink_message(const mavlink_message_t &msg)
The handler function for mavlink messages to be implemented by derived classes.
ros::Time get_ros_time_us(uint64_t boot_us)
ros::Timer time_sync_timer_
void send_message(const mavlink_message_t &msg)
Send a mavlink message.
static uint16_t mavlink_msg_timesync_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, int64_t tc1, int64_t ts1)
Pack a timesync message.