ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Plane: Takeoff improvements

Open Georacer opened this issue 6 months ago • 7 comments

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

  1. Mode TAKEOFF and AUTO now behave identically during a takeoff.
  2. TKOFF_LVL_ALT now also affects AUTO mode.
  3. TAKEOFF mode now respects the level-off angles, as it approaches altitude. There should now be significantly less overshoot.
  4. The behaviour of TKOFF_ROTATION_SPD now works as advertized. It was inactive before.

Notable code changes

  1. Mode TAKEOFF now spends all of the climb in FlightStage::TAKEOFF, just like AUTO mode did.
  2. TECS::set_pitch_max_limit() is now split into TECS::set_pitch_max() and TECS::set_pitch_min(). Its usage in quadplane.cpp has been modified accordingly.
  3. TECS pitch limits are now applied at the end of the calculation. Before, vertical acceleration limitations were applied last.
  4. TECS: _post_TO_hgt_offset will now never pull height demand above the target altitude.
  5. mode_takeoff.cpp is now prevented from switching behaviours from past TKOFF_ALT-2m back to climb behaviour. This would cause behaviour switching if the plane would drop slightly lower than 2m from TKOFF_ALT.
  6. 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.
  7. Changed behaviour of TECS_PITCH_MIN to match description.
  8. servos.cpp now doesn't try to enforce all of the takeoff throttle logic combinations. Only TKOFF_THR_MAX and TKOFF_THR_MIN.

Tests

The following were tested in autotests:

  1. Altitude and pitch no longer oscillation upon reaching the takeoff altitude. ✅
  2. TAKEOFF and AUTO takeoffs now behave exactly the same in all combinations of ARSPD_USE and TKOFF_OPTIONS. ✅
  3. The level-off of minimum pitch demand now works in TAKEOFF. ✅
  4. 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:

  1. Altitude and pitch no longer oscillation upon reaching the takeoff altitude. ✅
  2. The level-off of minimum pitch demand now works in TAKEOFF. ✅
  3. 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

  1. Ground speed is used in some airspeed comparisons.
  2. 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.
  3. 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

  1. 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.
  2. Render TKOFF_LVL_ALT a higher-level parameter, as it is now used also by AUTO mode, not just TAKEOFF.

Georacer avatar Aug 05 '24 15:08 Georacer