From a03178014cd37044264d64f9f67d9a387f846258 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 7 May 2024 13:20:50 +1000 Subject: [PATCH 1/2] autotest: add test for Rover RTL speed --- Tools/autotest/rover.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tools/autotest/rover.py b/Tools/autotest/rover.py index b08e1ebed3003f..bab8ed9594d625 100644 --- a/Tools/autotest/rover.py +++ b/Tools/autotest/rover.py @@ -525,6 +525,27 @@ def DriveRTL(self, timeout=120): self.disarm_vehicle() self.progress("RTL Mission OK (%fm)" % home_distance) + def RTL_SPEED(self, timeout=120): + '''Test RTL_SPEED is honoured''' + + self.upload_simple_relhome_mission([ + (mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 300, 0, 0), + (mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 1000, 0, 0), + ]) + + self.wait_ready_to_arm() + self.arm_vehicle() + + self.change_mode('AUTO') + self.wait_current_waypoint(2, timeout=120) + for speed in 1, 5.5, 1.5, 7.5: + self.set_parameter("RTL_SPEED", speed) + self.change_mode('RTL') + self.wait_groundspeed(speed-0.1, speed+0.1, minimum_duration=10) + self.change_mode('HOLD') + self.do_RTL() + self.disarm_vehicle() + def AC_Avoidance(self): '''Test AC Avoidance switch''' self.context_push() @@ -6814,6 +6835,7 @@ def tests(self): self.MAV_CMD_BATTERY_RESET, self.NetworkingWebServer, self.NetworkingWebServerPPP, + self.RTL_SPEED, ]) return ret From 35449e7c338e3b81cbf8222e4c9c4bff0ff99d03 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 7 May 2024 13:21:16 +1000 Subject: [PATCH 2/2] Rover: correct clamping of RTL_SPEED parameter MAX wasn't treating these things as floats --- Rover/mode_rtl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rover/mode_rtl.cpp b/Rover/mode_rtl.cpp index e896c5151fc878..8fe2ad75959d75 100644 --- a/Rover/mode_rtl.cpp +++ b/Rover/mode_rtl.cpp @@ -8,7 +8,7 @@ bool ModeRTL::_enter() } // initialise waypoint navigation library - g2.wp_nav.init(MAX(0, g2.rtl_speed)); + g2.wp_nav.init(MAX(0.0f, g2.rtl_speed)); // set target to the closest rally point or home #if HAL_RALLY_ENABLED