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: fast attitude recovery for quadplanes #29498

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

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)

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 added 7 commits March 19, 2025 13:59
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
@tridge tridge force-pushed the pr-quadplane-inverted-recovery branch from 7a569e4 to c9adcc8 Compare March 19, 2025 03:04
@tridge tridge force-pushed the pr-quadplane-inverted-recovery branch 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…

@IamPete1
Copy link
Member

Any idea what is limiting the pitch in QLOITER?

We do have the transition pitch limit stuff, it works in all modes but is only likely to be noticeable in Q_LOITER, the key function is set_VTOL_roll_pitch_limit there is a time parameter Q_BACKTRANS_MS. If were still using the FW controllers we need to delay the init of loiter navigation and delay the start of that pitch up limit. We should be able to use the same code paths as tailsitters.

It does concern me for 4.6 that this is getting more and more complex.

@IamPete1
Copy link
Member

I had another thought, we should update show_vtol_view to account for the delay in switching controllers so it is correctly reflected in the logs and GCS.

@tridge
Copy link
Contributor Author

tridge commented Mar 19, 2025

We do have the transition pitch limit stuff, it works in all modes but is only likely to be noticeable in Q_LOITER, the key function is set_VTOL_roll_pitch_limit there is a time parameter Q_BACKTRANS_MS

I looked at that, but it was set to 3000 ms, yet, the pitch was limited to under 2 degrees for more than 25 seconds.

I had another thought, we should update show_vtol_view to account for the delay in switching controllers so it is correctly reflected in the logs and GCS

yes, I have that change pending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants