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
2022-03-25 08:20:13 +13:00
committed by Alessandro Simovic
parent a214d6de94
commit f08268adbc
2 changed files with 9 additions and 2 deletions
@@ -166,7 +166,8 @@ void FlightModeManager::start_flight_task()
// Take-over landing from navigator if precision landing is enabled
} else if (_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_RTL
} else if ((_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_RTL ||
_vehicle_status_sub.get().nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_LAND)
&& _param_rtl_pld_md.get() > 0) {
should_disable_task = false;
@@ -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)) {