Browse Source

Plane: fixed climb rate for quadplanes in CRUISE

the high loop rate of quadplanes led to less than 1cm/loop change in
height, which got truncated to zero. Adjusting height at 10Hz fixes
that.

Thanks to Marco for reporting this!
mission-4.1.18
Andrew Tridgell 8 years ago
parent
commit
92f88e9b33
  1. 6
      ArduPlane/Plane.h
  2. 39
      ArduPlane/navigation.cpp

6
ArduPlane/Plane.h

@ -712,6 +712,12 @@ private:
// lookahead value for height error reporting // lookahead value for height error reporting
float lookahead; float lookahead;
#endif #endif
// last input for FBWB/CRUISE height control
float last_elevator_input;
// last time we checked for pilot control of height
uint32_t last_elev_check_us;
} target_altitude {}; } target_altitude {};
float relative_altitude = 0.0f; float relative_altitude = 0.0f;

39
ArduPlane/navigation.cpp

@ -248,29 +248,38 @@ void Plane::update_cruise()
*/ */
void Plane::update_fbwb_speed_height(void) void Plane::update_fbwb_speed_height(void)
{ {
static float last_elevator_input; uint32_t now = micros();
float elevator_input; if (now - target_altitude.last_elev_check_us >= 100000) {
elevator_input = channel_pitch->get_control_in() / 4500.0f; // we don't run this on every loop as it would give too small granularity on quadplanes at 300Hz, and
// give below 1cm altitude change, which would result in no climb or descent
float dt = (now - target_altitude.last_elev_check_us) * 1.0e-6;
dt = constrain_float(dt, 0.1, 0.15);
target_altitude.last_elev_check_us = now;
float elevator_input = channel_pitch->get_control_in() / 4500.0f;
if (g.flybywire_elev_reverse) { if (g.flybywire_elev_reverse) {
elevator_input = -elevator_input; 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
set_target_altitude_current();
}
target_altitude.last_elevator_input = elevator_input;
} }
change_target_altitude(g.flybywire_climb_rate * elevator_input * perf.delta_us_fast_loop * 0.0001f);
if (is_zero(elevator_input) && !is_zero(last_elevator_input)) {
// the user has just released the elevator, lock in
// the current altitude
set_target_altitude_current();
}
// check for FBWB altitude limit // check for FBWB altitude limit
check_minimum_altitude(); check_minimum_altitude();
altitude_error_cm = calc_altitude_error_cm(); altitude_error_cm = calc_altitude_error_cm();
last_elevator_input = elevator_input;
calc_throttle(); calc_throttle();
calc_nav_pitch(); calc_nav_pitch();
} }

Loading…
Cancel
Save