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 auto fence enable in Mode Takeoff #25788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions ArduPlane/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,9 @@ class ModeTakeoff: public Mode
Location start_loc;

bool _enter() override;
#if AP_FENCE_ENABLED
void _exit() override;
#endif
};

#if HAL_SOARING_ENABLED
Expand Down
13 changes: 8 additions & 5 deletions ArduPlane/mode_takeoff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ void ModeTakeoff::update()
plane.next_WP_loc.alt += alt*100.0;

plane.set_flight_stage(AP_FixedWing::FlightStage::NORMAL);

#if AP_FENCE_ENABLED
plane.fence.auto_enable_fence_after_takeoff();
#endif
}

if (plane.flight_stage == AP_FixedWing::FlightStage::TAKEOFF) {
Expand All @@ -164,4 +160,11 @@ void ModeTakeoff::navigate()
// Zero indicates to use WP_LOITER_RAD
plane.update_loiter(0);
}

#if AP_FENCE_ENABLED
void ModeTakeoff::_exit()
{
if (plane.is_flying() && plane.is_flying()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the plane is definitely flying?

plane.fence.auto_enable_fence_after_takeoff();
}
}
#endif