mirror of https://github.com/ArduPilot/ardupilot
autotest: add test for mount retract on rc failsafe
This commit is contained in:
parent
9dfcb487cf
commit
500ec85e52
|
@ -708,6 +708,48 @@ class AutoTestHelicopter(AutoTestCopter):
|
||||||
self.change_mode('LOITER')
|
self.change_mode('LOITER')
|
||||||
self.fly_mission_points(self.scurve_nasty_up_mission())
|
self.fly_mission_points(self.scurve_nasty_up_mission())
|
||||||
|
|
||||||
|
def MountFailsafeAction(self):
|
||||||
|
"""Fly Mount Failsafe action"""
|
||||||
|
self.context_push()
|
||||||
|
|
||||||
|
self.progress("Setting up servo mount")
|
||||||
|
roll_servo = 12
|
||||||
|
pitch_servo = 11
|
||||||
|
yaw_servo = 10
|
||||||
|
open_servo = 9
|
||||||
|
roll_limit = 50
|
||||||
|
self.set_parameters({
|
||||||
|
"MNT1_TYPE": 1,
|
||||||
|
"SERVO%u_MIN" % roll_servo: 1000,
|
||||||
|
"SERVO%u_MAX" % roll_servo: 2000,
|
||||||
|
"SERVO%u_FUNCTION" % yaw_servo: 6, # yaw
|
||||||
|
"SERVO%u_FUNCTION" % pitch_servo: 7, # roll
|
||||||
|
"SERVO%u_FUNCTION" % roll_servo: 8, # pitch
|
||||||
|
"SERVO%u_FUNCTION" % open_servo: 9, # mount open
|
||||||
|
"MNT1_OPTIONS": 2, # retract
|
||||||
|
"MNT1_DEFLT_MODE": 3, # RC targettting
|
||||||
|
"MNT1_ROLL_MIN": -roll_limit,
|
||||||
|
"MNT1_ROLL_MAX": roll_limit,
|
||||||
|
})
|
||||||
|
|
||||||
|
self.reboot_sitl()
|
||||||
|
|
||||||
|
retract_roll = 25.0
|
||||||
|
self.set_parameter("MNT1_NEUTRAL_X", retract_roll)
|
||||||
|
self.progress("Killing RC")
|
||||||
|
self.set_parameter("SIM_RC_FAIL", 2)
|
||||||
|
self.delay_sim_time(10)
|
||||||
|
want_servo_channel_value = int(1500 + 500*retract_roll/roll_limit)
|
||||||
|
self.wait_servo_channel_value(roll_servo, want_servo_channel_value, epsilon=1)
|
||||||
|
|
||||||
|
self.progress("Resurrecting RC")
|
||||||
|
self.set_parameter("SIM_RC_FAIL", 0)
|
||||||
|
self.wait_servo_channel_value(roll_servo, 1500)
|
||||||
|
|
||||||
|
self.context_pop()
|
||||||
|
|
||||||
|
self.reboot_sitl()
|
||||||
|
|
||||||
def set_rc_default(self):
|
def set_rc_default(self):
|
||||||
super(AutoTestHelicopter, self).set_rc_default()
|
super(AutoTestHelicopter, self).set_rc_default()
|
||||||
self.progress("Lowering rotor speed")
|
self.progress("Lowering rotor speed")
|
||||||
|
@ -1122,6 +1164,7 @@ class AutoTestHelicopter(AutoTestCopter):
|
||||||
self.NastyMission,
|
self.NastyMission,
|
||||||
self.PIDNotches,
|
self.PIDNotches,
|
||||||
self.AutoTune,
|
self.AutoTune,
|
||||||
|
self.MountFailsafeAction,
|
||||||
])
|
])
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -7939,7 +7939,7 @@ class TestSuite(ABC):
|
||||||
(str(m), channel_field))
|
(str(m), channel_field))
|
||||||
return m_value
|
return m_value
|
||||||
|
|
||||||
def wait_servo_channel_value(self, channel, value, timeout=2, comparator=operator.eq):
|
def wait_servo_channel_value(self, channel, value, epsilon=0, timeout=2, comparator=operator.eq):
|
||||||
"""wait for channel value comparison (default condition is equality)"""
|
"""wait for channel value comparison (default condition is equality)"""
|
||||||
channel_field = "servo%u_raw" % channel
|
channel_field = "servo%u_raw" % channel
|
||||||
opstring = ("%s" % comparator)[-3:-1]
|
opstring = ("%s" % comparator)[-3:-1]
|
||||||
|
@ -7957,8 +7957,11 @@ class TestSuite(ABC):
|
||||||
if m_value is None:
|
if m_value is None:
|
||||||
raise ValueError("message (%s) has no field %s" %
|
raise ValueError("message (%s) has no field %s" %
|
||||||
(str(m), channel_field))
|
(str(m), channel_field))
|
||||||
self.progress("want SERVO_OUTPUT_RAW.%s=%u %s %u" %
|
self.progress("SERVO_OUTPUT_RAW.%s got=%u %s want=%u" %
|
||||||
(channel_field, m_value, opstring, value))
|
(channel_field, m_value, opstring, value))
|
||||||
|
if comparator == operator.eq:
|
||||||
|
if abs(m_value - value) <= epsilon:
|
||||||
|
return m_value
|
||||||
if comparator(m_value, value):
|
if comparator(m_value, value):
|
||||||
return m_value
|
return m_value
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue