lib/timesync: relax warnings

- double required max consecutive counts
 - don't continuously complain about round trip time (RTT) unless
   there's been at least one acceptable round trip (latency < 100 ms)
This commit is contained in:
Daniel Agar 2023-12-13 16:05:20 -05:00
parent 7fa6f4e32f
commit 4b25fad862
2 changed files with 4 additions and 7 deletions

View File

@ -66,7 +66,7 @@ void Timesync::update(const uint64_t now_us, const int64_t remote_timestamp_ns,
// We reset the filter if we received 5 consecutive samples which violate our present estimate.
// This is most likely due to a time jump on the offboard system.
if (_high_deviation_count > MAX_CONSECUTIVE_HIGH_DEVIATION) {
PX4_ERR("Time jump detected. Resetting time synchroniser.");
PX4_WARN("time jump detected. Resetting time synchroniser.");
// Reset the filter
reset_filter();
}
@ -103,12 +103,9 @@ void Timesync::update(const uint64_t now_us, const int64_t remote_timestamp_ns,
// Increment counter if round trip time is too high for accurate timesync
_high_rtt_count++;
if (_high_rtt_count > MAX_CONSECUTIVE_HIGH_RTT) {
if (_high_rtt_count == MAX_CONSECUTIVE_HIGH_RTT) {
PX4_WARN("RTT too high for timesync: %llu ms", rtt_us / 1000ULL);
// Reset counter to rate-limit warnings
_high_rtt_count = 0;
}
}
// Publish status message

View File

@ -87,8 +87,8 @@ static constexpr uint32_t CONVERGENCE_WINDOW = 500;
// TODO : automatically determine these using ping statistics?
static constexpr uint64_t MAX_RTT_SAMPLE = 10_ms;
static constexpr uint64_t MAX_DEVIATION_SAMPLE = 100_ms;
static constexpr uint32_t MAX_CONSECUTIVE_HIGH_RTT = 5;
static constexpr uint32_t MAX_CONSECUTIVE_HIGH_DEVIATION = 5;
static constexpr uint32_t MAX_CONSECUTIVE_HIGH_RTT = 10;
static constexpr uint32_t MAX_CONSECUTIVE_HIGH_DEVIATION = 10;
class Timesync
{