PDA

View Full Version : Discussion Filtering IMU


RustySharpie
Feb 11, 2009, 02:56 AM
Hi everyone, I'm new to the whole IMU stuff but willing to learn.

So I want to make my own IMU with only 1 3axis accelerometer and 3 rate gyros so that I can track position and heading. I also want to test it by walking around with it or pushing it around on a cart and seeing if I can get the position and heading accurate enough.

I have tried double integrating the output of the accelerometer through the trapezoidal rule. Needless to say, the error was huge...

I read up on filtering my output. I believe I need a combination of a low pass filter as well as a Kalman filter.
The problem is there are so many different variations of the Kalman filter, I'm not sure which would be the best place to start.

Can anyone point me in the right direction?

drex
Feb 12, 2009, 04:22 PM
use the extended kalman.

for heading u need a 3 axis mag to make a tilt comp compass, or u can use the gps heading although it may not be as accurate as u would like it to be...

the 3 axis mag data will correct the errors that build up with the gyros etc...

so yah, add a gps and add a 3 axis mag.

then construct your extended kalman...

and dont forget to filter your a2d data too.....

so tons of stuff to do :)

RustySharpie
Feb 12, 2009, 08:51 PM
Thanks for the reply.
I want to avoid using GPS. I have no clue whether or not this will be remotely accurate but I want to find out =)
As for the 3axis mag, I'm not sure if it will work for my application, since I will be using it indoors. I read somewhere that magnetometers are affected by the steel beams in the building. I was hoping I could just use a gyro to measure the yaw.
I was also hoping I could just get away by just measuring tilt with the accelerometer initially and then using the gyro for the in-motion angle changes.

Any ideas or suggestions anyone?

rbeall
Feb 12, 2009, 09:29 PM
when you say use the gyro to measure angle changes you are right you can do just that. You integrate the yaw rate to get the yaw angle. However this assumes a perfect world with no noise, bias, or drift. Any time you integrate noise, bias, or drift the error is compounded quite quickly even if the error is small. What you see in practice with mems gyros is that, when integrated, they drift significantly due to their unpredictable bias. What I have seen in my runs is about 360 deg in about 10 seconds. So the yaw would spin a full revolution every half a min or less. If you look at my chart hoepfully you can see what I mean and why you need to Kalman the two together.

What you see in this data run is I rolled the imu +-90 deg, then I shook it to simulate some vibration, then I rolled +- 90 more rapidlly. Notice how quickly the Kalman tracks the gyro bias specially at the end. Also notice how after shaking I jerked the imu forward and the accelerometers went crazy but the gyros calculated that the orientation hadn't changed. I like leaning more on the gyros because they are significantly more accurate. So I tune my filter such that it looks like the gyro simply plotted with out the bias.

a_roll is the roll angle calculated only using the accelerometers
g_roll is the roll angle calculated by integrating the gryos
kalman is the blend of the two obviously

good luck - Ryan

RustySharpie
Feb 13, 2009, 05:12 AM
WOW. That your Kalman filtering results looks sweeeeet.
A few questions on your comments...
You tell me the Kalman tracks the gryo bias quickly at the end. Where should I be looking at?
Also, you said that you lean more on the gyros but looking at your plot, it looks like the filtering is more closer to the accelerometer angle. Am I missing something? Or is this some high level stuff from KF that I haven't touched yet?

I've been reading that the gyro drift is a major problem.
I'm not sure if I'm doing it wrong or not but the gyro I've been using doesn't seem to drift that much. Its the Melexis EVB90609. I set the gyro on the table for 10min at 1000 samples/sec using a 14bit DAC from National Instrument.

The bias didnt change much but it seemed more like it was constantly offsetted. The normal zero rate output is 2.5V

Heres a graph of the output for that data.
http://i43.tinypic.com/nn9r48.jpg

Any suggestions?
What about my idea about no magnetometers and no GPS?

