forked from Archive/PX4-Autopilot
mc_pos_control: fix derivative spike when regaining velocity estimate
When having no velocity estimate the derivative was updated with zero.
When losing the velocity estimate this is fine since the resulting
derivative spike doesn't get used and acceleration is set to NAN.
But when regaining the velocity estimate the spike from zero to
the first estimated velocity gets used as acceleration in the position
controller and results in a twitch.
To solve this I use the derivative reset I introduced in pr #13522
commit b64abf48b2
This commit is contained in:
parent
a6cc972b5c
commit
1e06f6bbd2
|
@ -456,10 +456,9 @@ MulticopterPositionControl::set_vehicle_states(const float &vel_sp_z)
|
||||||
} else {
|
} else {
|
||||||
_states.velocity(0) = _states.velocity(1) = NAN;
|
_states.velocity(0) = _states.velocity(1) = NAN;
|
||||||
_states.acceleration(0) = _states.acceleration(1) = NAN;
|
_states.acceleration(0) = _states.acceleration(1) = NAN;
|
||||||
|
// reset derivatives to prevent acceleration spikes when regaining velocity
|
||||||
// since no valid velocity, update derivate with 0
|
_vel_x_deriv.reset();
|
||||||
_vel_x_deriv.update(0.0f);
|
_vel_y_deriv.reset();
|
||||||
_vel_y_deriv.update(0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PX4_ISFINITE(_local_pos.vz) && _local_pos.v_z_valid) {
|
if (PX4_ISFINITE(_local_pos.vz) && _local_pos.v_z_valid) {
|
||||||
|
@ -476,9 +475,8 @@ MulticopterPositionControl::set_vehicle_states(const float &vel_sp_z)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_states.velocity(2) = _states.acceleration(2) = NAN;
|
_states.velocity(2) = _states.acceleration(2) = NAN;
|
||||||
// since no valid velocity, update derivate with 0
|
// reset derivative to prevent acceleration spikes when regaining velocity
|
||||||
_vel_z_deriv.update(0.0f);
|
_vel_z_deriv.reset();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue