Skip to content

Commit

Permalink
autotest: add new blending test
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Apr 29, 2024
1 parent bcf6332 commit 91c7b4a
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8752,7 +8752,7 @@ def test_replay_optical_flow_bit(self):
print("log difference: %s" % str(log_difference))
return log_difference[0]

def GPSBlending(self):
def GPSBlendingLog(self):
'''Test GPS Blending'''
'''ensure we get dataflash log messages for blended instance'''

Expand Down Expand Up @@ -8827,6 +8827,67 @@ def GPSBlending(self):
if ex is not None:
raise ex

def GPSBlending(self):
'''Test GPS Blending'''
'''ensure we get dataflash log messages for blended instance'''

self.context_push()

# configure:
self.set_parameters({
"WP_YAW_BEHAVIOR": 0, # do not yaw
"GPS2_TYPE": 1,
"SIM_GPS2_TYPE": 1,
"SIM_GPS2_DISABLE": 0,
"SIM_GPS_POS_X": 1.0,
"SIM_GPS_POS_Y": -1.0,
"SIM_GPS2_POS_X": -1.0,
"SIM_GPS2_POS_Y": 1.0,
"GPS_AUTO_SWITCH": 2,
})
self.reboot_sitl()

alt = 10
self.takeoff(alt, mode='GUIDED')
self.fly_guided_move_local(30, 0, alt)
self.fly_guided_move_local(30, 30, alt)
self.fly_guided_move_local(0, 30, alt)
self.fly_guided_move_local(0, 0, alt)
self.change_mode('LAND')

current_log_file = self.dfreader_for_current_onboard_log()

self.wait_disarmed()

# ensure that the blended solution is always about half-way
# between the two GPSs:
current_ts = None
while True:
m = current_log_file.recv_match(type='GPS')
if m is None:
break
if current_ts is None:
if m.I != 0: # noqa
continue
current_ts = m.TimeUS
measurements = {}
if m.TimeUS != current_ts:
current_ts = None
continue
measurements[m.I] = (m.Lat, m.Lng)
if len(measurements) == 3:
# check lat:
for n in 0, 1:
expected_blended = (measurements[0][n] + measurements[1][n])/2
epsilon = 0.0000002
error = abs(measurements[2][n] - expected_blended)
if error > epsilon:
raise NotAchievedException("Blended diverged")
current_ts = None

self.context_pop()
self.reboot_sitl()

def Callisto(self):
'''Test Callisto'''
self.customise_SITL_commandline(
Expand Down Expand Up @@ -10936,6 +10997,7 @@ def tests2b(self): # this block currently around 9.5mins here
self.RTL_TO_RALLY,
self.FlyEachFrame,
self.GPSBlending,
self.GPSBlendingLog,
self.DataFlash,
Test(self.DataFlashErase, attempts=8),
self.Callisto,
Expand Down

0 comments on commit 91c7b4a

Please sign in to comment.