Skip to content

Commit

Permalink
lib/timesync: relax warnings
Browse files Browse the repository at this point in the history
 - 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)
  • Loading branch information
dagar committed Dec 16, 2023
1 parent 7fa6f4e commit 4b25fad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/lib/timesync/Timesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/lib/timesync/Timesync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

1 comment on commit 4b25fad

@DronecodeBot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/missing-topics-when-using-uxrce-dds-with-raspberry-pi-and-the-latest-firmware-v1-15-0/40892/2

Please sign in to comment.