Skip to content

Commit

Permalink
autotest: add a test for in-flight compass learning
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed Jan 28, 2025
1 parent 99c1752 commit a405c67
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Tools/autotest/arduplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -6445,6 +6445,28 @@ def ForceArm(self):
)
self.disarm_vehicle()

def CompassLearnInFlight(self):
'''check we can learn compass offsets in flight'''
self.context_push()
self.set_parameters({
"COMPASS_OFS_X": 1100,
})
self.assert_prearm_failure("Check mag field", other_prearm_failures_fatal=False)
self.context_pop()
self.wait_ready_to_arm()
self.takeoff(30, mode='TAKEOFF')
self.assert_parameter_value("COMPASS_OFS_X", 20, epsilon=30)
old_compass_ofs_x = self.get_parameter('COMPASS_OFS_X')
self.set_parameters({
"COMPASS_OFS_X": 1100,
})
self.set_parameter("COMPASS_LEARN", 3) # 3 is in-flight learning
self.wait_parameter_value("COMPASS_LEARN", 0)
self.assert_parameter_value("COMPASS_OFS_X", old_compass_ofs_x, epsilon=30)
self.fly_home_land_and_disarm()
self.reboot_sitl()
self.assert_parameter_value("COMPASS_OFS_X", old_compass_ofs_x, epsilon=30)

def _MAV_CMD_EXTERNAL_WIND_ESTIMATE(self, command):
self.reboot_sitl()

Expand Down Expand Up @@ -6839,6 +6861,7 @@ def tests1b(self):
self.MAV_CMD_DO_LAND_START,
self.MAV_CMD_NAV_ALTITUDE_WAIT,
self.InteractTest,
self.CompassLearnInFlight,
self.MAV_CMD_MISSION_START,
self.TerrainRally,
self.MAV_CMD_NAV_LOITER_UNLIM,
Expand Down

0 comments on commit a405c67

Please sign in to comment.