Skip to content

Commit 7f277b2

Browse files
tpwrulespeterbarker
authored andcommitted
autotest: improve test.Plane.CompassLearnInFlight robustness
The test has always learned a marginal compass value (25-30, with failure at 35) and since commit `a52f911b` it has usually failed on my machine with a value of 40-45 presumably due to a small change in the flight path. It also occasionally fails in CI with similar values; presumably different machine speeds select a different part of the flight during which learning occurs. Fix the issue by flying a straight level path to allow time for the GSF to converge, as that is used as the reference for learning according to the code. This results in a learned value of 5-10 which is much closer to the target and hopefully less sensitive to the particular machine.
1 parent f053f82 commit 7f277b2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Tools/autotest/arduplane.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6737,6 +6737,9 @@ def CompassLearnInFlight(self):
67376737
self.wait_ready_to_arm()
67386738
self.takeoff(30, mode='TAKEOFF')
67396739
self.assert_parameter_value("COMPASS_OFS_X", 20, epsilon=30)
6740+
# fly straight and level for a bit to let GSF converge for accurate learning
6741+
self.change_mode("FBWB") # not "CRUISE" to avoid heading track with bad compass
6742+
self.wait_distance(200, accuracy=20)
67406743
old_compass_ofs_x = self.get_parameter('COMPASS_OFS_X')
67416744
self.set_parameters({
67426745
"COMPASS_OFS_X": 1100,

0 commit comments

Comments
 (0)