Plane: fixed some rebase duplicate code.

This commit is contained in:
Tom Pittenger 2019-03-22 14:59:00 +11:00 committed by Andrew Tridgell
parent 0270c57530
commit 05774a8a5a
2 changed files with 6 additions and 23 deletions

View File

@ -56,9 +56,6 @@ bool Mode::enter()
plane.auto_state.vtol_mode = false;
plane.auto_state.vtol_loiter = false;
// reset steering integrator on mode change
plane.steerController.reset_I();
bool enter_result = _enter();
if (enter_result) {
@ -69,6 +66,12 @@ bool Mode::enter()
plane.throttle_suppressed = plane.auto_throttle_mode;
plane.adsb.set_is_auto_mode(plane.auto_navigation_mode);
// reset steering integrator on mode change
plane.steerController.reset_I();
// update RC failsafe, as mode change may have necessitated changing the failsafe throttle
plane.control_failsafe();
}
return enter_result;

View File

@ -260,25 +260,11 @@ bool Plane::set_mode(Mode &new_mode, const mode_reason_t reason)
previous_mode_reason = control_mode_reason;
control_mode_reason = reason;
#if CAMERA == ENABLED
camera.set_is_auto_mode(control_mode == &mode_auto);
#endif
if (previous_mode == &mode_autotune && control_mode != &mode_autotune) {
// restore last gains
autotune_restore();
}
// zero initial pitch and highest airspeed on mode change
auto_state.highest_airspeed = 0;
auto_state.initial_pitch_cd = ahrs.pitch_sensor;
// disable taildrag takeoff on mode change
auto_state.fbwa_tdrag_takeoff_mode = false;
// start with previous WP at current location
prev_WP_loc = current_loc;
// attempt to enter new mode
if (!new_mode.enter()) {
// Log error that we failed to enter desired flight mode
@ -301,12 +287,6 @@ bool Plane::set_mode(Mode &new_mode, const mode_reason_t reason)
logger.Write_Mode(control_mode->mode_number(), control_mode_reason);
notify_mode(*control_mode);
// reset steering integrator on mode change
steerController.reset_I();
// update RC failsafe, as mode change may have necessitated changing the failsafe throttle
control_failsafe();
return true;
}