mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 08:03:34 +08:00
Add PPS capture message to logged topics, simplify timestamp logic and small cleanup
This commit is contained in:
committed by
Beat Küng
parent
5ad8b84dec
commit
064a602962
@@ -193,10 +193,8 @@ CameraCapture::publish_trigger()
|
||||
|
||||
|
||||
if (_pps_hrt_timestamp > 0) {
|
||||
// Current RTC time (RTC time captured by the PPS module + elapsed time since capture)
|
||||
uint64_t gps_utc_time = _pps_rtc_timestamp + hrt_elapsed_time(&_pps_hrt_timestamp);
|
||||
// Current RTC time - elapsed time since capture interrupt event
|
||||
trigger.timestamp_utc = gps_utc_time - hrt_elapsed_time(&trigger.timestamp);
|
||||
// Last PPS RTC time + elapsed time to the camera capture interrupt
|
||||
trigger.timestamp_utc = _pps_rtc_timestamp + (trigger.timestamp - _pps_hrt_timestamp);
|
||||
|
||||
} else {
|
||||
// No PPS capture received, use RTC clock as fallback
|
||||
|
||||
@@ -132,8 +132,8 @@ private:
|
||||
hrt_abstime _last_trig_time{0};
|
||||
uint32_t _capture_overflows{0};
|
||||
|
||||
uint64_t _pps_hrt_timestamp{0};
|
||||
uint64_t _pps_rtc_timestamp{0};
|
||||
hrt_abstime _pps_hrt_timestamp{0};
|
||||
uint64_t _pps_rtc_timestamp{0};
|
||||
|
||||
// Signal capture callback
|
||||
void capture_callback(uint32_t chan_index, hrt_abstime edge_time, uint32_t edge_state, uint32_t overflow);
|
||||
|
||||
@@ -174,8 +174,8 @@ private:
|
||||
bool _turning_on{false};
|
||||
matrix::Vector2f _last_shoot_position{0.f, 0.f};
|
||||
bool _valid_position{false};
|
||||
uint64_t _pps_hrt_timestamp{0};
|
||||
uint64_t _pps_rtc_timestamp{0};
|
||||
hrt_abstime _pps_hrt_timestamp{0};
|
||||
uint64_t _pps_rtc_timestamp{0};
|
||||
|
||||
//Camera Auto Mount Pivoting Oblique Survey (CAMPOS)
|
||||
uint32_t _CAMPOS_num_poses{0};
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
};
|
||||
|
||||
@@ -172,6 +172,7 @@ void LoggedTopics::add_default_topics()
|
||||
add_optional_topic_multi("sensor_accel", 1000, 4);
|
||||
add_optional_topic_multi("sensor_baro", 1000, 4);
|
||||
add_topic_multi("sensor_gps", 1000, 2);
|
||||
add_topic("pps_capture", 1000);
|
||||
add_optional_topic_multi("sensor_gyro", 1000, 4);
|
||||
add_optional_topic_multi("sensor_mag", 1000, 4);
|
||||
add_topic_multi("vehicle_imu", 500, 4);
|
||||
|
||||
Reference in New Issue
Block a user