Skip to content

Commit

Permalink
autotest: add test for stuck tether simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabsingh3003 authored and tridge committed Dec 9, 2024
1 parent 99f4f13 commit 031b526
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8304,6 +8304,57 @@ def WatchAlts(self):

self.do_RTL()

def TestTetherStuck(self):
"""Test tethered vehicle stuck because of tether"""
# Enable tether simulation
self.set_parameters({
"SIM_TETH_ENABLE": 1,
})
self.delay_sim_time(2)
self.reboot_sitl()

# Set tether line length
self.set_parameters({
"SIM_TETH_LINELEN": 10,
})
self.delay_sim_time(2)

# Prepare and take off
self.wait_ready_to_arm()
self.arm_vehicle()
self.takeoff(10, mode='LOITER')

# Simulate vehicle getting stuck by increasing RC throttle
self.set_rc(3, 1900)
self.delay_sim_time(5, reason='let tether get stuck')

# Monitor behavior for 10 seconds
tstart = self.get_sim_time()
initial_alt = self.get_altitude()
stuck = True # Assume it's stuck unless proven otherwise

while self.get_sim_time() - tstart < 10:
# Fetch current altitude
current_alt = self.get_altitude()
self.progress(f"current_alt={current_alt}")

# Fetch and log battery status
battery_status = self.mav.recv_match(type='BATTERY_STATUS', blocking=True, timeout=1)
if battery_status:
self.progress(f"Battery: {battery_status}")

# Check if the vehicle is stuck.
# We assume the vehicle is stuck if the current is high and the altitude is not changing
if battery_status and (battery_status.current_battery < 6500 or abs(current_alt - initial_alt) > 2):
stuck = False # Vehicle moved or current is abnormal
break

if not stuck:
raise NotAchievedException("Vehicle did not get stuck as expected")

# Land and disarm the vehicle to ensure we can go down
self.land_and_disarm()

def fly_rangefinder_drivers_fly(self, rangefinders):
'''ensure rangefinder gives height-above-ground'''
self.change_mode('GUIDED')
Expand Down Expand Up @@ -12330,6 +12381,7 @@ def tests2b(self): # this block currently around 9.5mins here
self.MAV_CMD_MISSION_START_p1_p2,
self.ScriptingAHRSSource,
self.CommonOrigin,
self.TestTetherStuck,
])
return ret

Expand Down

0 comments on commit 031b526

Please sign in to comment.