Skip to content

Commit dc351bb

Browse files
committed
Tools: Autotest: Plane: Add tests for new glide mode
1 parent 3d7262e commit dc351bb

2 files changed

Lines changed: 78 additions & 5 deletions

File tree

‎Tools/autotest/arduplane.py‎

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,16 +1566,16 @@ def GCSFailsafe(self):
15661566
self.set_heartbeat_rate(self.speedup)
15671567
self.end_subtest("Completed RTL Failsafe test")
15681568

1569-
self.start_subtest("Test Failsafe: FBWA Glide")
1569+
self.start_subtest("Test Failsafe: Glide")
15701570
self.set_parameters({
15711571
"FS_LONG_ACTN": 2,
15721572
})
15731573
self.change_mode('AUTO')
15741574
self.progress("Disconnecting GCS")
15751575
self.set_heartbeat_rate(0)
1576-
self.wait_mode("FBWA", timeout=10)
1576+
self.wait_mode(27, timeout=10) # Glide, need pymavlink support to use text name
15771577
self.set_heartbeat_rate(self.speedup)
1578-
self.end_subtest("Completed FBWA Failsafe test")
1578+
self.end_subtest("Completed Glide Failsafe test")
15791579

15801580
self.start_subtest("Test Failsafe: Deploy Parachute")
15811581
self.load_mission("plane-parachute-mission.txt")
@@ -1590,6 +1590,74 @@ def GCSFailsafe(self):
15901590
self.reboot_sitl()
15911591
self.end_subtest("Completed Parachute Failsafe test")
15921592

