PX4 Firmware
PX4 Autopilot Software http://px4.io
MavlinkTimesync Class Reference

#include <mavlink_timesync.h>

Collaboration diagram for MavlinkTimesync:

Public Member Functions

 MavlinkTimesync (Mavlink *mavlink)
 
 ~MavlinkTimesync ()=default
 
void handle_message (const mavlink_message_t *msg)
 
uint64_t sync_stamp (uint64_t usec)
 Convert remote timestamp to local hrt time (usec) Use synchronised time if available, monotonic boot time otherwise. More...
 

Protected Member Functions

void add_sample (int64_t offset_us)
 Online exponential filter to smooth time offset. More...
 
bool sync_converged ()
 Return true if the timesync algorithm converged to a good estimate, return false otherwise. More...
 
void reset_filter ()
 Reset the exponential filter and its states. More...
 

Protected Attributes

uORB::PublicationMulti< timesync_status_s_timesync_status_pub {ORB_ID(timesync_status)}
 
uint32_t _sequence {0}
 
double _time_offset {0}
 
double _time_skew {0}
 
double _filter_alpha {ALPHA_GAIN_INITIAL}
 
double _filter_beta {BETA_GAIN_INITIAL}
 
uint32_t _high_deviation_count {0}
 
uint32_t _high_rtt_count {0}
 
Mavlink *const _mavlink
 

Private Member Functions

 MavlinkTimesync (MavlinkTimesync &)
 
MavlinkTimesyncoperator= (const MavlinkTimesync &)
 

Detailed Description

Definition at line 97 of file mavlink_timesync.h.

Constructor & Destructor Documentation

◆ MavlinkTimesync() [1/2]

MavlinkTimesync::MavlinkTimesync ( Mavlink mavlink)
explicit

Definition at line 46 of file mavlink_timesync.cpp.

◆ ~MavlinkTimesync()

MavlinkTimesync::~MavlinkTimesync ( )
default

◆ MavlinkTimesync() [2/2]

MavlinkTimesync::MavlinkTimesync ( MavlinkTimesync )
private

Member Function Documentation

◆ add_sample()

void MavlinkTimesync::add_sample ( int64_t  offset_us)
protected

Online exponential filter to smooth time offset.

Definition at line 203 of file mavlink_timesync.cpp.

References _filter_alpha, _filter_beta, _sequence, _time_offset, and _time_skew.

Referenced by handle_message().

Here is the caller graph for this function:

◆ handle_message()

void MavlinkTimesync::handle_message ( const mavlink_message_t *  msg)

Definition at line 52 of file mavlink_timesync.cpp.

References _filter_alpha, _filter_beta, _high_deviation_count, _high_rtt_count, _mavlink, _sequence, _time_offset, _timesync_status_pub, add_sample(), ALPHA_GAIN_FINAL, ALPHA_GAIN_INITIAL, BETA_GAIN_FINAL, BETA_GAIN_INITIAL, CONVERGENCE_WINDOW, Mavlink::get_channel(), hrt_absolute_time(), MAX_CONSECUTIVE_HIGH_DEVIATION, MAX_CONSECUTIVE_HIGH_RTT, MAX_DEVIATION_SAMPLE, MAX_RTT_SAMPLE, uORB::PublicationMulti< T >::publish(), PX4_EPOCH_SECS, reset_filter(), sync_converged(), and timesync_status_s::timestamp.

Referenced by MavlinkReceiver::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

MavlinkTimesync& MavlinkTimesync::operator= ( const MavlinkTimesync )
private

◆ reset_filter()

void MavlinkTimesync::reset_filter ( )
protected

Reset the exponential filter and its states.

Definition at line 226 of file mavlink_timesync.cpp.

References _filter_alpha, _filter_beta, _high_deviation_count, _high_rtt_count, _sequence, _time_offset, _time_skew, ALPHA_GAIN_INITIAL, and BETA_GAIN_INITIAL.

Referenced by handle_message().

Here is the caller graph for this function:

◆ sync_converged()

bool MavlinkTimesync::sync_converged ( )
protected

Return true if the timesync algorithm converged to a good estimate, return false otherwise.

Definition at line 197 of file mavlink_timesync.cpp.

References _sequence, and CONVERGENCE_WINDOW.

Referenced by handle_message(), and sync_stamp().

Here is the caller graph for this function:

◆ sync_stamp()

uint64_t MavlinkTimesync::sync_stamp ( uint64_t  usec)

Convert remote timestamp to local hrt time (usec) Use synchronised time if available, monotonic boot time otherwise.

Definition at line 185 of file mavlink_timesync.cpp.

References _time_offset, hrt_absolute_time(), and sync_converged().

Referenced by MavlinkReceiver::handle_message_att_pos_mocap(), MavlinkReceiver::handle_message_landing_target(), MavlinkReceiver::handle_message_odometry(), and MavlinkReceiver::handle_message_vision_position_estimate().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _filter_alpha

double MavlinkTimesync::_filter_alpha {ALPHA_GAIN_INITIAL}
protected

Definition at line 144 of file mavlink_timesync.h.

Referenced by add_sample(), handle_message(), and reset_filter().

◆ _filter_beta

double MavlinkTimesync::_filter_beta {BETA_GAIN_INITIAL}
protected

Definition at line 145 of file mavlink_timesync.h.

Referenced by add_sample(), handle_message(), and reset_filter().

◆ _high_deviation_count

uint32_t MavlinkTimesync::_high_deviation_count {0}
protected

Definition at line 148 of file mavlink_timesync.h.

Referenced by handle_message(), and reset_filter().

◆ _high_rtt_count

uint32_t MavlinkTimesync::_high_rtt_count {0}
protected

Definition at line 149 of file mavlink_timesync.h.

Referenced by handle_message(), and reset_filter().

◆ _mavlink

Mavlink* const MavlinkTimesync::_mavlink
protected

Definition at line 151 of file mavlink_timesync.h.

Referenced by handle_message().

◆ _sequence

uint32_t MavlinkTimesync::_sequence {0}
protected

Definition at line 137 of file mavlink_timesync.h.

Referenced by add_sample(), handle_message(), reset_filter(), and sync_converged().

◆ _time_offset

double MavlinkTimesync::_time_offset {0}
protected

Definition at line 140 of file mavlink_timesync.h.

Referenced by add_sample(), handle_message(), reset_filter(), and sync_stamp().

◆ _time_skew

double MavlinkTimesync::_time_skew {0}
protected

Definition at line 141 of file mavlink_timesync.h.

Referenced by add_sample(), and reset_filter().

◆ _timesync_status_pub

uORB::PublicationMulti<timesync_status_s> MavlinkTimesync::_timesync_status_pub {ORB_ID(timesync_status)}
protected

Definition at line 135 of file mavlink_timesync.h.

Referenced by handle_message().


The documentation for this class was generated from the following files: