diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 6adc5178aa..4afb53b825 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -1012,6 +1012,7 @@ private: void takeoff_calc_pitch(void); int8_t takeoff_tail_hold(void); int16_t get_takeoff_pitch_min_cd(void); + void complete_auto_takeoff(void); void print_hit_enter(); void ahrs_update(); void update_speed_height(void); diff --git a/ArduPlane/commands_logic.cpp b/ArduPlane/commands_logic.cpp index fb04ddee06..375bf95970 100644 --- a/ArduPlane/commands_logic.cpp +++ b/ArduPlane/commands_logic.cpp @@ -548,15 +548,7 @@ bool Plane::verify_takeoff() auto_state.takeoff_complete = true; next_WP_loc = prev_WP_loc = current_loc; -#if GEOFENCE_ENABLED == ENABLED - if (g.fence_autoenable > 0) { - if (! geofence_set_enabled(true, AUTO_TOGGLED)) { - gcs_send_text(MAV_SEVERITY_NOTICE, "Enable fence failed (cannot autoenable"); - } else { - gcs_send_text(MAV_SEVERITY_INFO, "Fence enabled (autoenabled)"); - } - } -#endif + plane.complete_auto_takeoff(); // don't cross-track on completion of takeoff, as otherwise we // can end up doing too sharp a turn diff --git a/ArduPlane/quadplane.cpp b/ArduPlane/quadplane.cpp index 1bca11f0ec..2d49d8dc9d 100644 --- a/ArduPlane/quadplane.cpp +++ b/ArduPlane/quadplane.cpp @@ -1684,6 +1684,9 @@ bool QuadPlane::verify_vtol_takeoff(const AP_Mission::Mission_Command &cmd) } transition_state = TRANSITION_AIRSPEED_WAIT; plane.TECS_controller.set_pitch_max_limit(transition_pitch_max); + + plane.complete_auto_takeoff(); + return true; } diff --git a/ArduPlane/takeoff.cpp b/ArduPlane/takeoff.cpp index 95feb86f59..84fc48db1e 100644 --- a/ArduPlane/takeoff.cpp +++ b/ArduPlane/takeoff.cpp @@ -225,3 +225,19 @@ return_zero: return 0; } + +/* + called when an auto-takeoff is complete + */ +void Plane::complete_auto_takeoff(void) +{ +#if GEOFENCE_ENABLED == ENABLED + if (g.fence_autoenable > 0) { + if (! geofence_set_enabled(true, AUTO_TOGGLED)) { + gcs_send_text(MAV_SEVERITY_NOTICE, "Enable fence failed (cannot autoenable"); + } else { + gcs_send_text(MAV_SEVERITY_INFO, "Fence enabled (autoenabled)"); + } + } +#endif +}