rbeall
Feb 13, 2009, 09:54 PM
What I mean by "lean more on the gyro" is my "technical term" for how the kalman is tuned. Once you get a Kalman running and start fiddling with the gains it will probably make more sense but the best I can describe it is this:

I take more of the gyro reading than the accelerometer. For example do you see where the huge negative spike in the yellow aroll (right after the shake). If the Kalman leaned towards the acclerometer more it would have dipped towards the acc. But it trusted the gyro more instead.

you are exactly right about the gyro. They have a 2.5 offset so that they can read negative rates as well. So like mine the full sweep is +-300 deg/s on a 0-5 V scale.

As far as drift goes.... Drift is describing the integrated drift. The gyo itself is going to read 2.5 all day long at zero rotation rate. But you do see the noise right? When you integrate that noise its obviously never going to be perfectly 2.500000V. Well integration continuously adds up all of that noise. You are looking at the average and its noise band is pretty low. But when you add the noise every time you sample it. 2.501+2.505+2.49.... It "drifts" just like groll. It will continue to add up all those little errors really fast and continue on forever unless you subtract them out. Thats where your accelerometers come in. They have their own noise (usally a lot more than gyros) but they will always know generally where gravity is pointing in steady level flight. So you can use them keep recentering or recorrecting your drift.

What I mean by tracking the bias is how soon the Kalman returns to zero after the quick roll I did. It naturally wants to peel off becuase its trusting more of the gryo readings but once it gets a couple good acceleration angles it quickly backs out the bias again. What I was looking for was when ever you put a Kalman'ed IMU through crazy manuevers like excessive vibration or centripetal accleration or linear acceleration for example the Kalman looses its center because your 1G down vector gets tossed around and is hard to resolve. The quicker the filter can respond to this the better. If its not tuned right you will see that its slugish to fix itself when you put it back on the table it will talke like 10 seconds to read zero roll again etc. But it pops right back almost like it was never lost to begin with if its tuned right.

Hence the reason why you were like "where is it" Its very subtile becuase its tuned so tight. Its the small curve up at the end when the Kalman zeros up.

Hope this helps:

As far as the no compass or gps... There is really no way to use conventional IMU's to get heading with out an extra sensor. It is exactly like expecting groll in my plot to be your heading. It will drift. So you have to have the Mag or GPS to bring you back or resolve your heading vector. The Magnetomer or GPS act in the same fashion as the accelerometers in this case. They find the gyro's drift and cancel it out. But they have thier own noise and imperfections like the acc so I also lean more on the gyros in this case.

-Ryan

rbeall
Feb 13, 2009, 09:58 PM
Here is an example of the Kalman leaning more on the Accelerometers. See how the Kalman follows aroll more than groll.....

Hope this helps kinda give you picture

drex
Feb 14, 2009, 01:37 AM
great post :)

yes you can trust the gps more at a certain pdop and speed etc than the mag or the mag more than the gps at higher pdop and slower speeds....... and vice versa based on what components you are using... and that will get the heading straightened out...

always good to use a tilt compensated compass (accelo and 3 axe mag)

RustySharpie
Feb 14, 2009, 03:42 AM
Thanks for the very informative posts. =) Looks like your kalman is very responsive.

I think I'm starting to understand it a bit more. The more gain you have on one sensor, the more the kalman will be affected by that sensor. Kinda like a PID controller maybe?

Damn. Was really hoping I could avoid the 3axis mag. I guess I'll have to go buy one and see how it is affected by being indoors. Hopefully it will be accurate enough. Looks like I got a crazy long way to go before I even get to the EKF =/

Any suggestions on how to make linear position from the double integration of the accelerometer more accurate?
PS. Whats pdop?

Sorry for all the questions =x

rbeall
Feb 14, 2009, 12:10 PM
double integration of the acceleration is the exact same problem as the gyros. There is just way too much noise. I have seen it in flight on a pretty robust autopilot as well as done on my imu and its looses itself almost instantly (double integrations blows up obviously a lot faster)

