Skip to content

Commit

Permalink
Test RNG_HOLD
Browse files Browse the repository at this point in the history
  • Loading branch information
clydemcqueen committed Jul 18, 2023
1 parent aa37855 commit 3f53395
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions Tools/autotest/ardusub.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def AltitudeHold(self):
raise NotAchievedException("Did not get GLOBAL_POSITION_INT")
pwm = 1300
if msg.relative_alt/1000.0 < -6.0:
# need to g`o up, not down!
# need to go up, not down!
pwm = 1700
self.set_rc(Joystick.Throttle, pwm)
self.wait_altitude(altitude_min=-6, altitude_max=-5)
Expand Down Expand Up @@ -166,8 +166,33 @@ def AltitudeHold(self):
self.watch_altitude_maintained()
self.disarm_vehicle()

def RangeHold(self):
"""Test RNG_HOLD mode"""
self.wait_ready_to_arm()
self.arm_vehicle()
self.change_mode('ALT_HOLD')

# Dive so that rangefinder can see the seafloor
msg = self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True, timeout=5)
if msg is None:
raise NotAchievedException("Did not get GLOBAL_POSITION_INT")
pwm = 1300
if msg.relative_alt/1000.0 < -41.0:
pwm = 1700
self.set_rc(Joystick.Throttle, pwm)
self.wait_altitude(altitude_min=-41, altitude_max=-40, relative=False, timeout=60)
self.set_rc(Joystick.Throttle, 1500)

# Let the vehicle settle
self.delay_sim_time(1)

# Switch to RNG_HOLD
self.change_mode(21)
self.watch_altitude_maintained()
self.disarm_vehicle()

def ModeChanges(self, delta=0.2):
"""Check if alternating between ALTHOLD, STABILIZE and POSHOLD affects altitude"""
"""Check if alternating between ALTHOLD, STABILIZE, POSHOLD and RNG_HOLD (mode 21) affects altitude"""
self.wait_ready_to_arm()
self.arm_vehicle()
# zero buoyancy and no baro noise
Expand All @@ -187,12 +212,16 @@ def ModeChanges(self, delta=0.2):
self.delay_sim_time(2)
self.change_mode('STABILIZE')
self.delay_sim_time(2)
self.change_mode(21)
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(21)
self.delay_sim_time(2)
self.change_mode('MANUAL')
self.disarm_vehicle()
final_altitude = self.mav.recv_match(type='VFR_HUD', blocking=True).alt
Expand Down Expand Up @@ -432,6 +461,7 @@ def tests(self):
ret.extend([
self.DiveManual,
self.AltitudeHold,
self.RangeHold,
self.PositionHold,
self.ModeChanges,
self.DiveMission,
Expand Down

0 comments on commit 3f53395

Please sign in to comment.