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

New DCM AHRS #8407

Closed
wants to merge 41 commits into from
Closed

Conversation

JulioCesarMatias
Copy link
Collaborator

@JulioCesarMatias JulioCesarMatias commented Sep 19, 2022

well... I've been working on it for at least 2 or 3 months, with the help of some friends like: @Jetrell, @b14ckyy and @MrD-RC. The intention is just to end the Drift of the current AHRS. So far, almost 90% of this is functional, but we still have some issues that need to be resolved, I'll list them below. This PR is being difficult for both parties, both for the developer, and also for those who will merge this in the future (if the problems are fixed, of course)....

  • 1 ~ There is a small drift in the AHRS, when we leave a maneuver in fixed-wing aircraft, but the GPS compensation manages to mitigate a good part of the drift (This may be related to the change_limit variable on line 938, since I spent days trying to fix this, but I couldn't).

  • 2 ~ When the GPS is deactivated, the Drift increases even more (because the centrifugal force correction function stops working, see line 821 to 836).

If this short list of problems is solved, we will have a good AHRS in iNav... I can mention some benefits:

1 - The circles in Pos-Hold mode on fixed-wing aircraft were perfect... So far I can't believe what I saw... Overall, this AHRS improved the performance of the INS.

2 - If we are flying with Compass, a "consistency" check will always be checking if it is useful to use in flight, if not, the system automatically switches to the use of GPS (This has already been proposed in the past here in iNav, but it didn't go any further, because I don't think anyone put this in lines of code).

3 - Delayed acceleration vector to compensate for low GPS refresh rate.

4 - Gyro coning correction (https://scholarsmine.mst.edu/cgi/viewcontent.cgi?article=8915&context=masters_theses).

5 - During a launch acceleration, and reduce the Roll and Pitch gain by 50% to reduce the impact of GPS lag on takeoff attitude when using a catapult.

6 - We only have 3 configuration parameters for this AHRS... kP Acc, kP Mag and GPS Gain.

Anyone interested in helping me with this, please fork my branch,study the entire algorithm, not just the lines I mentioned above, it is necessary to understand how everything else works, so that no incorrect conclusion occurs... HITL mode using XPlane11 also helped a lot with the development of this!

@0crap
Copy link
Contributor

0crap commented Sep 23, 2022

I just want to give an update on this. Darren Lines, bonafidepirate, 3 other pilots of the community and myself, we have now cumulative around 20-25 flight hours with the last commit of this test build. Multiple planes like AR900, AR Pro, Esky Eagle, Dart 250G, AtomRC Seal 1.5m (with some vibration problems that ran Ardupilot before), AR 600, Nano Drak and a Harrier S1100. where tested with many different FCs. Not even counting the 10 hours of flight time in the simulator testing missions and behavior with different sensor setups.

No one reported any problem with it!

Awesome work on this PR including all the testing that is been done.
@b14ckyy Will you also thoroughly test PR #8403 to see which comes out as best?

@b14ckyy
Copy link
Collaborator

b14ckyy commented Sep 23, 2022

yes I am working with him as well and test it.

@JulioCesarMatias
Copy link
Collaborator Author

JulioCesarMatias commented Sep 23, 2022

to see which comes out as best

This is not a competition! "to see which comes out as best". From my point of view, this new AHRS has a lot of improvements that the old one doesn't have.

@JulioCesarMatias
Copy link
Collaborator Author

What's the point of making the centrifugal correction using the GPS work, if when you don't have a GPS, the Drift will still be there?? Tell me?

@JulioCesarMatias
Copy link
Collaborator Author

to see which comes out as best

This is not a competition! "to see which comes out as best". From my point of view, this new AHRS has a lot of improvements that the old one doesn't have.

No one is competing, it was just a coincidence that both PR's were open at the same time (although I don't want to open this one now)... Both are totally different.

@b14ckyy
Copy link
Collaborator

b14ckyy commented Sep 23, 2022

What's the point of making the centrifugal correction using the GPS work, if when you don't have a GPS, the Drift will still be there?? Tell me?

the other PR uses still the ignore_rate mitigations if no GPS is available. If course it is not a perfect solution but doable.

Anyway. I see no reason why you should not have opened this PR. We know that some last things are to fix and you need some help. Without the PR no one would be able to help. Let's wait till @digitalentity has time to look at it.
#####################

One more update in case this helps solving issues. Marcin did another test flight with the seal today. Drift was only there if excessive or continuous Z-Accelleration is applied like a spiral climb in cruise mode or during autotune on Pitch.

But one more thing that is more noticeable on his plane is the heading randomly doing correction jumps. Check the numerical heading at the following times: 1:31 - 2:53 - 4:42 (maybe more but i did not frame by frame chat the whole flight.

It is not really noticeable in Angle mode of course but in nav modes this can cause sudden course changes. Keith also saw it on one mission flight when a waypoint was not properly approached and then a sudden course correction appeared and I saw the same in my 5.1 comparison flight here when approaching WP4
image

I have not taken it serously before but in this flight it was more obvious to see the connection.

Here is the full video of Marcins flight: https://youtu.be/ZOygg6xUMrE

@digitalentity
Copy link
Member

Hey, great stuff we have here!

I would still suggest to have ignore_rate in place for no-GPS aircrafts. It's not perfect, but it does the job to some extent. Obviously, the code should also be tested on copters.

@JulioCesarMatias
Copy link
Collaborator Author

JulioCesarMatias commented Sep 25, 2022

I would still suggest to have ignore_rate in place for no-GPS aircrafts.

I don't agree with that!

@b14ckyy
Copy link
Collaborator

b14ckyy commented Sep 26, 2022

Let's try it first in the current state. I am maybe able to do a real no-gps flight tomorrow after work (late shift today so it might be too dark when I arrive at the field). If not then on the weekend.

for GPS enabled flights on wings in my opinion the remaining possible drift on certain maneuvers is not even a showstopper. The only big issue I see with gps assisted flights is the heading currently. that sometimes is off by too much. Looking closer over recent flight tests (also my own) show that this can be an issue for WP missions as well as RTH. I have seen heading jumps of 30° but also up to 70° while flying a straight line in cruise mode. Also can be seen here in this WP mission when the plane tries to fly from WP4 to WP5 but starts completely off course.
image

I'll have a look at my past flights and upload logs if needed.

@0crap
Copy link
Contributor

0crap commented Sep 26, 2022

I would still suggest to have ignore_rate in place for no-GPS aircrafts.

I don't agree with that!

Why not, just because it's old code?
What I see from the flight footage is that your code works really well.
Only issue is when you do acrobatic flight.
ignore_rate with a high value might be a good solution for now to get the PR merged.
After that, polish it to perfection and remove the ignore_rate when done.

You might consider it temporarily...

@JulioCesarMatias
Copy link
Collaborator Author

instead of you thinking about using the old AHRS parts, I recommend you to take a paper and pencil and help me correct the current AHRS math! If I didn't add the functions "ignore_rate" and "ignore_sloope" it's because I know that this new AHRS works without these functions! And merge this to fix this in the future? No, that doesn't make sense, it's totally wrong.

@b14ckyy
Copy link
Collaborator

b14ckyy commented Sep 26, 2022

Guys let's calm down a little bit.
I agree with Julio, that if the AHRS can work without ignore rate (even on quads and with no GPS present) then we should avoid to bring it back in. If the AHRS is fully functional as it is on Ardupilot and Aerobatic pilots are not satisfied enough at the end, THEN we can think about this as a edge case option just for these pilots as it worked well for this kind of flying.

The only problem that I see at the end is, that the ignore rate workaround is depending on very clean setups and high gyro precision and that can cause new issues for these.

But as long as GPS is available and we have the speed and heading working, there is no point in adding back the ignore rates.

@0crap
Copy link
Contributor

0crap commented Sep 26, 2022

Fair enough! 👍

@b14ckyy
Copy link
Collaborator

b14ckyy commented Sep 26, 2022

btw @0crap it is not just acrobatic flying causing still drift. When I do autotune and pitch up and down in waves I would not consider this acrobatic and here is the biggest impact visible with the most amount of drift.
Also when it is very windy and the plane turns from upwind into downwind, this sudden accelleration causes a noticeable down drift of the AHI for a moment. This happens in navigation modes and can't be fixed with ignore_rate. Adn these are currently the major issues (for fixed wings) that have to be fixed for GPS available flights. Soem more stuff on quads needs to be done as well.

@0crap
Copy link
Contributor

0crap commented Sep 26, 2022

... . When I do autotune and pitch up and down in waves I would not consider this acrobatic and here is the biggest impact visible with the most amount of drift. ...

True, seen that on your vid. Weird indeed.
Thx for explaining.

@Jetrell
Copy link

Jetrell commented Sep 26, 2022

Also, overcoming the remaining issues by the easier path of ignore_slope, won't help to overcome the Multi-rotor braking runaway issue in Poshold.
This has been a considerable problem for years. And freaks you out if you're not expecting it.

This temporary runaway occurs if a quad experiences specific G forces acting on the accelerometer as it slows, and begins to tilt back in the braking phase...
Hopefully, being able to mitigate this X axis conflicting data while braking, should help alleviate this problem.

@JulioCesarMatias
Copy link
Collaborator Author

well... sorry for the earlier message! But, I think we should pay attention to the function that is activated through the variable "should_correct_centrifugal", and also give a review on the fusion of the NED (3D) speed of the GPS in the AHRS.

@b14ckyy
Copy link
Collaborator

b14ckyy commented Sep 26, 2022

just a quick test flight today with the Dart 250g. It flew very bad becasue I had messed up the first launch and the Hatch cover flew off and broke off the tabs. So I had to fly with an open fuselage xD
This time no GPS and no Compass. Just plain Gyro, acc and baro available.

https://www.youtube.com/watch?v=9In1nxRDOjQ

@JulioCesarMatias JulioCesarMatias removed this from the 6.0 milestone Sep 28, 2022
@JulioCesarMatias
Copy link
Collaborator Author

https://drive.google.com/file/d/0B9rLLz1XQKmaZTlQdV81QjNoZTA/view?resourcekey=0-tMmw1tSCJzcthOHDaPqdyA

@JulioCesarMatias
Copy link
Collaborator Author

no solutions here! Let's pay attention to >> #8403

@DzikuVx
Copy link
Member

DzikuVx commented Oct 17, 2022

@JulioCesarMatias if you don't mind, I'd like to leave this PR open but with Don't merge flag as I think it's an amazing piece of code and might be a nice proof of concept for future work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants