Skip to content

Commit

Permalink
autotest: added CommonOrigin test
Browse files Browse the repository at this point in the history
test EK2 and EK3 common origin
  • Loading branch information
tridge committed Aug 21, 2024
1 parent eac9c78 commit 6e16092
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11729,6 +11729,59 @@ def BatteryInternalUseOnly(self):
"id": 1
})

def CommonOrigin(self):
"""Test common origin between EKF2 and EKF3"""
self.context_push()

# start on EKF2
self.set_parameters({
'AHRS_EKF_TYPE': 2,
'EK2_ENABLE': 1,
'EK3_CHECK_SCALE': 1, # make EK3 slow to get origin
})
self.reboot_sitl()

self.context_collect('STATUSTEXT')

self.wait_statustext("EKF2 IMU0 origin set", timeout=60, check_context=True)
self.wait_statustext("EKF2 IMU0 is using GPS", timeout=60, check_context=True)
self.wait_statustext("EKF2 active", timeout=60, check_context=True)

self.context_collect('GPS_GLOBAL_ORIGIN')

# get EKF2 origin
self.run_cmd(mavutil.mavlink.MAV_CMD_GET_HOME_POSITION)
ek2_origin = self.assert_receive_message('GPS_GLOBAL_ORIGIN', check_context=True)

# switch to EKF3
self.set_parameters({
'SIM_GPS_GLITCH_X' : 0.001, # about 100m
'EK3_CHECK_SCALE' : 100,
'AHRS_EKF_TYPE' : 3})

self.wait_statustext("EKF3 IMU0 is using GPS", timeout=60, check_context=True)
self.wait_statustext("EKF3 active", timeout=60, check_context=True)

self.run_cmd(mavutil.mavlink.MAV_CMD_GET_HOME_POSITION)
ek3_origin = self.assert_receive_message('GPS_GLOBAL_ORIGIN', check_context=True)

self.progress("Checking origins")
if ek2_origin.time_usec == ek3_origin.time_usec:
raise NotAchievedException("Did not get a new GPS_GLOBAL_ORIGIN message")

print(ek2_origin, ek3_origin)

if (ek2_origin.latitude != ek3_origin.latitude or
ek2_origin.longitude != ek3_origin.longitude or
ek2_origin.altitude != ek3_origin.altitude):
raise NotAchievedException("Did not get matching EK2 and EK3 origins")

self.context_pop()

# restart GPS driver
self.reboot_sitl()


def tests2b(self): # this block currently around 9.5mins here
'''return list of all tests'''
ret = ([
Expand Down Expand Up @@ -11828,6 +11881,7 @@ def tests2b(self): # this block currently around 9.5mins here
self.LoggingFormat,
self.MissionRTLYawBehaviour,
self.BatteryInternalUseOnly,
self.CommonOrigin,
])
return ret

Expand Down

0 comments on commit 6e16092

Please sign in to comment.