@@ -7232,6 +7232,121 @@ def Volz(self):
7232
7232
if abs (m .Pos - m .PosCmd ) > 20 :
7233
7233
break
7234
7234
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
+
7235
7350
def tests (self ):
7236
7351
'''return list of all tests'''
7237
7352
ret = []
@@ -7397,6 +7512,7 @@ def tests1b(self):
7397
7512
self .AdvancedFailsafeBadBaro ,
7398
7513
self .DO_CHANGE_ALTITUDE ,
7399
7514
self .SET_POSITION_TARGET_GLOBAL_INT_for_altitude ,
7515
+ self .ScriptedArmingChecksApplet ,
7400
7516
]
7401
7517
7402
7518
def disabled_tests (self ):
0 commit comments