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

EKF: 14 state INS with z-axis bias and mag heading mode #1506

Merged
merged 122 commits into from
May 13, 2015

Conversation

peabody124
Copy link
Contributor

When engaging altitude hold using the INS it is common to see a
small glitch in the altitude. This arises because of untracked bias
in the accelerometer. This new INS fixes this issue by tracking
the accelerometer bias.

In addition it changes how the mag is dealt with so it only influences
yaw and cannot affect roll and pitch. This creates a better attitude
estimate in practice.

Finally it adds unit tests for the INS with regards to stability and
convergence rates.

Much of this work is written up here: http://buildandcrash.blogspot.com/2015/01/ekf-enhancements-and-unit-tests.html

@peabody124
Copy link
Contributor Author

Testing and code review extremely welcome! I feel quite good about this code.

for (j = i; j < NUMX; j++)
D[i][j] = P[i][j];

// Brute force calculation of the elements of P
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this come from? Would be good to have some explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's pretty old code from the 13 state INS, just generic matrix multiplication unrolled.

@BrainFPV
Copy link
Contributor

I read through the code but didn't verify the math. Do you have the matlab scripts used to generate the update steps? It would help for double checking things.

I will test the next time I go flying.

@peabody124
Copy link
Contributor Author

@BrainFPV I tried to write the python code so it was a bit more understandable and "mathy", I can dig out some of the matlab code that generated some of the pseudocode too but even that is fairly cryptic and the output requires a fair bit of massaging

@peabody124
Copy link
Contributor Author

One issue I'm seeing with this is that BaroAltitude is showing up in the SystemStats.ObjectManagerQueueID so somewhere that queue overflows (when not receiving GPS data).

@peabody124
Copy link
Contributor Author

@elafargue thsi should be good to test if you want to

@peabody124 peabody124 added this to the Meetup milestone May 5, 2015
@peabody124 peabody124 force-pushed the ins14 branch 2 times, most recently from b52b582 to 004ff77 Compare May 12, 2015 09:09
For some reason D[15][15] was being replaced with D[14][15]
in the automatically computed code which prevented the z-axis
accel bias calculation working properly. This was fixed
manually (and tediously).
These variables are not referenced anywhere in the covariance
prediction, which is where G is used.
This is for symmetry with the way the gyro biases are treated.
This makes it converge faster and still seems quite stable.
This is a testing mode, primarily, so it is nice to use
the same settings as in the real mode.
The velocity was updated towards zero for indoor mode and
the ublox vertical velocity in outdoor mode. Further testing
has indicated that in indoor mode this overly damps the
velocity estimate. For outdoor mode, it will likely have issues
because of the latency in the GPS.

The baro is a pretty accurate sensor and sufficient to fuse with
the accels to get a good estimate of the vertical velocity.
peabody124 and others added 21 commits May 12, 2015 16:29
The last row of plots was not useful.
This simulates the bias changing after the system
converges to check how long it takes to stabilize.
Also update the simulation to keep the cirlce centered
at the orgin rather than drifting away.
Conflicts:
	python/ins/ins14.py
This catches any problems with the attitude coupling
into the yaw, which is one of the things this code is
designed to fix.
The calculation to remove the influence of attitude from
the mag was transposed which applied in the wrong way
and magnified problems.
Was only passing in the first two axes which prevents
backing out the transformation.
Under some rare conditions, the INS biases can get
very large and destabilize the filter. Because these
are meant to track the errors in sensors, we can place
reasonable priors on what values are valid and
saturate at these limits..
This is more consistent with the other objects. More
critically, it invalidates any previous settings without
mag horizontal plane compensation. The mag is now used
in real units so the variance increased by about two
orders of magnitude. This resulted in NANs from the EKF.
This module takes almost 20KB of flash and is rarely used. This
disables it by default, but leaves it commented to make it easy
to reenable for custom compiles.
@peabody124 peabody124 modified the milestones: March Release, Meetup May 12, 2015
@mlyle
Copy link
Contributor

mlyle commented May 12, 2015

While I hope for more work in this area.. INS14 is clearly better, the patch reads sane, and we have good flight test on it.

elafargue added a commit that referenced this pull request May 13, 2015
EKF: 14 state INS with z-axis bias and mag heading mode

As flight-tested during the Spring 2015 Tau Labs meetup!
@elafargue elafargue merged commit 3ee981a into TauLabs:next May 13, 2015
@peabody124 peabody124 deleted the ins14 branch May 13, 2015 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants