autotest: add test for set_alt_m binding

This commit is contained in:
Peter Barker
2025-10-11 12:39:41 -05:00
committed by Thomas Watson
parent 9b240db037
commit 69a514b4aa
+34
View File
@@ -6994,6 +6994,39 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
if m.interval_us != interval_us:
raise NotAchievedException(f"Unexpected interval_us (want={interval_us}, got={m.interval_us})")
def ScriptingLocationBindings(self):
'''test scripting bindings'''
self.install_script_content_context("test-scripting-bindings.lua", """
function main()
here = ahrs:get_location()
if here == nil then
gcs:send_text(0, "Need location")
return
end
if here.alt == 0 then
gcs:send_text(0, "zero altitude?!")
return
end
ALT_FRAME = { ABSOLUTE = 0, ABOVE_HOME = 1, ABOVE_ORIGIN = 2, ABOVE_TERRAIN = 3 }
here:set_alt_m(12.34, ALT_FRAME.ABSOLUTE)
want = 1234
if here:alt() ~= want then
gcs:send_text(0, string.format("Bad altitude" .. here:alt() .. " want " .. want))
return
end
gcs:send_text(0, "Tests OK")
end
function update()
main()
return update, 1000
end
return update()
""")
self.set_parameter('SCR_ENABLE', 1)
self.reboot_sitl()
self.wait_statustext('Tests OK')
def DriveEachFrame(self):
'''drive each frame (except BalanceBot) in a mission to ensure basic functionality'''
vinfo = vehicleinfo.VehicleInfo()
@@ -7144,6 +7177,7 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
self.NetworkingWebServer,
self.NetworkingWebServerPPP,
self.RTL_SPEED,
self.ScriptingLocationBindings,
self.MissionRetransfer,
self.FenceFullAndPartialTransfer,
self.MissionPolyEnabledPreArm,