ardupilot
ardupilot copied to clipboard
Plane: Takeoff improvements
This PR fixes TECS oscillations that would occur once mode TAKEOFF would reach TKOFF_ALT
.
Additionally, it harmonizes the takeoff behaviour between modes AUTO and TAKEOFF.
Finally, it fixes a few bugs.
Many thanks to @Hwurzburg for sharing code for fixing the pitch setpoint.
Notable behaviour changes
- Mode TAKEOFF and AUTO now behave identically during a takeoff.
-
TKOFF_LVL_ALT
now also affects AUTO mode. - TAKEOFF mode now respects the level-off angles, as it approaches altitude. There should now be significantly less overshoot.
- The behaviour of TKOFF_ROTATION_SPD now works as advertized. It was inactive before.
Notable code changes
- Mode TAKEOFF now spends all of the climb in FlightStage::TAKEOFF, just like AUTO mode did.
-
TECS::set_pitch_max_limit()
is now split intoTECS::set_pitch_max()
andTECS::set_pitch_min()
. Its usage inquadplane.cpp
has been modified accordingly. - TECS pitch limits are now applied at the end of the calculation. Before, vertical acceleration limitations were applied last.
- TECS:
_post_TO_hgt_offset
will now never pull height demand above the target altitude. -
mode_takeoff.cpp
is now prevented from switching behaviours from pastTKOFF_ALT
-2m back to climb behaviour. This would cause behaviour switching if the plane would drop slightly lower than 2m fromTKOFF_ALT
. - There are many occasions were TECS is overridden both in pitch and throttle. When that happens, TECS is now effectively inactive and will reset itself.
- Changed behaviour of
TECS_PITCH_MIN
to match description. -
servos.cpp
now doesn't try to enforce all of the takeoff throttle logic combinations. OnlyTKOFF_THR_MAX
andTKOFF_THR_MIN
.
Tests
The following were tested in autotests:
- Altitude and pitch no longer oscillation upon reaching the takeoff altitude. ✅
- TAKEOFF and AUTO takeoffs now behave exactly the same in all combinations of
ARSPD_USE
andTKOFF_OPTIONS
. ✅ - The level-off of minimum pitch demand now works in TAKEOFF. ✅
- When
TKOFF_ROTATE_SPD
is nonzero, pitch demand will be 5deg before the rotation speed and will climb up to the minimum takeoff pitch for groundspeed equal to cruise airspeed. ✅
The following were tested in manual SITL:
- Altitude and pitch no longer oscillation upon reaching the takeoff altitude. ✅
- The level-off of minimum pitch demand now works in TAKEOFF. ✅
- When
TKOFF_ROTATE_SPD
is nonzero, pitch demand will be 5deg before the rotation speed and will climb up to the minimum takeoff pitch for groundspeed equal to cruise airspeed. ✅
Known issues
- Ground speed is used in some airspeed comparisons.
- If AUTO is engaged while in flight and has a NAV_TAKEOFF point, it will force the pitch to positive while it gets processed. This lasts for a few cycles.
- The SITL plane doesn't regulate pitch well when it's flying at full throttle and fast. Nothing to do with this PR, just an observation.
Future work
- I noticed that if you load a mission before you get a GNSS fix, the NAV_TAKEOFF waypoint (i.e. next_WP_loc) will be set at coordinates at the home coordinates and altitude. This can break some takeoff logic in AUTO mode.
- Render
TKOFF_LVL_ALT
a higher-level parameter, as it is now used also by AUTO mode, not just TAKEOFF.