From 8838ebd77de6c3dbc6fbc823be4bd8f88c84179e Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Thu, 29 Jun 2023 14:22:24 +0200 Subject: [PATCH] Navigator: Loiter: always establish new Loiter with center at current pos When switching into Hold mode establish a Loiter around current position, even if we were before already loitering (eg in Mission mode). Signed-off-by: Silvan Fuhrer --- src/modules/navigator/loiter.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/navigator/loiter.cpp b/src/modules/navigator/loiter.cpp index 655db702fa..2c53d19659 100644 --- a/src/modules/navigator/loiter.cpp +++ b/src/modules/navigator/loiter.cpp @@ -61,6 +61,7 @@ Loiter::on_activation() reposition(); } else { + // this is executed when the flight mode is switched to Hold manually, not through a reposition set_loiter_position(); } @@ -109,16 +110,11 @@ Loiter::set_loiter_position() _mission_item.nav_cmd = NAV_CMD_IDLE; } else { - if (pos_sp_triplet->current.valid && pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_LOITER) { - setLoiterItemFromCurrentPositionSetpoint(&_mission_item); + if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) { + setLoiterItemFromCurrentPositionWithBreaking(&_mission_item); } else { - if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) { - setLoiterItemFromCurrentPositionWithBreaking(&_mission_item); - - } else { - setLoiterItemFromCurrentPosition(&_mission_item); - } + setLoiterItemFromCurrentPosition(&_mission_item); } }