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 #25785

Closed
wants to merge 1 commit into from

Conversation

Hwurzburg
Copy link
Collaborator

@Hwurzburg Hwurzburg commented Dec 17, 2023

fixes bug in Mode takeoff where autoenable occurs immediately after initial phase of climb and triggers min alt fence breach....AUTO takeoffs (both fw and VTOL) do not autoenable until takeoff alt is obtained....this does the same

addresses #25783

@Hwurzburg Hwurzburg requested a review from IamPete1 December 17, 2023 00:40
Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

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

I wonder if a much easier change of enabling fence on takeoff mode exit would achieve the same thing? Since there is no way to change the target altitude after takeoff the only difference would be if there was some sort of issue that prevented the maintaining altitude once it had been reached.

@@ -152,6 +149,13 @@ void ModeTakeoff::update()
plane.calc_nav_pitch();
plane.calc_throttle();
//check if in long failsafe, if it is recall long failsafe now to get fs action via events call
Copy link
Member

Choose a reason for hiding this comment

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

This comment belongs with the bit of code under the addition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will fix

@@ -152,6 +149,13 @@ void ModeTakeoff::update()
plane.calc_nav_pitch();
plane.calc_throttle();
//check if in long failsafe, if it is recall long failsafe now to get fs action via events call
#if AP_FENCE_ENABLED
const uint16_t altitude = plane.relative_ground_altitude(false,true);
if (altitude >= alt && !have_auto_enabled_fence) {
Copy link
Member

Choose a reason for hiding this comment

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

I think the standard loiter check can be used?

Suggested change
if (altitude >= alt && !have_auto_enabled_fence) {
if (plane.reached_loiter_target() && (loiter.reached_target_alt || loiter.unable_to_acheive_target_alt) && !have_auto_enabled_fence) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will try it in SITL

@Hwurzburg
Copy link
Collaborator Author

I wonder if a much easier change of enabling fence on takeoff mode exit would achieve the same thing? Since there is no way to change the target altitude after takeoff the only difference would be if there was some sort of issue that prevented the maintaining altitude once it had been reached.

but you could misconfigure such that the loiter breaches a fence....but it may be simpler...will create an alternate PR for consideration

@IamPete1
Copy link
Member

but you could misconfigure such that the loiter breaches a fence....but it may be simpler...will create an alternate PR for consideration

Your right of course, but then why are we letting the user arm in takeoff mode if they will just breach fence, it would save effort all round to not take off in the first place ;). Its a little more tricky if they arm in another mode and switch to takeoff tho...

@Hwurzburg
Copy link
Collaborator Author

closing in favor of Pete's approach #25788

@Hwurzburg Hwurzburg closed this Dec 17, 2023
@Hwurzburg Hwurzburg deleted the fix_Fence_mode_takeoff branch December 20, 2023 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants