mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
fix(sensors): fix baro publish rate limiter aliasing (#26967)
Use timestamp_sample instead of time_now_us for the rate limiter check to sync to the sensor clock rather than the wall clock. Switch from direct timestamp assignment to epoch-advance (_last_publication_timestamp += interval_us) with a catch-up guard to prevent aliasing artifacts when the sensor sample rate is close to the configured publication rate.
This commit is contained in:
parent
dd2530bb09
commit
047fddbcd8
@ -274,7 +274,7 @@ void VehicleAirData::Run()
|
||||
|
||||
const hrt_abstime timestamp_sample = _timestamp_sample_sum[instance] / _data_sum_count[instance];
|
||||
|
||||
if (time_now_us >= _last_publication_timestamp[instance] + interval_us) {
|
||||
if (timestamp_sample >= _last_publication_timestamp[instance] + interval_us) {
|
||||
|
||||
bool publish = (time_now_us <= timestamp_sample + 1_s);
|
||||
|
||||
@ -312,7 +312,12 @@ void VehicleAirData::Run()
|
||||
_vehicle_air_data_pub.publish(out);
|
||||
}
|
||||
|
||||
_last_publication_timestamp[instance] = time_now_us;
|
||||
// epoch-advance to prevent aliasing; catch up if more than one interval behind
|
||||
_last_publication_timestamp[instance] += interval_us;
|
||||
|
||||
if (timestamp_sample > _last_publication_timestamp[instance] + interval_us) {
|
||||
_last_publication_timestamp[instance] = timestamp_sample;
|
||||
}
|
||||
|
||||
// reset
|
||||
_timestamp_sample_sum[instance] = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user