From 6bf9556612cb392d4b4b5b6dbba98606e8aa978f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 May 2022 19:27:12 +1000 Subject: [PATCH] AP_Mission: improved handling of large LOITER_TURNS instead of wrapping we should use MIN with 255, which is closer to what was requested --- libraries/AP_Mission/AP_Mission.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Mission/AP_Mission.cpp b/libraries/AP_Mission/AP_Mission.cpp index dd9c399193..8c196cd5bd 100644 --- a/libraries/AP_Mission/AP_Mission.cpp +++ b/libraries/AP_Mission/AP_Mission.cpp @@ -920,8 +920,8 @@ MAV_MISSION_RESULT AP_Mission::mavlink_int_to_mission_cmd(const mavlink_mission_ break; case MAV_CMD_NAV_LOITER_TURNS: { // MAV ID: 18 - uint16_t num_turns = packet.param1; // param 1 is number of times to circle is held in low p1 - uint16_t radius_m = fabsf(packet.param3); // param 3 is radius in meters is held in high p1 + uint16_t num_turns = MIN(255,packet.param1); // param 1 is number of times to circle is held in low p1 + uint16_t radius_m = MIN(255,fabsf(packet.param3)); // param 3 is radius in meters is held in high p1 cmd.p1 = (radius_m<<8) | (num_turns & 0x00FF); // store radius in high byte of p1, num turns in low byte of p1 cmd.content.location.loiter_ccw = (packet.param3 < 0); cmd.content.location.loiter_xtrack = (packet.param4 > 0); // 0 to xtrack from center of waypoint, 1 to xtrack from tangent exit location