Skip to content

Plane: fast attitude recovery for quadplanes #29498

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

Merged
merged 18 commits into from
Apr 1, 2025

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Mar 11, 2025

This is a rework of #28320 which uses the fixed wing attitude controller for recovery instead of modifying the VTOL controller. This gives much faster attitude recovery and also avoids an issue with the way the quaternion controller may try to pitch down while inverted, leading to a large amount of altitude loss
This approach builds on the way we already use the fixed wing controller during forward transitions, so it is very little code change, and testing shows it produces a very small amount of altitude loss (eg. in the autotest the alt loss is usually around 2m from fully inverted)

Update: this PR now makes the use of the forced fixed wing controller optional using Q_ASSIST_OPTIONS (defaults enabled) and adds spin recovery, also optional.

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.

This effectively recovers as it would in Q-Assist in a fixed wing flight. One issue I have seen on a real vehicle is that the fixed wing angle controllers have a bad time unusual attitudes. A vehicle got into a inverted spin and was no able to recover in Q-Assist. The issue was three fold, it was oscillating about roll +-180 and could not decide which way to go. The fixed-wing controllers hard limit angle error so the error was not building the longer it was upside down (as it would in the VTOL controller), so it never tried that hard to recover. The VTOL rate controller I terms are also relaxed in assist so again it was never trying that hard. In that case we were able to switch to a VTOL mode and have it recover quickly (although not quite quick enough to prevent the crash).

One advantage of this method is that we can say that it is not anything that the vehicle would not do in Q-Assist so were not in any more risk of overloading the vehicle that we would be in that case.

One disadvantage is that the user may be trying the VTOL mode because Q-Assist may have failed to recover, in which case it makes sense to try a different approach.

@tridge tridge force-pushed the pr-quadplane-inverted-recovery branch from 8674077 to 45332e5 Compare March 11, 2025 20:10
@tridge
Copy link
Contributor Author

tridge commented Mar 12, 2025

One issue I have seen on a real vehicle is that the fixed wing angle controllers have a bad time unusual attitudes. A vehicle got into a inverted spin and was no able to recover in Q-Assist. The issue was three fold, it was oscillating about roll +-180 and could not decide which way to go. The fixed-wing controllers hard limit angle error so the error was not building the longer it was upside down (as it would in the VTOL controller), so it never tried that hard to recover.

my preference is to apply this method with those limitations and work on improving the fixed wing attitude controller to better cope with these scenarios.

@tridge tridge force-pushed the pr-quadplane-inverted-recovery branch 2 times, most recently from fa7d655 to 314daa5 Compare March 12, 2025 21:32
@tridge
Copy link
Contributor Author

tridge commented Mar 12, 2025

@IamPete1 I've added in the attitude control method as discussed, plus the indecision change for the FW roll controller
in the new test added in this PR we now lose no altitude at all (usually gains about 0.1 or 0.2 m in recovery). Without these changes we lose around 25m or so

@tridge
Copy link
Contributor Author

tridge commented Mar 13, 2025

need to do testing on some real quadplanes

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 would like to see testing on a motor always on tailsitter like the swan H1 in realflight.

@tridge
Copy link
Contributor Author

tridge commented Mar 18, 2025

need to test the HWing in RealFlight

@tridge
Copy link
Contributor Author

tridge commented Mar 18, 2025

I would like to see testing on a motor always on tailsitter like the swan H1 in realflight.

I have tested in RealFlight. Flies fine. Inverted mode doesn't work, but also doesn't work in master. I also found a bug where if you disarm in a fwd flight mode in an all motor tailsitter the motors don't stop! That bug is in master

@tridge tridge force-pushed the pr-quadplane-inverted-recovery branch 2 times, most recently from c9adcc8 to 7aae436 Compare March 19, 2025 03:08
@tridge
Copy link
Contributor Author

tridge commented Mar 19, 2025

@IamPete1 I have been testing recovery using the Griffin model in RealFlight. I'm getting some strange results. One is that when I switch to QLOITER the aircraft doesn't slow down. For example:
image
image

log here: https://uav.tridgell.net/GriffinTest/00000042.BIN
zooming in, we see the pitch staying below 2 degrees until it suddenly goes to 5 degrees, then some time later it does to 30 degrees, which is what I expected to happen to slow down from 50 m/s.
Any idea what is limiting the pitch in QLOITER?

@tridge
Copy link
Contributor Author

tridge commented Mar 19, 2025

@IamPete1 this is another one that worries me:
https://uav.tridgell.net/GriffinTest/00000039.BIN
it dropped like a stone inverted
Uploading image.png…

tridge added 18 commits April 1, 2025 15:01
ensures we can recover from inverted flight quickly
when we start the VTOL motor stabilisation with an attitude beyond
normal attitude limits we set a flag to use fixed wing attitude
control (slaving VTOL rate control to fixed wing rate control) until
we have recovered

this avoids an issue with the shaping in the VTOL attitude controller
and also fixes an issue with the VTOL controller bringing the nose
down, which can cause a lot of height loss in quadplanes
we use input_rate_bf_roll_pitch_yaw_no_shaping to avoid input shaping
when slaving the VTOL rate controllers to the fixed wing rate control

this allows for much faster recovery in Q-assist
when we are close to a 180 degree error, go with the last direction if
we are in a 40 degree angle wedge of 180 degree error
during forward transition of tiltrotors we use the VTOL attitude
controller until min airspeed is reached. This fixes the FW rate
controllers to be slaved to the VTOL controller for that time
if we are forcing recovery then don't use yaw control override
this avoids an issue with not pitching up
added Q_ASSIST_OPTIONS for disabling new features
@rmackay9
Copy link
Contributor

rmackay9 commented Apr 1, 2025

this is included in 4.6.0-beta5 via PR rmackay9#37

@tridge tridge merged commit 7a1630c into ArduPilot:master Apr 1, 2025
117 of 119 checks passed
@github-project-automation github-project-automation bot moved this from 4.6.0-beta5 to Pending in 4.6 Backports Apr 1, 2025
@rmackay9 rmackay9 moved this from Pending to 4.6.0-beta5 in 4.6 Backports Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 4.6.0-beta5
Development

Successfully merging this pull request may close these issues.

5 participants