flight_modes: use precision landing when landing

This also enables precision landing in landing mode, not just during
RTL.

This required an additional fix during the horizontal approach. It seems
like the z setpoint is not set when landing, so we can't blindly use
that setpoint but rather need to keep the altitude.
This commit is contained in:
Julian Oes
2023-03-29 13:18:58 +02:00
committed by Alessandro Simovic
parent e69baef2f8
commit e2524d8dd5
2 changed files with 9 additions and 2 deletions
@@ -150,7 +150,13 @@ FlightTaskAutoPrecisionLanding::run_state_horizontal_approach()
_position_setpoint(0) = x;
_position_setpoint(1) = y;
_position_setpoint(2) = _target(2);
_velocity_setpoint(0) = _velocity_setpoint(1) = _velocity_setpoint(2) = NAN;
_velocity_setpoint(0) = _velocity_setpoint(1) = NAN;
// If altitude setpoint is NAN, we stay at the current altitude
if (!PX4_ISFINITE(_position_setpoint(2))) {
_velocity_setpoint(2) = 0.0f;
}
// check if target visible, if not go to start
if (!check_state_conditions(PrecLandState::HorizontalApproach)) {