PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <mavlink_timesync.h>
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 &) | |
MavlinkTimesync & | operator= (const MavlinkTimesync &) |
Definition at line 97 of file mavlink_timesync.h.
|
explicit |
Definition at line 46 of file mavlink_timesync.cpp.
|
default |
|
private |
|
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().
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().
|
private |
|
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().
|
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().
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().
|
protected |
Definition at line 144 of file mavlink_timesync.h.
Referenced by add_sample(), handle_message(), and reset_filter().
|
protected |
Definition at line 145 of file mavlink_timesync.h.
Referenced by add_sample(), handle_message(), and reset_filter().
|
protected |
Definition at line 148 of file mavlink_timesync.h.
Referenced by handle_message(), and reset_filter().
|
protected |
Definition at line 149 of file mavlink_timesync.h.
Referenced by handle_message(), and reset_filter().
|
protected |
Definition at line 151 of file mavlink_timesync.h.
Referenced by handle_message().
|
protected |
Definition at line 137 of file mavlink_timesync.h.
Referenced by add_sample(), handle_message(), reset_filter(), and sync_converged().
|
protected |
Definition at line 140 of file mavlink_timesync.h.
Referenced by add_sample(), handle_message(), reset_filter(), and sync_stamp().
|
protected |
Definition at line 141 of file mavlink_timesync.h.
Referenced by add_sample(), and reset_filter().
|
protected |
Definition at line 135 of file mavlink_timesync.h.
Referenced by handle_message().