precland: also check flight mode

So far flight mode manager was checking navigator states,
but not if commander switches to precland on its own.

For example "commander mode auto:precland"
or the flight mode menu in QGC
This commit is contained in:
Alessandro Simovic 2022-04-20 14:49:43 +02:00
parent d66f7b7b43
commit 02325f38fa

View File

@ -147,6 +147,8 @@ void FlightModeManager::start_flight_task()
const bool precland_mission_item_active = _vehicle_status_sub.get().nav_state ==
vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION &&
_navigator_mission_item_sub.get().nav_sub_cmd == navigator_mission_item_s::WORK_ITEM_TYPE_PRECISION_LAND;
const bool precland_flight_mode = _vehicle_status_sub.get().nav_state ==
vehicle_status_s::NAVIGATION_STATE_AUTO_PRECLAND;
// Do not run any flight task for VTOLs in fixed-wing mode
if (_vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) {
@ -173,7 +175,7 @@ void FlightModeManager::start_flight_task()
task_failure = true;
}
} else if (land_should_be_precland || precland_mission_item_active) {
} else if (land_should_be_precland || precland_mission_item_active || precland_flight_mode) {
// Take-over landing from navigator if precision landing is enabled
should_disable_task = false;