Add PPS capture message to logged topics, simplify timestamp logic and small cleanup

This commit is contained in:
Michael Schaeuble
2021-12-17 07:56:08 +01:00
committed by Beat Küng
parent 5ad8b84dec
commit 064a602962
6 changed files with 12 additions and 18 deletions
+3 -5
View File
@@ -99,14 +99,12 @@ void PPSCapture::Run()
pps_capture_s pps_capture;
pps_capture.timestamp = _hrt_timestamp;
// GPS UTC time when the GPIO interrupt was triggered
// UTC time + elapsed time since the UTC time was received - eleapsed time since the PPS interrupt
// event
uint64_t gps_utc_time = _last_gps_utc_timestamp + hrt_elapsed_time(&_last_gps_timestamp)
- hrt_elapsed_time(&_hrt_timestamp);
// Last UTC time received from the GPS + elapsed time to the PPS interrupt
uint64_t gps_utc_time = _last_gps_utc_timestamp + (_hrt_timestamp - _last_gps_timestamp);
// (For ubx F9P) The rising edge of the PPS pulse is aligned to the top of second GPS time base.
// So, remove the fraction of second and shift to the next second. The interrupt is triggered
// before the matching timestamp tranfered, which means the last received GPS time is always
// before the matching timestamp is received via a UART message, which means the last received GPS time is always
// behind.
pps_capture.rtc_timestamp = gps_utc_time - (gps_utc_time % USEC_PER_SEC) + USEC_PER_SEC;
+2 -5
View File
@@ -73,12 +73,9 @@ private:
uORB::Publication<pps_capture_s> _pps_capture_pub{ORB_ID(pps_capture)};
uORB::Subscription _sensor_gps_sub{ORB_ID(sensor_gps)};
static constexpr unsigned USEC_IN_1_SEC{1000000}; // microseconds in 1 second
static constexpr unsigned MAX_POSITIVE_DRIFT{USEC_IN_1_SEC / 2}; // microseconds
hrt_abstime _hrt_timestamp{0};
uint64_t _last_gps_timestamp{0};
uint64_t _last_gps_utc_timestamp{0};
hrt_abstime _last_gps_timestamp{0};
uint64_t _last_gps_utc_timestamp{0};
};