diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index d4b97c3a05..056a6c1b63 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -148,7 +148,10 @@ class AutoTestCopter(AutoTest): self.wait_ready_to_arm(require_absolute=require_absolute, timeout=timeout) self.zero_throttle() self.arm_vehicle() - self.set_rc(3, takeoff_throttle) + if mode == 'GUIDED': + self.user_takeoff(alt_min=alt_min) + else: + self.set_rc(3, takeoff_throttle) self.wait_for_alt(alt_min=alt_min, timeout=timeout) self.hover() self.progress("TAKEOFF COMPLETE") @@ -6497,6 +6500,31 @@ class AutoTestCopter(AutoTest): if not ok: raise NotAchievedException("check_replay failed") + def test_copter_gps_zero(self): + # https://github.com/ArduPilot/ardupilot/issues/14236 + self.progress("arm the vehicle and takeoff in Guided") + self.takeoff(20, mode='GUIDED') + self.progress("fly 50m North (or whatever)") + old_pos = self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True) + self.fly_guided_move_global_relative_alt(50, 0, 20) + self.set_parameter('GPS_TYPE', 0) + self.drain_mav() + tstart = self.get_sim_time() + while True: + if self.get_sim_time_cached() - tstart > 30 and self.mode_is('LAND'): + self.progress("Bug not reproduced") + break + m = self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True, timeout=1) + self.progress("Received (%s)" % str(m)) + if m is None: + raise NotAchievedException("No GLOBAL_POSITION_INT?!") + pos_delta = self.get_distance_int(old_pos, m) + self.progress("Distance: %f" % pos_delta) + if pos_delta < 5: + raise NotAchievedException("Bug reproduced - returned to near origin") + self.wait_disarmed() + self.reboot_sitl() + # a wrapper around all the 1A,1B,1C..etc tests for travis def tests1(self): ret = ([]) @@ -6859,6 +6887,10 @@ class AutoTestCopter(AutoTest): self.fly_dynamic_notches, attempts=4), + Test("PositionWhenGPSIsZero", + "Ensure position doesn't zero when GPS lost", + self.test_copter_gps_zero), + Test("GyroFFT", "Fly Gyro FFT", self.fly_gyro_fft,