Skip to content
Snippets Groups Projects
Commit f11a65a7 authored by Dennis Mannhart's avatar Dennis Mannhart Committed by Lorenz Meier
Browse files

mc_pos_control: fix overwrite for state velocity

parent f2d559a4
No related branches found
No related tags found
No related merge requests found
......@@ -440,6 +440,8 @@ MulticopterPositionControl::set_vehicle_states(const float &vel_sp_z)
} else if (PX4_ISFINITE(_local_pos.vz)) {
_states.velocity(2) = _local_pos.vz;
if (PX4_ISFINITE(vel_sp_z) && fabsf(vel_sp_z) > FLT_EPSILON && PX4_ISFINITE(_local_pos.z_deriv)) {
// A change in velocity is demanded. Set velocity to the derivative of position
// because it has less bias but blend it in across the landing speed range
......@@ -447,7 +449,6 @@ MulticopterPositionControl::set_vehicle_states(const float &vel_sp_z)
_states.velocity(2) = _local_pos.z_deriv * weighting + _local_pos.vz * (1.0f - weighting);
}
_states.velocity(2) = _local_pos.vz;
_states.acceleration(2) = _vel_z_deriv.update(-_states.velocity(2));
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment