Skip to content

autotest: add a test for AUTO takeoff while moving - #35129

Open
haaaaaaarshs wants to merge 2 commits into
ArduPilot:masterfrom
haaaaaaarshs:fix/6322-inflight-takeoff
Open

haaaaaaarshs wants to merge 2 commits into
ArduPilot:masterfrom
haaaaaaarshs:fix/6322-inflight-takeoff

Conversation

@haaaaaaarshs

Copy link
Copy Markdown

Summary

Add a Copter SITL test for an AUTO takeoff started while moving.

Related to #6322.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

On commit ce01d4c, based on 546cf15, the Copter build, TakeoffAlt,
TakeoffCheck, and AutoTakeoffWhileMoving passed. The autotest command and
flake8 each exited with status 0. The moving-takeoff test recorded 18.7
seconds of samples, a maximum gap of 50 ms, and a maximum return of 0.38 m.

A broader CopterTests1d run on November 10 failed when FETtecESC and
CircleManualControlEntryLeft timed out waiting for messages. The cause
is unknown. That run used the earlier version of the test. The full
Linux CI matrix has not been run locally.

Description

The test sets MIS_RESTART=1, takes off in LOITER, moves forward, and
switches to AUTO with a 50 m takeoff command first in the mission. It
measures return along the initial direction until the mission reports
item 2, using a 1.5 m limit.

I did not reproduce the substantial return described in #6322 in two
manual attempts on an earlier checkout. The test does not establish
that the issue is fixed. The tolerance is provisional, and the
mission-item message may arrive slightly after the transition. Feedback
on the scenario and tolerance would be helpful.

Notes for Reviewers

I used Claude to revise the tests, for PR prechecks as well as interpreting the SITL results.

@peterbarker peterbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be more satisfying if we could close the issue based on it.

Try making the vehicle go faster to see if you can reproduce?

Comment thread Tools/autotest/arducopter.py Outdated

def AutoTakeoffWhileMoving(self):
"""Check horizontal motion during an airborne AUTO takeoff."""
self.context_push()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.context_push()

not required, nor is the closing context pop

Comment thread Tools/autotest/arducopter.py Outdated
Comment on lines +5954 to +5955
finally:
self.context_pop()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
finally:
self.context_pop()

Comment thread Tools/autotest/arducopter.py Outdated
Comment on lines +5952 to +5953
self.change_mode('LOITER')
self.do_RTL()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.change_mode('LOITER')
self.do_RTL()
self.disarm_vehicle(force=True)

Comment thread Tools/autotest/arducopter.py Outdated
Comment on lines +5873 to +5878
motion = self.assert_receive_message('LOCAL_POSITION_NED')
speed = (motion.vx ** 2 + motion.vy ** 2) ** 0.5
if speed < 3:
raise NotAchievedException(
f'Initial horizontal speed was only {speed:.2f} m/s'
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you just wait for groundspeed to be achieved?!

Comment thread Tools/autotest/arducopter.py Outdated
self.wait_current_waypoint(1)
takeoff_started = True
self.delay_sim_time(8, reason='observe airborne AUTO takeoff')
self.assert_current_waypoint(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've just waited for this to be the current waypoint

Comment thread Tools/autotest/arducopter.py Outdated
self.set_rc(2, 1500)
self.wait_current_waypoint(1)
takeoff_started = True
self.delay_sim_time(8, reason='observe airborne AUTO takeoff')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI time isn't unlimited, prune your delays where they aren't required.

Comment thread Tools/autotest/arducopter.py Outdated
self.delay_sim_time(8, reason='observe airborne AUTO takeoff')
self.assert_current_waypoint(1)
self.wait_groundspeed(0, 0.6, timeout=10, minimum_duration=1)
self.assert_current_waypoint(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh?

@haaaaaaarshs

Copy link
Copy Markdown
Author

Hey Peter, thanks for taking a look! The SITL runs at around 10 m/s measured a maximum return of 0.58 m, so I still haven’t seen the larger return described in the issue under those conditions.I will work through your suggestions for simplifying the test and will update the PR after checking the changes.

@rmackay9

Copy link
Copy Markdown
Contributor

Hi @haaaaaaarshs,

Txs for this. What's the purpose of the test though? Is there some issue you've seen taking off from a moving vehicle?

@haaaaaaarshs

Copy link
Copy Markdown
Author

Hi @rmackay9, the copter is already in the air and moving forward when it switches to AUTO with a takeoff command as the first item in the mission. The test checks for the backward movement described in the issue.

I haven’t been able to reproduce the larger return myself. In my latest SITL run, the copter was moving at 10.17 m/s, and the maximum return was 0.57 m. Do you think this test is still useful even though I couldn’t reproduce the original behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants