forked from Archive/PX4-Autopilot
multicopter: minimize dt jitter by using estimate timestamp_sample
This commit is contained in:
parent
dcf69144cb
commit
019eaf7038
|
@ -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;
|
||||
|
|
|
@ -263,8 +263,8 @@ MulticopterAttitudeControl::Run()
|
|||
}
|
||||
|
||||
// Guard against too small (< 0.2ms) and too large (> 20ms) dt's.
|
||||
const float dt = math::constrain(((v_att.timestamp - _last_run) * 1e-6f), 0.0002f, 0.02f);
|
||||
_last_run = v_att.timestamp;
|
||||
const float dt = math::constrain(((v_att.timestamp_sample - _last_run) * 1e-6f), 0.0002f, 0.02f);
|
||||
_last_run = v_att.timestamp_sample;
|
||||
|
||||
/* check for updates in other topics */
|
||||
_manual_control_setpoint_sub.update(&_manual_control_setpoint);
|
||||
|
|
|
@ -291,7 +291,7 @@ void MulticopterPositionControl::Run()
|
|||
vehicle_local_position_s local_pos;
|
||||
|
||||
if (_local_pos_sub.update(&local_pos)) {
|
||||
const hrt_abstime time_stamp_now = local_pos.timestamp;
|
||||
const hrt_abstime time_stamp_now = local_pos.timestamp_sample;
|
||||
const float dt = math::constrain(((time_stamp_now - _time_stamp_last_loop) * 1e-6f), 0.002f, 0.04f);
|
||||
_time_stamp_last_loop = time_stamp_now;
|
||||
|
||||
|
|
Loading…
Reference in New Issue