Skip to content

Commit

Permalink
Tools: fix helicopter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bnsgeyer authored Apr 22, 2024
1 parent 63faf03 commit d90d61b
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions Tools/autotest/helicopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,22 +872,9 @@ def AutoTune(self):
self.change_mode('AUTOTUNE')

tstart = self.get_sim_time()
sim_time_expected = 5000
deadline = tstart + sim_time_expected
while self.get_sim_time_cached() < deadline:
now = self.get_sim_time_cached()
m = self.mav.recv_match(type='STATUSTEXT',
blocking=True,
timeout=1)
if m is None:
continue
self.progress("STATUSTEXT (%u<%u): %s" % (now, deadline, m.text))
if "AutoTune: Success" in m.text:
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))
continue

raise NotAchievedException("AUTOTUNE failed (%u seconds)" %
(self.get_sim_time() - tstart))
self.wait_statustext('AutoTune: Success', timeout=1000)
now = self.get_sim_time()
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))

self.set_rc(3, 1000)
self.context_collect('STATUSTEXT')
Expand All @@ -914,8 +901,14 @@ def AutoTune(self):
self.wait_statustext('AutoTune: Success', timeout=1000)
now = self.get_sim_time()
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))
self.land_and_disarm()

self.set_rc(3, 1000)
self.context_collect('STATUSTEXT')
self.wait_statustext(r"SIM Hit ground at ([0-9.]+) m/s",
check_context=True,
regex=True)
self.set_rc(8, 1000)
self.wait_disarmed()

# test Roll rate P and Rate D tuning
self.set_parameters({
Expand All @@ -934,8 +927,14 @@ def AutoTune(self):
self.wait_statustext('AutoTune: Success', timeout=1000)
now = self.get_sim_time()
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))
self.land_and_disarm()

self.set_rc(3, 1000)
self.context_collect('STATUSTEXT')
self.wait_statustext(r"SIM Hit ground at ([0-9.]+) m/s",
check_context=True,
regex=True)
self.set_rc(8, 1000)
self.wait_disarmed()

# test Roll and pitch angle P tuning
self.set_parameters({
Expand All @@ -956,8 +955,14 @@ def AutoTune(self):
self.wait_statustext('AutoTune: Success', timeout=1000)
now = self.get_sim_time()
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))
self.land_and_disarm()

self.set_rc(3, 1000)
self.context_collect('STATUSTEXT')
self.wait_statustext(r"SIM Hit ground at ([0-9.]+) m/s",
check_context=True,
regex=True)
self.set_rc(8, 1000)
self.wait_disarmed()

# test yaw FF and rate P and Rate D
self.set_parameters({
Expand All @@ -978,8 +983,14 @@ def AutoTune(self):
self.wait_statustext('AutoTune: Success', timeout=1000)
now = self.get_sim_time()
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))
self.land_and_disarm()

self.set_rc(3, 1000)
self.context_collect('STATUSTEXT')
self.wait_statustext(r"SIM Hit ground at ([0-9.]+) m/s",
check_context=True,
regex=True)
self.set_rc(8, 1000)
self.wait_disarmed()

# test yaw angle P tuning
self.set_parameters({
Expand All @@ -1000,8 +1011,14 @@ def AutoTune(self):
self.wait_statustext('AutoTune: Success', timeout=1000)
now = self.get_sim_time()
self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart))
self.land_and_disarm()

self.set_rc(3, 1000)
self.context_collect('STATUSTEXT')
self.wait_statustext(r"SIM Hit ground at ([0-9.]+) m/s",
check_context=True,
regex=True)
self.set_rc(8, 1000)
self.wait_disarmed()

def tests(self):
'''return list of all tests'''
Expand Down

0 comments on commit d90d61b

Please sign in to comment.