Navigator: Don't switch to RTL if already in landing phase of mission.

This commit is contained in:
Konrad
2023-10-24 10:54:14 +02:00
committed by Roman Bapst
parent c1214c847f
commit a4d05085a7
2 changed files with 28 additions and 15 deletions
+14 -2
View File
@@ -92,13 +92,21 @@ Mission::on_activation()
bool bool
Mission::isLanding() Mission::isLanding()
{ {
if (get_land_start_available()) {
static constexpr size_t max_num_next_items{1u};
int32_t next_mission_items_index[max_num_next_items];
size_t num_found_items;
getNextPositionItems(_mission.land_start_index + 1, next_mission_items_index, num_found_items, max_num_next_items);
// vehicle is currently landing if // vehicle is currently landing if
// mission valid, still flying, and in the landing portion of mission (past land start marker) // mission valid, still flying, and in the landing portion of mission (past land start marker)
bool on_landing_stage = get_land_start_available() && _mission.current_seq > get_land_start_index(); bool on_landing_stage = (num_found_items > 0U) && _mission.current_seq > next_mission_items_index[0U];
// special case: if the land start index is at a LOITER_TO_ALT WP, then we're in the landing sequence already when the // special case: if the land start index is at a LOITER_TO_ALT WP, then we're in the landing sequence already when the
// distance to the WP is below the loiter radius + acceptance. // distance to the WP is below the loiter radius + acceptance.
if (_mission.current_seq == get_land_start_index() && _mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT) { if ((num_found_items > 0U) && _mission.current_seq == next_mission_items_index[0U]
&& _mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT) {
const float d_current = get_distance_to_next_waypoint(_mission_item.lat, _mission_item.lon, const float d_current = get_distance_to_next_waypoint(_mission_item.lat, _mission_item.lon,
_navigator->get_global_position()->lat, _navigator->get_global_position()->lon); _navigator->get_global_position()->lat, _navigator->get_global_position()->lon);
@@ -111,6 +119,10 @@ Mission::isLanding()
} }
return _navigator->get_mission_result()->valid && on_landing_stage; return _navigator->get_mission_result()->valid && on_landing_stage;
} else {
return false;
}
} }
bool bool
+1
View File
@@ -717,6 +717,7 @@ void Navigator::run()
// If we are already in mission landing, do not switch. // If we are already in mission landing, do not switch.
if (_navigation_mode == &_mission && _mission.isLanding()) { if (_navigation_mode == &_mission && _mission.isLanding()) {
navigation_mode_new = &_mission; navigation_mode_new = &_mission;
break;
} else { } else {
_pos_sp_triplet_published_invalid_once = false; _pos_sp_triplet_published_invalid_once = false;