Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane: Fix inability to climb the last few meters of takeoff #28792

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

Georacer
Copy link
Contributor

@Georacer Georacer commented Dec 1, 2024

Summary

This PR addresses #28685 and supersedes #28707.

Details

This affects takeoffs without an airspeed sensor.

Cause

Some airframes will not climb at 0 pitch, regardless of throttle setting.
Thus, the current takeoff level-off strategy of asymptotically forcing pitch to 0, results in the aircraft to never climb the final few meters.

Reproduction

The behaviour was reproduced in SITL, by setting:

  • PTCH_TRIM_DEG: -10.0
  • TKOFF_THR_MAX: 75.0

Solution

After the expected time to complete the takeoff has elapsed, drive the desired pitch gradually back to takeoff pitch, over the next 5 seconds.

Testing

Before:
The plane starts level off but manages to climb only up to 45m and hovers there, stuck in takeoff stage.
Screenshot from 2024-12-01 19-49-33

After:
The takeoff times out after 2s (TKOFF_PLIM_SEC) of being in the level-off maneuver.
Screenshot from 2024-12-01 19-50-37

Alternatives

The proposed solution of widening the TECS pitch limits and letting TECS take over and regulate the last few meters of the climb was not feasible:
During an airspeedless takeoff, TECS uses throttle to correct for altitude errors.
It would use pitch (if it was allowed) to correct for airspeed errors).
Thus letting TECS command the pitch angle would not help.

The previous PR #28707 was deemed too complicated and too heavy-handed. This present PR prefers to hand over altitude control to TECS.

@@ -119,14 +119,15 @@ void ModeTakeoff::update()
gcs().send_text(MAV_SEVERITY_INFO, "Takeoff to %.0fm for %.1fm heading %.1f deg",
alt, dist, direction);
plane.takeoff_state.start_time_ms = millis();
plane.takeoff_state.level_off_start_time_ms = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to hunt for all the possible places where we would need a reset of this parameter.

if (takeoff_state.level_off_start_time_ms > 0) {
// A takeoff is in progress.
uint32_t now = AP_HAL::millis();
if ((now - takeoff_state.level_off_start_time_ms) > (uint32_t)(1000U * g.takeoff_pitch_limit_reduction_sec)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@peterbarker is this the right way to check a timeout in the face of time folding?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please investigate if sec_to_target needs to be multiplied by a factor of 2.

In case of linear decrease of pitch / climb-rate, the plane ends up half-way and mathematically does not converge to target altitude.

That is what I came up with during a dozen test flights with 4 different SW changes over the weekend.

I have no clue why this works in Plane 4.5.7.

When an airspeed sensor is not used, during a takeoff, the pitch angle
is asymptotically driven to 0 as the takeoff altitude is approached.
Some airplanes will then stop climbing and fail to reach altitude.

To prevent an indefinite wait for the takeoff altitude to be reached, a
dedicated level-off timeout has been introduced.
@Georacer Georacer force-pushed the pr/takeoff_level_off_bugfix_2 branch from ef77e21 to 5c9f41c Compare December 1, 2024 20:40
@tridge tridge merged commit 9a5f81a into ArduPilot:master Dec 4, 2024
96 checks passed
@Georacer Georacer deleted the pr/takeoff_level_off_bugfix_2 branch December 5, 2024 09:38
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