MulticopterPositionControl: prevent velocity integrator filling up from stale acceleration setpoints

When position control is disabled, clear the setpoint properly to prevent stale values. This fixes a bug where switching to position mode in the same control loop as a hover thrust estimate update could fill up the velocity integrator.
This commit is contained in:
mahima-yoga
2026-01-07 17:57:09 +01:00
committed by Matthias Grob
parent 0375f1a6f0
commit 7c318a3296
2 changed files with 6 additions and 2 deletions
@@ -408,6 +408,7 @@ void MulticopterPositionControl::Run()
} else if (previous_position_control_enabled && !_vehicle_control_mode.flag_multicopter_position_control_enabled) {
// clear existing setpoint when controller is no longer active
_setpoint = PositionControl::empty_trajectory_setpoint;
_control.setInputSetpoint(_setpoint);
}
}
}
@@ -84,8 +84,11 @@ void PositionControl::updateHoverThrust(const float hover_thrust_new)
const float previous_hover_thrust = _hover_thrust;
setHoverThrust(hover_thrust_new);
_vel_int(2) += (_acc_sp(2) - CONSTANTS_ONE_G) * previous_hover_thrust / _hover_thrust
+ CONSTANTS_ONE_G - _acc_sp(2);
if (PX4_ISFINITE(_acc_sp(2))) {
_vel_int(2) += (_acc_sp(2) - CONSTANTS_ONE_G) * previous_hover_thrust / _hover_thrust
+ CONSTANTS_ONE_G - _acc_sp(2);
}
}
void PositionControl::setState(const PositionControlStates &states)