Tools: Sub: add test to make sure changing modes does not cause altitude changes

This commit is contained in:
Willian Galvani 2022-09-27 23:41:41 -03:00
parent b90079bfa6
commit 650e8652a9

View File

@ -166,6 +166,42 @@ class AutoTestSub(AutoTest):
self.watch_altitude_maintained()
self.disarm_vehicle()
def ModeChanges(self, delta=0.2):
"""Check if alternating between ALTHOLD, STABILIZE and POSHOLD affects altitude"""
self.wait_ready_to_arm()
self.arm_vehicle()
# zero buoyancy and no baro noise
self.set_parameter("SIM_BUOYANCY", 0)
self.set_parameter("SIM_BARO_RND", 0)
# dive a bit to make sure we are not surfaced
self.change_mode('STABILIZE')
self.set_rc(Joystick.Throttle, 1350)
self.delay_sim_time(10)
self.set_rc(Joystick.Throttle, 1500)
self.delay_sim_time(3)
# start the test itself, go through some modes and check if anything changes
previous_altitude = self.mav.recv_match(type='VFR_HUD', blocking=True).alt
self.change_mode('ALT_HOLD')
self.delay_sim_time(2)
self.change_mode('POSHOLD')
self.delay_sim_time(2)
self.change_mode('STABILIZE')
self.delay_sim_time(2)
self.change_mode('ALT_HOLD')
self.delay_sim_time(2)
self.change_mode('STABILIZE')
self.delay_sim_time(2)
self.change_mode('ALT_HOLD')
self.delay_sim_time(2)
self.change_mode('MANUAL')
self.disarm_vehicle()
final_altitude = self.mav.recv_match(type='VFR_HUD', blocking=True).alt
if abs(previous_altitude - final_altitude) > delta:
raise NotAchievedException(
"Changing modes affected depth with no throttle input!, started at {}, ended at {}"
.format(previous_altitude, final_altitude)
)
def PositionHold(self):
"""Test POSHOLD mode"""
self.wait_ready_to_arm()
@ -407,6 +443,7 @@ class AutoTestSub(AutoTest):
self.DiveManual,
self.AltitudeHold,
self.PositionHold,
self.ModeChanges,
self.DiveMission,
self.GripperMission,
self.DoubleCircle,