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 FBWB/CRUISE missing zero crossing of elevator input #26796

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ArduPlane/navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,16 @@ void Plane::update_fbwb_speed_height(void)
elevator_input = -elevator_input;
}

int32_t alt_change_cm = g.flybywire_climb_rate * elevator_input * dt * 100;
change_target_altitude(alt_change_cm);

if (is_zero(elevator_input) && !is_zero(target_altitude.last_elevator_input)) {
// the user has just released the elevator, lock in
// the current altitude
bool input_stop_climb = !is_positive(elevator_input) && is_positive(target_altitude.last_elevator_input);
bool input_stop_descent = !is_negative(elevator_input) && is_negative(target_altitude.last_elevator_input);
if (input_stop_climb || input_stop_descent) {
// user elevator input reached or passed zero, lock in the current altitude
set_target_altitude_current();
}

int32_t alt_change_cm = g.flybywire_climb_rate * elevator_input * dt * 100;
change_target_altitude(alt_change_cm);

#if HAL_SOARING_ENABLED
if (g2.soaring_controller.is_active()) {
if (g2.soaring_controller.get_throttle_suppressed()) {
Expand Down
Loading