Skip to content

Commit 28a31d0

Browse files
committed
Tools: scripted arming checks
1 parent 001ef66 commit 28a31d0

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

Tools/autotest/arduplane.py

+116
Original file line numberDiff line numberDiff line change
@@ -7232,6 +7232,121 @@ def Volz(self):
72327232
if abs(m.Pos - m.PosCmd) > 20:
72337233
break
72347234

7235+
def setup_servo_mount(self, roll_servo=5, pitch_servo=6, yaw_servo=7):
7236+
'''configure a rpy servo mount; caller responsible for required rebooting'''
7237+
self.progress("Setting up servo mount")
7238+
self.set_parameters({
7239+
"MNT1_TYPE": 1,
7240+
"MNT1_PITCH_MIN": -45,
7241+
"MNT1_PITCH_MAX": 45,
7242+
"RC6_OPTION": 213, # MOUNT1_PITCH
7243+
"SERVO%u_FUNCTION" % roll_servo: 8, # roll
7244+
"SERVO%u_FUNCTION" % pitch_servo: 7, # pitch
7245+
"SERVO%u_FUNCTION" % yaw_servo: 6, # yaw
7246+
})
7247+
7248+
def ScriptedArmingChecksApplet(self):
7249+
""" Applet for Arming Checks will prevent a vehicle from arming based on scripted checks
7250+
"""
7251+
self .start_subtest("Scripted Arming Checks Applet validation")
7252+
self.context_push()
7253+
self.context_collect("STATUSTEXT")
7254+
ex = None
7255+
7256+
applet_script = "arming-checks.lua"
7257+
try:
7258+
"""Initialize the FC"""
7259+
self.set_parameter("SCR_ENABLE", 1)
7260+
self.install_applet_script(applet_script)
7261+
self.reboot_sitl()
7262+
self.wait_ekf_happy()
7263+
self.wait_text("ArduPilot Ready", check_context=True)
7264+
self.wait_text("Arming Checks .* loaded", timeout=30, check_context=True, regex=True)
7265+
7266+
self .start_subsubtest("ArmCk: MAV_SYSID not set")
7267+
self.progress("Currently SYSID is %f" % self.get_parameter('MAV_SYSID'))
7268+
self.wait_text("ArmCk: MAV_SYSID not set", timeout=30, check_context=True, regex=True)
7269+
7270+
''' This check comes first since its part of the standard parameters - an invalid scaling speed'''
7271+
self .start_subsubtest("ArmCk: SCALING_SPEED close to AIRSPEED_CRUISE")
7272+
self.assert_prearm_failure("Scaling spd not close", other_prearm_failures_fatal=False)
7273+
self.set_parameter("SCALING_SPEED", 22)
7274+
self.wait_text("Cleared: Scaling spd not close", check_context=True)
7275+
7276+
self .start_subsubtest("ArmCk: FOLL_SYSID must be set if FOLL_ENABLE = 1")
7277+
self.set_parameter("FOLL_ENABLE", 1)
7278+
self.assert_prearm_failure("FOLL_SYSID not set", other_prearm_failures_fatal=False)
7279+
self.set_parameter("FOLL_SYSID", 3)
7280+
self.wait_text("Cleared: FOLL_SYSID not set", check_context=True)
7281+
7282+
''' Need a healthy camera mount defined for this to work '''
7283+
self .start_subsubtest("ArmCk: Mount SYSID must be match FOLL_SYSID")
7284+
self.setup_servo_mount()
7285+
''' to fail the check MNTx_SYSID_DFLT must be non zero but not = FOLL_SYSID'''
7286+
self.set_parameter("MNT1_SYSID_DFLT", 1)
7287+
self.reboot_sitl() # to handle MNT_TYPE changing
7288+
self.wait_text("ArduPilot Ready", check_context=True)
7289+
self.wait_text("Arming Checks .* loaded", timeout=30, check_context=True, regex=True)
7290+
self.wait_text("MAV_SYSID not set", timeout=30, check_context=True, regex=True)
7291+
self.progress("Currently MNT1_SYSID_DFLT is %f" % self.get_parameter('MNT1_SYSID_DFLT'))
7292+
self.wait_text("ArmCk: MNTx_SYSID != FOLL", check_context=True)
7293+
self.set_parameter("MNT1_SYSID_DFLT", 3)
7294+
self.wait_text("Cleared: MNTx_SYSID != FOLL", check_context=True)
7295+
7296+
self .start_subsubtest("ArmCk: RTL_ALTITUDE must be legal")
7297+
self.set_parameter("RTL_ALTITUDE", 150)
7298+
self.assert_prearm_failure("ArmCk: fail: RTL_ALT", other_prearm_failures_fatal=False)
7299+
self.set_parameter("RTL_ALTITUDE", 120)
7300+
self.wait_text("Cleared: RTL_ALT", check_context=True)
7301+
7302+
self .start_subsubtest("ArmCk: RTL_CLIMB_MIN must be legal")
7303+
self.set_parameter("RTL_CLIMB_MIN", 150)
7304+
self.wait_text("ArmCk: RTL_CLIMB_MIN too high", check_context=True)
7305+
self.set_parameter("RTL_CLIMB_MIN", 120)
7306+
self.wait_text("Cleared: RTL_CLIMB_MIN too high", check_context=True)
7307+
7308+
self .start_subsubtest("ArmCk: AIRSPEED stall < min < cruise < max")
7309+
''' Airspeed parameter start out as
7310+
AIRSPEED_STALL = 0
7311+
AIRSPEED_MIN = 10
7312+
AIRSPEED_CRUISE = 22
7313+
AIRSPEED_MAX = 30
7314+
'''
7315+
self .start_subsubtest("ArmCk: AIRSPEED max < others")
7316+
self.set_parameter("AIRSPEED_MAX", 5)
7317+
self.assert_prearm_failure("ArmCk: fail: stall < min", other_prearm_failures_fatal=False)
7318+
self.set_parameter("AIRSPEED_MAX", 30)
7319+
self.wait_text("Cleared: stall < min", check_context=True)
7320+
self .start_subsubtest("ArmCk: AIRSPEED cruise < min")
7321+
self.set_parameter("AIRSPEED_MIN", 25)
7322+
self.assert_prearm_failure("ArmCk: fail: stall < min", other_prearm_failures_fatal=False)
7323+
self.set_parameter("AIRSPEED_MIN", 10)
7324+
self.wait_text("Cleared: stall < min", check_context=True)
7325+
self .start_subsubtest("ArmCk: AIRSPEED cruise > max")
7326+
self.set_parameter("AIRSPEED_CRUISE", 40)
7327+
self.set_parameter("SCALING_SPEED", 40)
7328+
self.assert_prearm_failure("ArmCk: fail: stall < min", other_prearm_failures_fatal=False)
7329+
self.set_parameter("AIRSPEED_CRUISE", 22)
7330+
self.set_parameter("SCALING_SPEED", 22)
7331+
self.wait_text("Cleared: stall < min", check_context=True)
7332+
7333+
self.start_subsubtest("ArmCk: AIRSPEED_MIN must be > AIRSPEED_STALL")
7334+
''' only applies if AIRSPEED_STALL is non zero'''
7335+
self.set_parameter("AIRSPEED_STALL", 2)
7336+
self.wait_text("ArmCk: Min Speed not", check_context=True)
7337+
self.set_parameter("AIRSPEED_STALL", 8)
7338+
7339+
self .start_subsubtest("Scripted Arming Checks complete")
7340+
7341+
except Exception as e:
7342+
ex = e
7343+
self.print_exception_caught(e)
7344+
7345+
self.context_pop()
7346+
7347+
if ex is not None:
7348+
raise ex
7349+
72357350
def tests(self):
72367351
'''return list of all tests'''
72377352
ret = []
@@ -7397,6 +7512,7 @@ def tests1b(self):
73977512
self.AdvancedFailsafeBadBaro,
73987513
self.DO_CHANGE_ALTITUDE,
73997514
self.SET_POSITION_TARGET_GLOBAL_INT_for_altitude,
7515+
self.ScriptedArmingChecksApplet,
74007516
]
74017517

