Skip to content

Commit

Permalink
Tools/autotest: Add LUA interface to access Range Finder state
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrmu authored and tridge committed Jan 2, 2024
1 parent 2cc63f5 commit 948ee94
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Tools/autotest/ardusub.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,44 @@ def AltitudeHold(self):
self.watch_altitude_maintained()
self.disarm_vehicle()

def RngfndQuality(self):
"""Check lua Range Finder quality information flow"""
self.context_push()
self.context_collect('STATUSTEXT')

ex = None
try:
self.set_parameters({
"SCR_ENABLE": 1,
"RNGFND1_TYPE": 36,
"RNGFND1_ORIENT": 25,
"RNGFND1_MIN_CM": 10,
"RNGFND1_MAX_CM": 5000,
})

self.install_example_script_context("rangefinder_quality_test.lua")

# These string must match those sent by the lua test script.
complete_str = "#complete#"
failure_str = "!!failure!!"

self.reboot_sitl()

self.wait_statustext(complete_str, timeout=20, check_context=True)
found_failure = self.statustext_in_collections(failure_str)

if found_failure is not None:
raise NotAchievedException("RngfndQuality test failed: " + found_failure.text)

except Exception as e:
self.print_exception_caught(e)
ex = e

self.context_pop()

if ex:
raise ex

def ModeChanges(self, delta=0.2):
"""Check if alternating between ALTHOLD, STABILIZE and POSHOLD affects altitude"""
self.wait_ready_to_arm()
Expand Down Expand Up @@ -524,6 +562,7 @@ def tests(self):
ret.extend([
self.DiveManual,
self.AltitudeHold,
self.RngfndQuality,
self.PositionHold,
self.ModeChanges,
self.DiveMission,
Expand Down

0 comments on commit 948ee94

Please sign in to comment.