Kalman Filtering IMU Data

Here is the place for all your dsPic or autopilot questions.

Moderator: lukasz

Re: Kalman Filtering IMU Data

Postby Mitch » Tue Mar 16, 2010 1:05 am

As Tom posted, there are multiple approaches to this problem. Put simply, for a full up IMU I can't see doing it without a robust filter, whether it's an EKF, H infinity, or other... . Sensor cost, availability, and selection is where I started. Gyros and accelerometers are a must have. Tom has incorporated everything necessary on the gluonpilot board - with the addition of uart2 gps and an I2C three axis magnetometer the development potential is endless. The math does get complex, I've revisited concepts that I haven't even considered since I finished my aerospace engineering degree almost 30 years ago. There has been a lot of technical change since then. I've posted several other comments about the work I'm doing in this forum.

There are multiple papers and thesis available online that provide summary outlines of academic work in this area but few examples of actual code. For me it has been continuous improvement with each filter or method I write, but I don't know if I'll ever find the best combination. There are only a handful of successful homebrew IMUs out there. I have elected to forgo the modeling of the vehicle and, as you suggested, focused on the data and bandwidth that is available from the sensors.

Right now my best concept is written to mitigate the reduction of huge matrices, the largest is a 6x6, but there are a lot of them. I'm using a quaternion least squares estimator to create a single quaternion attitude estimate from accelerometers, magnetometers, and soon gps data. The vehicle attitude is propegated with the higher bandwidth gyro measurements, and fused with the estimator quaternion in an EKF (all in the quaternion domain). Results are very good on the bench but I haven't integrated the GPS yet.

Debugging is very time consuming. In a few weeks I may be to a point where I will test some accelerations by driving it around in a car and eventually flight testing.
User avatar
Mitch
 
Posts: 118
Joined: Sat Dec 05, 2009 1:59 pm
Location: Florida, USA

Re: Kalman Filtering IMU Data

Postby Tom » Wed Mar 17, 2010 8:37 pm

Hi Mitch,

I bet you are doing a great job out there. And yes, it is extermely time consuming. Are you planning to make you code open? Are you planning to implement it on the gluon board? Do you have real flight data from an RC-plane?

Tom
User avatar
Tom
Site Admin
 
Posts: 1016
Joined: Fri Nov 13, 2009 6:27 pm
Location: Belgium

Re: Kalman Filtering IMU Data

Postby Mitch » Wed Mar 17, 2010 11:38 pm

As far as my code goes - anyone can have any of it. I am reluctant to post anything at this point because it is a work in progress (not finished, not cleaned up, and not gluonpilot yet). I don't want to open a can of worms. My previous offer stands that anyone who wants any as a reference can pm and I'll email it.

I presently have working example code of:

The euler/quaternion EKF code conceived in the Kingston Beard paper "Real-Time Attitude and Position Estimation for Small UAVs Using Low-Cost Sensors."

A vector matching algorithm using vector cross products - Shuster. Builds a direction cosine matrix -> euler angles from accelerometer and magnetometer triads.

A quaternion least squares estimator as conceived in Gebre-Egziabher, Elkaim paper "A Gyro-Free Quaternion-Based Attitude Determination System Using Low Cost Sensors" which solves Wahba's vector matching problem in a practical and unique way. I exchanged a few emails with Professor Elkaim. He was very decent and offered to answer any specific questions I had, but he would not provide any code. He also offered a link to his online linear algebra refresher course!

A sensor fusion quaternion EKF as described in Gebre-Egziabher paper " Design of Multi Sensor Attitude Determination Systems."

The last three require full 3 axis magnetometer sensors for vector matching.

My development board is very similiar to the gluonpilot board so changing over will be straightforward (same micro but using a hacked sparkfun razor for sensors). The problematic difference is the headers are different so I have to use adapters for the peripherals. I am quite happy with the static performance and am starting gps integration. I will eventually convert it all to gluonpilot.

I've been in a quandry because I want to fly Tom's code in an airplane with the gluonpilot board and keep working on the IMU. I plan to switch over to the gluonpilot board at some point.

When I have the gps part done to my satisfaction, I'll start dynamic testing in a car. I've already logged gps accelerations while my daughter drove me around the neighborhood. Then I'll fly the board in a a few airplanes and helis and log the IMU performance as best I can via telemetry. I think that will provide better troubleshooting information than trying to simulate all of the sensor data at the necessary rates.

Also starting to become good flying weather here! I'm really getting behind in building. I try to have projects ready to spray in the spring before the humidity gets too high.
User avatar
Mitch
 
Posts: 118
Joined: Sat Dec 05, 2009 1:59 pm
Location: Florida, USA

