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

Phase lag pre-arm check #27068

Closed
wants to merge 4 commits into from

Conversation

andyp1per
Copy link
Collaborator

Made a separate PR for discussion so as to not hold up #26674

@tridge your original suggestion was bw > 0.75*freq/nsources, I assume that was a typo because that will break the configuration of all 14 of my copters that are using this feature very successfully (and for which this feature was originally written) 😄 I have changed that to bw * 0.75 > freq/nsources which at least does not break many existing configurations but it does not work on octacopters. It is impossible to get the octacopter test to pass with this setting which was my original concern with having any check like this - it simply does not filter enough noise. My suggestion therefore is either to make this a warning or simply clamp the check at f/4. Either way much discussion and testing required!

Copy link
Contributor

@tridge tridge left a comment

Choose a reason for hiding this comment

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

maybe go to 1.0 so it passes with quad multi-src with 1:4 ratio?

libraries/AP_Vehicle/AP_Vehicle.cpp Outdated Show resolved Hide resolved
@andyp1per andyp1per force-pushed the pr-phase-lag-pre-arm branch from 669a513 to 0db55a2 Compare May 25, 2024 19:06
@andyp1per
Copy link
Collaborator Author

After discussion with @lthall we decided f/sqrt(nsources) was a suitable compromise in terms of pre-arm check. Adjusting attenuation unfortunately is unlikely to make enough of a difference.

@andyp1per andyp1per force-pushed the pr-phase-lag-pre-arm branch 2 times, most recently from 15aaabf to 69451bd Compare May 25, 2024 21:26
@tridge
Copy link
Contributor

tridge commented May 26, 2024

Adjusting attenuation unfortunately is unlikely to make enough of a difference.

I'm surprised about this. At zero attenuation there should be no phase lag. I wrote a little test to check this out and got this:
image
this was for a single notch set at 60Hz with bandwidth of 60Hz. Source frequency was 50Hz, and the test frequency varies for the 5 graphs from 10Hz to 50Hz.
The test shows a strong relationship between attenuation and phase lag.
test code here:
#27164
one thing I can't explain is the stair step in the graphs

@andyp1per andyp1per force-pushed the pr-phase-lag-pre-arm branch from c941739 to 984edff Compare May 26, 2024 15:58
@andyp1per andyp1per removed the WIP label May 26, 2024
@andyp1per
Copy link
Collaborator Author

andyp1per commented Jul 25, 2024

So Flytrex has pretty conclusively proved for me that 1/nsources is harmful. They flew on an X8 with notch-per-motor and saw oscillation at F/8 on their current tune because the noise was too high. F/6 also showed significant noise, whereas F/4 showed really good attenuation and good control on their existing tune using a single notch. So as a pre-arm check 1/sqrt(nsources) is definitely the way to go. This is also proved by my existing autotest.

@lthall
Copy link
Contributor

lthall commented Jul 25, 2024

I have a feeling this is a problem because Quicktune is resulting in dangerously small gain margins that are then made unstable by any increase in phase lag. Also true for manual tunes that are too tight but the Quicktune algorithm will make that the "recommended tune".

I think it is silly to have prearms to warn people about sensible parameter settings. All these things eat into flash space, support time and developer time.

@lthall
Copy link
Contributor

lthall commented Jul 26, 2024

Another thought. If we are going to be adding a pattern where we put in parameter pre-arm checks that are triggered by sensible parameter settings and then expect the user to turn off each check with an options bit, maybe we should set up a specific structure for that.

This is sort of a new category of "sanity check" where we have changed a parameter so we want to force the pilot to achnolage that they understand the risks of what they have done and have taken appropriate action to mitigate the risk.

In this case it is: - You have turned on additional notches so your tune may become unstable.
But any decrease in filter frequency can also do that. So maybe we should be doing this with any of those things I would normally say "If you change this parameter, be very carful on your next flight and start the flight with a tuning stability check".

@lthall
Copy link
Contributor

lthall commented Jul 26, 2024

So Flytrex has pretty conclusively proved for me that 1/nsources is harmful. They flew on an X8 with notch-per-motor and saw oscillation at F/8 on their current tune because the noise was too high. F/6 also showed significant noise, whereas F/4 showed really good attenuation and good control on their existing tune using a single notch. So as a pre-arm check 1/sqrt(nsources) is definitely the way to go. This is also proved by my existing autotest.

This is great testing to show why we don't want this PR. Do we have any real life testing and logs to show that we need this check?

@andyp1per
Copy link
Collaborator Author

Flytrex now have a decent tune with F/4 - so I pretty much conclude that we should close this PR.

@andyp1per andyp1per closed this Sep 5, 2024
@andyp1per andyp1per deleted the pr-phase-lag-pre-arm branch September 5, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WikiNeeded needs wiki update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants