multicopter: minimize dt jitter by using estimate timestamp_sample

This commit is contained in:
Daniel Agar
2021-12-17 17:52:28 -05:00
parent dcf69144cb
commit 019eaf7038
3 changed files with 4 additions and 4 deletions
@@ -99,7 +99,7 @@ void FlightModeManager::Run()
vehicle_local_position_s vehicle_local_position;
if (_vehicle_local_position_sub.update(&vehicle_local_position)) {
const hrt_abstime time_stamp_now = hrt_absolute_time();
const hrt_abstime time_stamp_now = vehicle_local_position.timestamp_sample;
// Guard against too small (< 0.2ms) and too large (> 100ms) dt's.
const float dt = math::constrain(((time_stamp_now - _time_stamp_last_loop) / 1e6f), 0.0002f, 0.1f);
_time_stamp_last_loop = time_stamp_now;