You can get the Kalman working without the mag. Obviously pitch and roll only but at least you can work on what you want to work on while waiting on the mag. Thats what I am doing. Still waiting on my drug dealer who gives me my parts to come through.

As far as the magnetometer, if there are interferances you can calibrate the thing to subtract it out. Assuming that you fly in the same building everytime. The perfect example of this having ferrus material actually on the aircraft. In my case the modem is right below my autopilot and skews the readings quite a bit. However you can reposition your heading cirlce over the center reference point as well as correct for any eliptical effects of the ferrus objects quite easliy actually.


More work but pretty achievable, specially if I can do it Ha
-Ryan

RustySharpie
Feb 14, 2009, 05:47 PM
Damn...guess I'll have to find another way besides double integration for the accelerometers for position.

I'd better get started on my Kalman for roll and pitch. Seems like its gonna take awhile.
I tried integrating my data for 10 mins of standstill at 1000 samples/sec and it took hours to compute in MatLab.
My drift looks like ~2 degs/sec
http://i42.tinypic.com/mwupfb.jpg


As for the magnetometer, I wanted to work in every building I might go to. But from your description, I'm guessing thats is impossible.

Thanks again guys

If anyone get ideas on how to get position from acceleration besides double integration, please share. =)

drex
Feb 14, 2009, 11:01 PM
pdop is total degree of precision....... lower # is better... it is an indication of how good a fix you got.... and you can have a cutoff in your code to trust the other gps data, also using speed and COG (heading) information in your filter if necessary....

you could also select between the 3 axis mag and the gps..

however you did say it was indoors.... so that is in all likeliness out the window.

how about some type of 3d orientation system indoors? that could help er out alot.


yes there is a calibration for mags, which usually involve a 360 rotation in a flat plane...... which can be rather troublesome...

the micromag is a popular 3 axis mag and is available from www.sparkfun.com

SPI port....

Quandumphone
Feb 15, 2009, 12:15 AM
This is good info. I've just recently started building an IMU as a for-fun project. The filtering is a bigger deal than I expected but I'm learning a lot. My individual sensors are filtered fairly well and am about to start integrating them. I've been studying the kalman filter quite a bit and am starting to get a handle on it. The math is a bit over my head but it is slowly sinking in. If any of you have some good sources for info to study for the semi-layman, I'd sure appreciate it.

rbeall
Feb 15, 2009, 01:47 AM
Honestly I wouldn't be surprised if you could find a gps module and a chip antenna these days that would work inside. Some of the stuff done on the attopilot used a module that worked well inside. But as far as I know there really isn't much out there other than gps. But it all depends upon what you are trying to accomplish. If wall avoidance is good enough then other approaches can be looked at.

As far as a good Kalman resource...

http://tom.pycke.be/mav/71/kalman-filtering-of-imu-data

Tom's site is how I got mine running... Great explinations and great documentation

-Ryan

Quandumphone
Feb 15, 2009, 07:14 PM
Thanks for the link. I'll be studying that too.

Tuner
Feb 16, 2009, 11:46 AM
GPS indoors = WHY??? Its unreliable and you can do better.

The nice thing about indoors is you have a lot of known points of reference. I would use distance sensor and SLAM. If you have a layout you can combine an internal map with sensor data to figure out where you are.

Good Luck!

RustySharpie
Feb 16, 2009, 10:45 PM
Good link on Kalman Filtering, though it will take some time to figure out what it all means. Also good info on accelerometers and gyroscopes. That site linked to this one
http://www.cs.unc.edu/%7Ewelch/kalman/
which seems to have alot of stuff Kalman too.

Care to elaborate what distance sensor and SLAM is? Or what your idea is? It sounds promising. =D

Quandumphone
Feb 17, 2009, 09:56 AM
What are you all using for graphing systems. I've seen people use similar charts and I've been wondering where to get that software.

rbeall
Feb 17, 2009, 07:28 PM
Matlab, a very versatile engineering software

RustySharpie
Feb 18, 2009, 01:55 AM
+1 for Matlab. Very easy to pick up.