74027518
def disabled_tests(self):

Tools/autotest/quadplane.py

+45
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,50 @@ def terrain_height_range(mav, m):
26322632
self.mav.motors_disarmed_wait()
26332633
self.reset_SITL_commandline()
26342634

2635+
def ScriptedArmingChecksApplet(self):
2636+
""" Applet for Arming Checks will prevent a vehicle from arming based on scripted checks
2637+
"""
2638+
self .start_subtest("Scripted Arming Checks Applet validation")
2639+
self.context_push()
2640+
self.context_collect("STATUSTEXT")
2641+
ex = None
2642+
2643+
applet_script = "arming-checks.lua"
2644+
try:
2645+
"""Initialize the FC"""
2646+
self.set_parameter("SCR_ENABLE", 1)
2647+
self.install_applet_script(applet_script)
2648+
self.reboot_sitl()
2649+
self.wait_ekf_happy()
2650+
self.wait_text("ArduPilot Ready", check_context=True)
2651+
self.wait_text("Arming Checks .* loaded", timeout=30, check_context=True, regex=True)
2652+
'''self.install_messageprinter_handlers_context(['PARAM_VALUE'])'''
2653+
2654+
self .start_subsubtest("ArmCk: Q_RTL_ALT must be legal")
2655+
self.set_parameter("SCALING_SPEED", 22)
2656+
self.set_parameter("Q_RTL_ALT", 150)
2657+
self.assert_prearm_failure("ArmCk: fail: RTL_ALT", other_prearm_failures_fatal=False)
2658+
self.set_parameter("Q_RTL_ALT", 120)
2659+
self.wait_text("Cleared: RTL_ALT", check_context=True)
2660+
2661+
self.start_subsubtest("ArmCk: Q_RTL vs QLand")
2662+
''' this is only a warning'''
2663+
self.set_parameter("Q_OPTIONS", 33)
2664+
self.wait_text("ArmCk: Q will RTL", check_context=True)
2665+
self.set_parameter("Q_OPTIONS", 1)
2666+
self.wait_text("ArmCk: Q will land", check_context=True)
2667+
2668+
self .start_subsubtest("Scripted Arming Checks complete")
2669+
2670+
except Exception as e:
2671+
ex = e
2672+
self.print_exception_caught(e)
2673+
2674+
self.context_pop()
2675+
2676+
if ex is not None:
2677+
raise ex
2678+
26352679
def tests(self):
26362680
'''return list of all tests'''
26372681

@@ -2689,5 +2733,6 @@ def tests(self):
26892733
self.QLoiterRecovery,
26902734
self.FastInvertedRecovery,
26912735
self.CruiseRecovery,
2736+
self.ScriptedArmingChecksApplet,
26922737
])
26932738
return ret

0 commit comments

Comments
 (0)