Skip to content

Commit

Permalink
Tools: re-work copter and plane loss of GPS auto tests
Browse files Browse the repository at this point in the history
Explicitly test time taken to reset to GPS loss and regain of lock for copter without and plane with dead reckoning assistance.
  • Loading branch information
Paul Riseborough authored and tridge committed Sep 22, 2023
1 parent 74f4650 commit 5807490
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,22 @@ def GPSGlitchAuto(self, timeout=180):
self.show_gps_and_sim_positions(False)
raise e

# stop and test loss of GPS for a short time - it should resume GPS use without falling back into a non aiding mode
self.change_mode("LOITER")
self.set_parameters({
"SIM_GPS_DISABLE": 1,
})
self.delay_sim_time(2)
self.set_parameters({
"SIM_GPS_DISABLE": 0,
})
# regaining GPS should not result in it falling back to a non-navigation mode
self.wait_ekf_flags(mavutil.mavlink.ESTIMATOR_POS_HORIZ_ABS, 0, timeout=1)
# It should still be navigating after enougnh time has passed for any pending timeouts to activate.
self.delay_sim_time(10)
self.wait_ekf_flags(mavutil.mavlink.ESTIMATOR_POS_HORIZ_ABS, 0, timeout=1)
self.change_mode("AUTO")

# record time and position
tstart = self.get_sim_time()

Expand Down
18 changes: 18 additions & 0 deletions Tools/autotest/arduplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -2139,8 +2139,26 @@ def validate_global_position_int_against_simstate(mav, m):
self.delay_sim_time(20)
self.change_mode("RTL")
self.wait_distance_to_home(100, 200, timeout=200)
# go into LOITER to create additonal time for a GPS re-enable test
self.change_mode("LOITER")
self.set_parameter("SIM_GPS_DISABLE", 0)
t_enabled = self.get_sim_time()
# The EKF should wait for GPS checks to pass when we are still able to navigate using dead reckoning
# to prevent bad GPS being used when coming back after loss of lock due to interence.
self.wait_ekf_flags(mavutil.mavlink.ESTIMATOR_POS_HORIZ_ABS, 0, timeout=15)
if self.get_sim_time() < (t_enabled+9):
raise NotAchievedException("GPS use re-started too quickly")
# wait for EKF and vehicle position to stabilise, then test response to jamming
self.delay_sim_time(20)
self.set_parameter("SIM_GPS_JAM", 1)
self.delay_sim_time(10)
self.set_parameter("SIM_GPS_JAM", 0)
t_enabled = self.get_sim_time()
# The EKF should wait for GPS checks to pass when we are still able to navigate using dead reckoning
# to prevent bad GPS being used when coming back after loss of lock due to interence.
self.wait_ekf_flags(mavutil.mavlink.ESTIMATOR_POS_HORIZ_ABS, 0, timeout=15)
if self.get_sim_time() < (t_enabled+9):
raise NotAchievedException("GPS use re-started too quickly after jamming")
self.set_rc(3, 1000)
self.fly_home_land_and_disarm()
self.progress("max-divergence: %fm" % (self.max_divergence,))
Expand Down

0 comments on commit 5807490

Please sign in to comment.