mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 02:36:37 +08:00
fix(bmp280): correct timestamp_sample to integration midpoint
The BMP280 pressure measurement is integrated over _measure_interval (~43ms at 16x pressure / 2x temperature oversampling). The read time corresponds to the end of the integration window, introducing a systematic timing bias. Correct timestamp_sample to the midpoint by subtracting measurement_time / 2.
This commit is contained in:
@@ -144,8 +144,12 @@ BMP280::collect()
|
|||||||
|
|
||||||
_collect_phase = false;
|
_collect_phase = false;
|
||||||
|
|
||||||
// this should be fairly close to the end of the conversion, so the best approximation of the time
|
/* Correct for measurement integration delay: the pressure was
|
||||||
const hrt_abstime timestamp_sample = hrt_absolute_time();
|
* integrated over the preceding _measure_interval window, so the
|
||||||
|
* effective sample midpoint is half the measurement time before now. */
|
||||||
|
const hrt_abstime now = hrt_absolute_time();
|
||||||
|
const hrt_abstime half_meas = _measure_interval / 2;
|
||||||
|
const hrt_abstime timestamp_sample = (now > half_meas) ? (now - half_meas) : now;
|
||||||
bmp280::data_s *data = _interface->get_data(BMP280_ADDR_DATA);
|
bmp280::data_s *data = _interface->get_data(BMP280_ADDR_DATA);
|
||||||
|
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user