1593+
def GlideFailsafeThrottle(self):
1594+
'''Ensure throttle is forced to zero in the glide failsafe and pilot authority returns on recovery'''
1595+
self.set_parameters({
1596+
"FS_SHORT_ACTN": 2, # short failsafe action: glide
1597+
"FS_LONG_ACTN": 2, # long failsafe action: glide, so we stay in the glide
1598+
"THR_MIN": 20, # non-zero so a zeroed throttle is distinct from throttle min
1599+
})
1600+
self.takeoff(50, mode='TAKEOFF')
1601+
# TAKEOFF takes no short failsafe action, CRUISE does and holds altitude on auto throttle
1602+
self.change_mode('CRUISE')
1603+
self.context_collect('STATUSTEXT')
1604+
self.progress("Failing receiver to trigger glide failsafe")
1605+
self.set_parameter("SIM_RC_FAIL", 1) # no pulses
1606+
self.wait_statustext("RC Short Failsafe: switched to Glide", check_context=True)
1607+
self.wait_mode(27) # Glide, need pymavlink support to use text name
1608+
self.drain_mav() # make sure we have the latest throttle output
1609+
# throttle must be forced to zero (SERVO3_MIN), not held at THR_MIN
1610+
self.assert_servo_channel_value(3, self.get_parameter("SERVO3_MIN"))
1611+
1612+
self.progress("Waiting for long failsafe, we should stay in the glide")
1613+
self.wait_statustext("RC Long Failsafe On", check_context=True)
1614+
self.assert_mode(27)
1615+
1616+
self.progress("Restoring receiver, long failsafe does not restore the mode")
1617+
self.set_parameter("SIM_RC_FAIL", 0)
1618+
self.wait_statustext("RC Long Failsafe Cleared", check_context=True)
1619+
self.assert_mode(27)
1620+
1621+
self.progress("Pilot must be able to leave the glide and regain throttle")
1622+
self.change_mode("FBWA")
1623+
self.set_rc(3, 1800)
1624+
self.wait_servo_channel_value(3, 1500, comparator=operator.ge, timeout=5)
1625+
self.set_rc(3, 1500)
1626+
self.fly_home_land_and_disarm()
1627+
1628+
def GlideFailsafeThrottleReverse(self):
1629+
'''Ensure reverse thrust goes to zero, not full reverse, in the glide failsafe'''
1630+
# the reverse thrust sim model interprets throttle as an angle
1631+
# output: 1000 = full reverse, 1500 = zero thrust, 2000 = full forward
1632+
self.customise_SITL_commandline([], model="plane-revthrust", wipe=True)
1633+
self.set_parameters({
1634+
"THR_MIN": -100, # negative THR_MIN enables reverse thrust
1635+
"SERVO3_MIN": 1000,
1636+
"SERVO3_TRIM": 1500, # zero-thrust point for a reversible ESC
1637+
"SERVO3_MAX": 2000,
1638+
"FS_SHORT_ACTN": 2, # short failsafe action: glide
1639+
"FS_LONG_ACTN": 2, # long failsafe action: glide, so we stay in the glide
1640+
})
1641+
# take off in TAKEOFF mode: auto throttle avoids the reverse-thrust
1642+
# stick mapping and never commands reverse during the climb
1643+
self.takeoff(50, mode='TAKEOFF')
1644+
# TAKEOFF takes no short failsafe action, CRUISE does and holds altitude on auto throttle
1645+
self.change_mode('CRUISE')
1646+
self.context_collect('STATUSTEXT')
1647+
self.progress("Failing receiver to trigger glide failsafe")
1648+
self.set_parameter("SIM_RC_FAIL", 1) # no pulses
1649+
self.wait_statustext("RC Short Failsafe: switched to Glide", check_context=True)
1650+
self.wait_mode(27) # Glide, need pymavlink support to use text name
1651+
self.drain_mav() # make sure we have the latest throttle output
1652+
1653+
def within_10(got, want):
1654+
return abs(got - want) <= 10
1655+
1656+
# zero thrust is SERVO3_TRIM (1500); the FBWA glide drove full reverse (SERVO3_MIN, 1000)
1657+
self.assert_servo_channel_value(3, self.get_parameter("SERVO3_TRIM"), comparator=within_10)
1658+
self.set_parameter("SIM_RC_FAIL", 0)
1659+
self.fly_home_land_and_disarm()
1660+
15931661
def TestGripperMission(self):
15941662
'''Test Gripper mission items'''
15951663
self.set_parameter("RTL_AUTOLAND", 1)
@@ -9877,6 +9945,7 @@ def AVAILABLE_MODES(self):
98779945
16: "Initialising",
98789946
24: "Thermal",
98799947
26: "Autoland",
9948+
27: "Glide",
98809949
}
98819950
initialising = self.get_mode_from_mode_mapping("INITIALISING")
98829951
modes = self.assert_available_modes(expected_modes, not_user_selectable=[initialising])
@@ -9887,8 +9956,9 @@ def AVAILABLE_MODES(self):
98879956
self.start_subtest("modes blocked by FLTMODE_GCSBLOCK are not user-selectable")
98889957
circle = self.get_mode_from_mode_mapping("CIRCLE")
98899958
guided = self.get_mode_from_mode_mapping("GUIDED")
9890-
self.set_parameter("FLTMODE_GCSBLOCK", (1 << 1) | (1 << 13)) # CIRCLE and GUIDED
9891-
self.assert_available_modes(expected_modes, not_user_selectable=[initialising, circle, guided])
9959+
glide = 27 # Glide, need pymavlink support to use text name
9960+
self.set_parameter("FLTMODE_GCSBLOCK", (1 << 1) | (1 << 13) | (1 << 22)) # CIRCLE, GUIDED and Glide
9961+
self.assert_available_modes(expected_modes, not_user_selectable=[initialising, circle, guided, glide])
98929962
self.set_parameter("FLTMODE_GCSBLOCK", 0)
98939963

98949964
self.start_subtest("request the first and last modes by index")
@@ -10932,6 +11002,8 @@ def tests1b(self):
1093211002
self.MissionJumpTags,
1093311003
self.JumpBestLandSequence,
1093411004
Test(self.GCSFailsafe, speedup=8),
11005+
self.GlideFailsafeThrottle,
11006+
self.GlideFailsafeThrottleReverse,
1093511007
self.RudderArmedTakeoffRequiresNeutralThrottle,
1093611008
self.MAV_CMD_DO_AUTOTUNE_ENABLE,
1093711009
self.MAV_CMD_NAV_ALTITUDE_WAIT,

‎Tools/autotest/quadplane.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,6 +4061,7 @@ def AVAILABLE_MODES(self):
40614061
24: "Thermal",
40624062
25: "Loiter to QLand",
40634063
26: "Autoland",
4064+
27: "Glide",
40644065
}
40654066
initialising = self.get_mode_from_mode_mapping("INITIALISING")
40664067
self.assert_available_modes(expected_modes, not_user_selectable=[initialising])

0 commit comments

Comments
 (0)