mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-08 17:08:28 -04:00
autotest: tidy scripting examples test
This commit is contained in:
parent
b3f06651cf
commit
306d8360fb
@ -5052,30 +5052,25 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
|
|||||||
|
|
||||||
def test_scripting_simple_loop(self):
|
def test_scripting_simple_loop(self):
|
||||||
self.start_subtest("Scripting simple loop")
|
self.start_subtest("Scripting simple loop")
|
||||||
ex = None
|
|
||||||
example_script = "simple_loop.lua"
|
self.context_push()
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
def my_message_hook(mav, message):
|
def my_message_hook(mav, message):
|
||||||
if message.get_type() != 'STATUSTEXT':
|
if message.get_type() != 'STATUSTEXT':
|
||||||
return
|
return
|
||||||
messages.append(message)
|
messages.append(message)
|
||||||
self.install_message_hook(my_message_hook)
|
|
||||||
try:
|
self.install_message_hook_context(my_message_hook)
|
||||||
self.set_parameter("SCR_ENABLE", 1)
|
|
||||||
self.install_example_script(example_script)
|
self.set_parameter("SCR_ENABLE", 1)
|
||||||
self.reboot_sitl()
|
self.install_example_script_context("simple_loop.lua")
|
||||||
self.delay_sim_time(10)
|
|
||||||
except Exception as e:
|
|
||||||
self.print_exception_caught(e)
|
|
||||||
ex = e
|
|
||||||
self.remove_example_script(example_script)
|
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
|
self.delay_sim_time(10)
|
||||||
|
|
||||||
self.remove_message_hook(my_message_hook)
|
self.context_pop()
|
||||||
|
self.reboot_sitl()
|
||||||
if ex is not None:
|
|
||||||
raise ex
|
|
||||||
|
|
||||||
# check all messages to see if we got our message
|
# check all messages to see if we got our message
|
||||||
count = 0
|
count = 0
|
||||||
@ -5139,138 +5134,85 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
|
|||||||
|
|
||||||
self.context_push()
|
self.context_push()
|
||||||
self.context_collect("STATUSTEXT")
|
self.context_collect("STATUSTEXT")
|
||||||
|
self.set_parameter("SCR_ENABLE", 1)
|
||||||
ex = None
|
self.install_example_script_context("hello_world.lua")
|
||||||
example_script = "hello_world.lua"
|
|
||||||
try:
|
|
||||||
self.set_parameter("SCR_ENABLE", 1)
|
|
||||||
self.install_example_script(example_script)
|
|
||||||
self.reboot_sitl()
|
|
||||||
self.wait_statustext('hello, world', check_context=True, timeout=30)
|
|
||||||
except Exception as e:
|
|
||||||
self.print_exception_caught(e)
|
|
||||||
ex = e
|
|
||||||
|
|
||||||
self.remove_example_script(example_script)
|
|
||||||
|
|
||||||
self.context_pop()
|
|
||||||
|
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
|
|
||||||
if ex is not None:
|
self.wait_statustext('hello, world', check_context=True, timeout=30)
|
||||||
raise ex
|
|
||||||
|
self.context_pop()
|
||||||
|
self.reboot_sitl()
|
||||||
|
|
||||||
def ScriptingSteeringAndThrottle(self):
|
def ScriptingSteeringAndThrottle(self):
|
||||||
'''Scripting test - steering and throttle'''
|
'''Scripting test - steering and throttle'''
|
||||||
self.start_subtest("Scripting square")
|
self.start_subtest("Scripting square")
|
||||||
ex = None
|
|
||||||
example_script = "rover-set-steering-and-throttle.lua"
|
self.context_push()
|
||||||
try:
|
self.install_example_script_context("rover-set-steering-and-throttle.lua")
|
||||||
self.install_example_script(example_script)
|
self.set_parameter("SCR_ENABLE", 1)
|
||||||
self.set_parameter("SCR_ENABLE", 1)
|
|
||||||
self.reboot_sitl()
|
|
||||||
self.wait_ready_to_arm()
|
|
||||||
self.arm_vehicle()
|
|
||||||
self.set_rc(6, 2000)
|
|
||||||
tstart = self.get_sim_time()
|
|
||||||
while not self.mode_is("HOLD"):
|
|
||||||
if self.get_sim_time_cached() - tstart > 30:
|
|
||||||
raise NotAchievedException("Did not move to hold")
|
|
||||||
m = self.mav.recv_match(type='VFR_HUD', blocking=True, timeout=1)
|
|
||||||
if m is not None:
|
|
||||||
self.progress("Current speed: %f" % m.groundspeed)
|
|
||||||
self.disarm_vehicle()
|
|
||||||
self.reboot_sitl()
|
|
||||||
except Exception as e:
|
|
||||||
self.print_exception_caught(e)
|
|
||||||
self.disarm_vehicle()
|
|
||||||
ex = e
|
|
||||||
self.remove_example_script(example_script)
|
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
|
|
||||||
if ex is not None:
|
self.wait_ready_to_arm()
|
||||||
raise ex
|
self.arm_vehicle()
|
||||||
|
self.set_rc(6, 2000)
|
||||||
|
tstart = self.get_sim_time()
|
||||||
|
while not self.mode_is("HOLD"):
|
||||||
|
if self.get_sim_time_cached() - tstart > 30:
|
||||||
|
raise NotAchievedException("Did not move to hold")
|
||||||
|
m = self.mav.recv_match(type='VFR_HUD', blocking=True, timeout=1)
|
||||||
|
if m is not None:
|
||||||
|
self.progress("Current speed: %f" % m.groundspeed)
|
||||||
|
self.disarm_vehicle()
|
||||||
|
|
||||||
|
self.context_pop()
|
||||||
|
self.reboot_sitl()
|
||||||
|
|
||||||
def test_scripting_auxfunc(self):
|
def test_scripting_auxfunc(self):
|
||||||
self.start_subtest("Scripting aufunc triggering")
|
self.start_subtest("Scripting aufunc triggering")
|
||||||
|
|
||||||
self.context_push()
|
self.context_push()
|
||||||
self.set_parameter('RELAY_PIN', 1)
|
|
||||||
self.context_collect("STATUSTEXT")
|
self.context_collect("STATUSTEXT")
|
||||||
|
self.set_parameters({
|
||||||
ex = None
|
"SCR_ENABLE": 1,
|
||||||
example_script = "RCIN_test.lua"
|
"RELAY_PIN": 1,
|
||||||
try:
|
})
|
||||||
self.set_parameter("SCR_ENABLE", 1)
|
self.install_example_script_context("RCIN_test.lua")
|
||||||
self.install_example_script(example_script)
|
|
||||||
self.reboot_sitl()
|
|
||||||
self.wait_parameter_value("SIM_PIN_MASK", 121)
|
|
||||||
self.wait_parameter_value("SIM_PIN_MASK", 123)
|
|
||||||
self.wait_parameter_value("SIM_PIN_MASK", 121)
|
|
||||||
except Exception as e:
|
|
||||||
self.print_exception_caught(e)
|
|
||||||
ex = e
|
|
||||||
|
|
||||||
self.remove_example_script(example_script)
|
|
||||||
|
|
||||||
self.context_pop()
|
|
||||||
|
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
|
|
||||||
if ex is not None:
|
self.wait_parameter_value("SIM_PIN_MASK", 121)
|
||||||
raise ex
|
self.wait_parameter_value("SIM_PIN_MASK", 123)
|
||||||
|
self.wait_parameter_value("SIM_PIN_MASK", 121)
|
||||||
|
|
||||||
|
self.context_pop()
|
||||||
|
self.reboot_sitl()
|
||||||
|
|
||||||
def test_scripting_print_home_and_origin(self):
|
def test_scripting_print_home_and_origin(self):
|
||||||
self.start_subtest("Scripting print home and origin")
|
self.start_subtest("Scripting print home and origin")
|
||||||
|
|
||||||
self.context_push()
|
self.context_push()
|
||||||
|
|
||||||
ex = None
|
self.set_parameter("SCR_ENABLE", 1)
|
||||||
example_script = "ahrs-print-home-and-origin.lua"
|
self.install_example_script_context("ahrs-print-home-and-origin.lua")
|
||||||
try:
|
self.reboot_sitl()
|
||||||
self.set_parameter("SCR_ENABLE", 1)
|
self.wait_ready_to_arm()
|
||||||
self.install_example_script(example_script)
|
self.wait_statustext("Home - ")
|
||||||
self.reboot_sitl()
|
self.wait_statustext("Origin - ")
|
||||||
self.wait_ready_to_arm()
|
|
||||||
self.wait_statustext("Home - ")
|
|
||||||
self.wait_statustext("Origin - ")
|
|
||||||
except Exception as e:
|
|
||||||
self.print_exception_caught(e)
|
|
||||||
ex = e
|
|
||||||
|
|
||||||
self.remove_example_script(example_script)
|
|
||||||
|
|
||||||
self.context_pop()
|
self.context_pop()
|
||||||
|
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
|
|
||||||
if ex is not None:
|
|
||||||
raise ex
|
|
||||||
|
|
||||||
def test_scripting_set_home_to_vehicle_location(self):
|
def test_scripting_set_home_to_vehicle_location(self):
|
||||||
self.start_subtest("Scripting set home to vehicle location")
|
self.start_subtest("Scripting set home to vehicle location")
|
||||||
|
|
||||||
self.context_push()
|
self.context_push()
|
||||||
|
self.set_parameter("SCR_ENABLE", 1)
|
||||||
ex = None
|
self.install_example_script_context("ahrs-set-home-to-vehicle-location.lua")
|
||||||
example_script = "ahrs-set-home-to-vehicle-location.lua"
|
|
||||||
try:
|
|
||||||
self.set_parameter("SCR_ENABLE", 1)
|
|
||||||
self.install_example_script(example_script)
|
|
||||||
self.reboot_sitl()
|
|
||||||
self.wait_statustext("Home position reset")
|
|
||||||
except Exception as e:
|
|
||||||
self.print_exception_caught(e)
|
|
||||||
ex = e
|
|
||||||
|
|
||||||
self.remove_example_script(example_script)
|
|
||||||
|
|
||||||
self.context_pop()
|
|
||||||
|
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
|
|
||||||
if ex is not None:
|
self.wait_statustext("Home position reset")
|
||||||
raise ex
|
|
||||||
|
self.context_pop()
|
||||||
|
self.reboot_sitl()
|
||||||
|
|
||||||
def Scripting(self):
|
def Scripting(self):
|
||||||
'''Scripting test'''
|
'''Scripting test'''
|
||||||
|
Loading…
Reference in New Issue
Block a user