From 801ecd584655aab579093a13af97f6e380516678 Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Fri, 26 May 2023 13:42:35 +0200 Subject: [PATCH] Navigator: make sure to reset mission.item fields touched by set_vtol_transition_item set_vtol_transition_item sets the params of the mission item directly to values that make sense for NAV_CMD_DO_VTOL_TRANSITION, but don't for other NAV_CMDs. So make sure that whenever we use it, we then in the next step reset the touched mission_item fields. Signed-off-by: Silvan Fuhrer --- src/modules/navigator/mission.cpp | 5 ++++- src/modules/navigator/rtl.cpp | 5 ++++- src/modules/navigator/vtol_takeoff.cpp | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/navigator/mission.cpp b/src/modules/navigator/mission.cpp index b7611dcd192d..e9270246f473 100644 --- a/src/modules/navigator/mission.cpp +++ b/src/modules/navigator/mission.cpp @@ -982,7 +982,10 @@ Mission::set_mission_items() _mission_item.altitude_is_relative = false; _mission_item.nav_cmd = NAV_CMD_WAYPOINT; _mission_item.autocontinue = true; - _mission_item.time_inside = 0.0f; + + // have to reset here because these field were used in set_vtol_transition_item + _mission_item.time_inside = 0.f; + _mission_item.acceptance_radius = _navigator->get_acceptance_radius(); // make previous setpoint invalid, such that there will be no prev-current line following. // if the vehicle drifted off the path during back-transition it should just go straight to the landing point diff --git a/src/modules/navigator/rtl.cpp b/src/modules/navigator/rtl.cpp index 919ff71e41ce..2a94c906198e 100644 --- a/src/modules/navigator/rtl.cpp +++ b/src/modules/navigator/rtl.cpp @@ -544,6 +544,10 @@ void RTL::set_rtl_item() _mission_item.altitude = loiter_altitude; _mission_item.altitude_is_relative = false; + // have to reset here because these field were used in set_vtol_transition_item + _mission_item.time_inside = 0.f; + _mission_item.acceptance_radius = _navigator->get_acceptance_radius(); + if (rtl_heading_mode == RTLHeadingMode::RTL_NAVIGATION_HEADING) { _mission_item.yaw = get_bearing_to_next_waypoint(gpos.lat, gpos.lon, _destination.lat, _destination.lon); @@ -554,7 +558,6 @@ void RTL::set_rtl_item() _mission_item.yaw = _navigator->get_local_position()->heading; } - _mission_item.acceptance_radius = _navigator->get_acceptance_radius(); _mission_item.origin = ORIGIN_ONBOARD; break; } diff --git a/src/modules/navigator/vtol_takeoff.cpp b/src/modules/navigator/vtol_takeoff.cpp index 73b8c46bb707..af106a249d03 100644 --- a/src/modules/navigator/vtol_takeoff.cpp +++ b/src/modules/navigator/vtol_takeoff.cpp @@ -117,8 +117,9 @@ VtolTakeoff::on_active() // we need the vehicle to loiter indefinitely but also we want this mission item to be reached as soon // as the loiter is established. therefore, set a small loiter time so that the mission item will be reached quickly, // however it will just continue loitering as there is no next mission item - _mission_item.time_inside = 1; + _mission_item.time_inside = 1.f; _mission_item.loiter_radius = _navigator->get_loiter_radius(); + _mission_item.acceptance_radius = _navigator->get_acceptance_radius(); _mission_item.altitude = _navigator->get_home_position()->alt + _param_loiter_alt.get(); mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current);