Re: Kalman Filtering IMU Data

Postby Bucho » Sat Mar 27, 2010 9:46 am

This website ist very interesting!

@Tom:

Are you planning to post your firmware for the quaternion 6-DOF IMU? The video you posted in January was very amazing. At the moment I am learning the basics of kalman-filtering. Thanks to your Web-Page and your old MAV-blog page, step by step I become familiar with the kalman filter. Still I have some questions and i hope I can find some answers here.

I did understand the example with the 1-DOF filtered roll gyro. But what if you want to determine the attitude around all 3 euler angles? For the estimation step the system matrix A will change depending on the attitude. Is this assumption right, or do you work with constant matrices?
A second question is: How did you determine the process noise?

I hope you can give me some hints.

Best regards
Daniel
User avatar
Bucho
 
Posts: 5
Joined: Fri Mar 26, 2010 1:33 pm

Re: Kalman Filtering IMU Data

Postby Tom » Sun Mar 28, 2010 1:23 pm

Hi Daniel,

My current code is on the google code page (download). However the attitude calculation is using a slightly different apparoach now.
In my first versions I used a 2-state kalman filter per axis. This worked fine in 90% of the cases, but now we gotta do better. There are a lot of paper out there that discuss all the different approaches you can take. A common approach is to use 7 states: 4 for quaternions (attitude representation without "gimbal lock") and 3 for the bias of every gyro.

Process noise can be calculated to a certain degree, however the best values still need a lot of trial and error. The best approach IMO is to do simulations in Matlab using real data.

What do you mean by "the A matrix will change depending on the attitude"? It models the updates of you states and remains constant.
User avatar
Tom
Site Admin
 
Posts: 1016
Joined: Fri Nov 13, 2009 6:27 pm
Location: Belgium

Re: Kalman Filtering IMU Data

Postby Bucho » Fri Apr 02, 2010 10:10 am

Hello Tom,

I mean, that the transfer function of the system changes with the attitude, due to it's nonlinearity. Mike gave me the hint, that an EKF is the right approach, so I think I have to study the EKF first.
If you are using real data for the estimation of the process noise, I think you have to know the exact values of the whole state, to calculate the difference beween real state and calculated state. Where do you get these values?

Best regards
Daniel
User avatar
Bucho
 
Posts: 5
Joined: Fri Mar 26, 2010 1:33 pm

Re: Kalman Filtering IMU Data

Postby Mitch » Fri Apr 02, 2010 11:19 am

In practice, I've used a backwards approach. Write the functions, implement the filter in hardware, use some gross estimate of process noise. Refine the constants to produce the level of convergence and filtering I desire. There are process noise, measurement noise, convergence factors... all are application specific. That's why I use a visual tool such as Tom's cube or my vb6 attitude indicator to watch the attitude estimate(s) as the hardware is moved and vibrated - much easier than trying to sort through all of the numbers.


Link
User avatar
Mitch
 
Posts: 118
Joined: Sat Dec 05, 2009 1:59 pm
Location: Florida, USA

Re: Kalman Filtering IMU Data

Postby Tom » Sun Apr 11, 2010 5:04 pm

Thanks for the great little vid Mitch!

I have a lot of 50Hz datalogging from the gluonpilot module in flight which I use to compare the performance of different algorithms. See http://gluonpilot.com/wiki/Matlab_attitude_estimation

Would that be of any interest?
User avatar
Tom
Site Admin
 
Posts: 1016
Joined: Fri Nov 13, 2009 6:27 pm
Location: Belgium

Re: Kalman Filtering IMU Data

Postby Bucho » Mon Apr 12, 2010 7:31 pm

Thank you for the information. But first I have to go deeper in the theory.

Best regards
User avatar
Bucho
 
Posts: 5
Joined: Fri Mar 26, 2010 1:33 pm

Re: Kalman Filtering IMU Data

Postby Goldfinch » Fri Apr 16, 2010 9:22 am

Tom wrote:I have a lot of 50Hz datalogging from the gluonpilot module in flight which I use to compare the performance of different algorithms. See http://gluonpilot.com/wiki/Matlab_attitude_estimation

This is good result of angle estimation! Is the roll result similar to pitch? Did You use any other filters for IMU data? Maybe it is better to increase output frequency and apply filters to get 50 Hz angle output? What paper by Beard do You refer on algorithm 3 description? Could You please share the Matlab code with EKF 3x3?
Goldfinch
 
Posts: 12
Joined: Mon Mar 15, 2010 11:22 am
Location: Russia

PreviousNext

Return to Firmware

Who is online

Users browsing this forum: No registered users and 1 guest

cron