Skip to content

Commit 8b3f392

Browse files
committed
Plane: Fix level-off and throttle without airspeed sensor
This patch intends to fix two issues with auto takeoff mission item for planes without airspeed sensor. Level-off fix: - Correct the level-off condition by factor 2 because with decreasing pitch, also the climb-rate decreses if decreased linearly, it can only reach half of it. - Add flag for level-off stage and let TECS handle the final climb. Throttle without airspeed sensor: - Remove conditional evaluation of airspeed sensor to enable traditional throttle range also without airspeed sensor. It is to be discussed if that flag in takeoff options is to be reversed to keep the behavior from Plane 4.5.7 consistent with Plane 4.6 onwards.
1 parent 10209a2 commit 8b3f392

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ArduPlane/Plane.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ class Plane : public AP_Vehicle {
454454
float throttle_lim_min;
455455
uint32_t throttle_max_timer_ms;
456456
// Good candidate for keeping the initial time for TKOFF_THR_MAX_T.
457+
458+
bool in_level_off_phase;
459+
// The Flag to indicate the last phase of takeoff, the pitch level-off to neutral.
457460
} takeoff_state;
458461

459462
// ground steering controller state

ArduPlane/takeoff.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void Plane::takeoff_calc_pitch(void)
208208
bool pitch_clipped_max = false;
209209

210210
// If we're using an airspeed sensor, we consult TECS.
211-
if (ahrs.using_airspeed_sensor()) {
211+
if (ahrs.using_airspeed_sensor() || (takeoff_state.in_level_off_phase == true)) {
212212
calc_nav_pitch();
213213
// At any rate, we don't want to go lower than the minimum pitch bound.
214214
if (nav_pitch_cd < pitch_min_cd) {
@@ -279,7 +279,6 @@ void Plane::takeoff_calc_throttle() {
279279
// Set the minimum throttle limit.
280280
const bool use_throttle_range = (aparm.takeoff_options & (uint32_t)AP_FixedWing::TakeoffOption::THROTTLE_RANGE);
281281
if (!use_throttle_range // We don't want to employ a throttle range.
282-
|| !ahrs.using_airspeed_sensor() // We don't have an airspeed sensor.
283282
|| below_lvl_alt // We are below TKOFF_LVL_ALT.
284283
) { // Traditional takeoff throttle limit.
285284
takeoff_state.throttle_lim_min = takeoff_state.throttle_lim_max;
@@ -309,13 +308,17 @@ int16_t Plane::get_takeoff_pitch_min_cd(void)
309308

310309
// are we entering the region where we want to start levelling off before we reach takeoff alt?
311310
if (auto_state.sink_rate < -0.1f) {
312-
float sec_to_target = (remaining_height_to_target_cm * 0.01f) / (-auto_state.sink_rate);
311+
float sec_to_target = (remaining_height_to_target_cm * 0.01f * 2) / MIN(TECS_controller.get_max_climbrate(), -auto_state.sink_rate);
312+
/* A linear decrease of pitch at level-off is also a linear decrease of climb-rate, thus the height gained is only half.
313+
* Additionally, the climb-rate is limited by TECS value to keep external factors like wind influence at bay.
314+
*/
313315
if (sec_to_target > 0 &&
314316
relative_alt_cm >= 1000 &&
315317
sec_to_target <= g.takeoff_pitch_limit_reduction_sec) {
316318
// make a note of that altitude to use it as a start height for scaling
317319
gcs().send_text(MAV_SEVERITY_INFO, "Takeoff level-off starting at %dm", int(remaining_height_to_target_cm/100));
318320
auto_state.height_below_takeoff_to_level_off_cm = remaining_height_to_target_cm;
321+
takeoff_state.in_level_off_phase = true;
319322
}
320323
}
321324
}

0 commit comments

Comments
 (0)