Skip to content

Commit

Permalink
Tools: added external AHRS scripting test
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Dec 5, 2023
1 parent 5c477d9 commit 8349741
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
QGC WPL 110
0 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363262 149.165237 584.090027 1
1 0 3 22 0.000000 0.000000 0.000000 0.000000 -35.361553 149.163956 20.000000 1
2 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.364540 149.162857 50.000000 1
3 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.367333 149.163164 28.000000 1
4 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.366814 149.165878 28.000000 1
5 0 3 21 0.000000 0.000000 0.000000 1.000000 -35.362947 149.165179 0.000000 1
31 changes: 29 additions & 2 deletions Tools/autotest/arduplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -3158,10 +3158,11 @@ def TerrainLoiter(self):
self.progress("Returning home")
self.fly_home_land_and_disarm(240)

def fly_external_AHRS(self, sim, eahrs_type, mission):
def fly_external_AHRS(self, sim, eahrs_type, mission, extra_params=None, script=None):
"""Fly with external AHRS (VectorNav)"""
self.customise_SITL_commandline(["--uartE=sim:%s" % sim])

self.context_push()
self.set_parameters({
"EAHRS_TYPE": eahrs_type,
"SERIAL4_PROTOCOL": 36,
Expand All @@ -3170,7 +3171,20 @@ def fly_external_AHRS(self, sim, eahrs_type, mission):
"AHRS_EKF_TYPE": 11,
"INS_GYR_CAL": 1,
})
if script is not None:
# optionally install a driver script
self.install_driver_script_context(script)
self.set_parameters({
"SCR_ENABLE" : 1,
"SCR_VM_I_COUNT" : 1000000,
})
self.reboot_sitl()
if extra_params is not None:
# optional extra parameters
self.set_parameters(extra_params)
self.reboot_sitl()
# set again for ones that need to be after reboot
self.set_parameters(extra_params)
self.delay_sim_time(5)
self.progress("Running accelcal")
self.run_cmd(
Expand All @@ -3182,6 +3196,7 @@ def fly_external_AHRS(self, sim, eahrs_type, mission):
self.wait_ready_to_arm()
self.arm_vehicle()
self.fly_mission(mission)
self.context_pop()

def wait_and_maintain_wind_estimate(
self,
Expand Down Expand Up @@ -3281,7 +3296,18 @@ def MicroStrainEAHRS7(self):

def InertialLabsEAHRS(self):
'''Test InertialLabs EAHRS support'''
self.fly_external_AHRS("ILabs", 5, "ap1.txt")
self.fly_external_AHRS("ILabs", 5, "ap1.txt",
extra_params={'SIM_SPEEDUP': 10})

def InertialLabsEAHRSScripting(self):
'''Test InertialLabs EAHRS support with scripting'''
self.fly_external_AHRS("ILabs", 10, "ap1.txt",
extra_params={"ILABS_ENABLE": 1,
'SERIAL4_PROTOCOL': 28,
'SIM_SPEEDUP': 1,
'EAHRS_SENSORS': 13,
'ARSPD_TYPE': 16},
script="EAHRS_InertialLabs.lua")

def get_accelvec(self, m):
return Vector3(m.xacc, m.yacc, m.zacc) * 0.001 * 9.81
Expand Down Expand Up @@ -5363,6 +5389,7 @@ def tests(self):
self.MicroStrainEAHRS5,
self.MicroStrainEAHRS7,
self.InertialLabsEAHRS,
self.InertialLabsEAHRSScripting,
self.Deadreckoning,
self.DeadreckoningNoAirSpeed,
self.EKFlaneswitch,
Expand Down
13 changes: 13 additions & 0 deletions Tools/autotest/vehicle_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4455,6 +4455,12 @@ def install_applet_script_context(self, scriptname):
self.install_applet_script(scriptname)
self.context_get().installed_scripts.append(scriptname)

def install_driver_script_context(self, scriptname):
'''installs a driver script which will be removed when the context goes
away'''
self.install_driver_script(scriptname)
self.context_get().installed_scripts.append(scriptname)

def rootdir(self):
this_dir = os.path.dirname(__file__)
return os.path.realpath(os.path.join(this_dir, "../.."))
Expand Down Expand Up @@ -8024,6 +8030,9 @@ def script_test_source_path(self, scriptname):
def script_applet_source_path(self, scriptname):
return os.path.join(self.rootdir(), "libraries", "AP_Scripting", "applets", scriptname)

def script_drivers_source_path(self, scriptname):
return os.path.join(self.rootdir(), "libraries", "AP_Scripting", "drivers", scriptname)

def installed_script_path(self, scriptname):
return os.path.join("scripts", os.path.basename(scriptname))

Expand Down Expand Up @@ -8064,6 +8073,10 @@ def install_applet_script(self, scriptname, install_name=None):
source = self.script_applet_source_path(scriptname)
self.install_script(source, scriptname, install_name=install_name)

def install_driver_script(self, scriptname, install_name=None):
source = self.script_drivers_source_path(scriptname)
self.install_script(source, scriptname, install_name=install_name)

def remove_installed_script(self, scriptname):
dest = self.installed_script_path(os.path.basename(scriptname))
try:
Expand Down

0 comments on commit 8349741

Please sign in to comment.