Sensors for Attitude Estimation

3689740489?profile=original

Hello UAV enthusiasts,

I recently created a slide deck on the topic of sensors for attitude estimation (i.e. gyroscopes, accelerometers and magnetometers). In these slides, I review

  1. Installation considerations,
  2. Stochastic models,
  3. Bias characterization,
  4. Sensor calibration, and
  5. Conceptual models.

The methods and concepts contained in these slides have been "battle tested''. That is, these are the methods and concepts I used while developing a lightweight autopilot system for UAVs. I hope you find some of this material useful. These slides were part of a graduate course titled "Control of Marine and Aerial Vehicles".

All the best,

Matthew

silic_uav_sensors_v2.pdf

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Additionally, if you are using the AK8963 (which is also embedded in some Invensense chips), you might want to switch to a 5883 clone component. I have used this part in my drone for YEARS with no problems. Note it is critical to not have any stray mag fields (i.e.,power supply traces or cables carrying more than 500mA ) within 10mm of the part. Some board makers might not be complying with this requirement.

  • Hello Matthew,

    Technical note regarding compass chips (magnetometers); most drones are using magneto-resistive magnetometers like the Honeywell 5883/5983, and not Hall effect sensors. One of the most common Hall sensors, the AK8963, has been discontinued. Honeywell was the original maker of the ubiquitous 5883 and its successor 5983. Inexplicably, Honeywell sold the 5883/5983 product line to a Chinese company, QST.

    Side note: The Chinese seems to have developed a monopoly on this critical component. There are no longer any manufacturers of a compass chip in the US. Memsic, located in Maryland, is actually a Chinese owned company; parts are made in China.

    There are also clones of the 5x83. Memsic is probably the most advanced clone MMC5983. The MMC5883 is an improved 5883 compatible component. Additionally, one detrimental attribute of the magneto-resistive sensor is it can be "flipped", i.e., poles reversed inadvertently by a strong magnetic field. However, within a drone, this is unlikely to happen. The sensors have a "rest' mode which activate an electro-magnetic strap insdied the chip to restore the original magnetic field sensing to values stored in the chip's  ROM. The Hall effect sensor does not have this problem.

    Have you published a paper on your " lightweight autopilot system for UAVs"?

  • Matthew, if this is at all interesting to you I would offer to run one of your flight data sets through my hud rendering system to see what happens.  Essentially what I do is mount an action cam somewhere on the airplane with as much of a clear view as possible, but some prop or airframe in the view usually isn't a problem.  The camera can point just about anywhere as long as it's mostly in the direction of one of the major axes.  Press record on the video camera, go fly (logging GPS and high rate IMU data.)

    For the first time, I also need to do a camera calibration which involves taking dozens of pictures (or a minute or two video) of the standard checkerboard pattern used for lens calibration.

    Pretty much everything else is automatic after that.  (Some of the extra stuff I draw comes from my particular data file format, so there could need to be some juggling with data file formats.)

    The videos don't show anything that's not already in plots from the data logs, but seeing things from a first-person perspective in real time can be enlightening.  Creating videos of my own flights has led to a lot of thinking, investigation, learning, tweaking, and tuning.

    Also, hopefully no one thinks I'm trying to pass myself off as an expert here.  I don't have the math background to sit down and derive a kalman filter from scratch.  But I've been flying and working with this same 15-state EKF for more than 10 years now so I've built up quite a trust in what it does or doesn't do.  Anyway, I'm also enjoying the discussion, and if any of the tools or tricks I've developed can help out your efforts, I'm happy to offer them up.  (All our lab code is published with the MIT open-source license.)

  • hmm, mostly i use uncalibrated mag data!
    the hmc5983 has a build in offset correction.

    as the hmc5983 is available in homeopathic dosis i will dig in the dpi method.

    i have used mahony in the past and try to avoid this kinda sensorfusion.

    the internal pi controller uses a 2nd order correction which is a pain in the back when flying through turbolent zones.

  • Hey Curt,

    The YouTube video you posted looks amazing! I like how the flight trajectory stays up on the HUD. So you use temperature-dependent calibration coefficients? I've never tried to capture the temperature-dependence. I've always assumed the temperature doesn't affect the calibration too much, but I've never verified that assumption. Any idea on how much error the temperature might introduce into your attitude estimate?

    I totally get the love/hate relationship with mags! I have yet to rely on a magnetometer during a flight test. Because I work exclusively with fixed-wing vehicles, the course-over-ground (cog) readings from the GPS seems to suffice. However, like you said, that isn't an option for hovering vehicles or sluggish surface vehicles.

    Although I haven't used the magnetometer in the air, I've gotten it to work on the ground, while mounted in the vehicle. I can typically get the error in the estimated yaw angle to be under 3 degrees, which is sufficient for my needs. In order to get this accuracy, two key steps are needed.

    First, the calibration procedure must correct any misalignment between the magnetometer and the accelerometer.  A lot of calibration procedures simply map the uncalibrated magnetometer readings to a sphere; because these procedures do not correct for mutual misalignment, the estimated yaw angle can be quite inaccurate. The Dot Product Invariance (DPI) method that I mention in the slides does correct for mutual misalignment. As such, the DPI method can be used to calibrate the magnetometer for use in navigation systems.

    Second, the DPI method needs to be supplied with many, accurate observations of the reference down direction. Through trial and error, I found a reliable source, namely the downward direction as estimated by the attitude estimator. We estimate our attitude using the Mahony Filter. The Mahony Filter fuses gyroscope and accelerometer readings to maintain an accurate earth-to-body rotation matrix. The last column of this rotation matrix provides me with the reference direction I need for magnetometer calibration.

    There are two advantages for using the third column of the rotation matrix. First, because the reference vector is fused from gyroscope and accelerometer readings, the vector is less sensitive to errors in the accelerometer. Second, because the vector is measured using the onboard IMU, I can calibrate the magnetometer by rotating the vehicle by hand. It is especially important to calibrate the magnetometer in its final configuration on the vehicle. I think the gimbal system shown in the YouTube video posted by Robert is great for calibrating an isolated magnetometer. However, once that magnetometer is mounted in the vehicle, I would imagine the calibration would no longer be valid. 

    Anyways, this response is getting long. I'll detail my procedure in a future post :) It's great to talk to fellow researchers in my field. Best of luck with your research, Curt!

  • yes, it doesn't look bad.

    i have clue what would be good and in contrast bad.

    https://www.youtube.com/watch?v=XqQCbkncVYI

    i prefer simpler things.

    using a milled cube and turn it fast on a granite table.

    that's always interesting to watch and easy to do.

    and doing so the 15 state ekf failed as i mentioned.

    it took to long to recover.

    i am not using paul riseborough's ekf but the older one :-)

  • The UMN 15-state EKF requires changes in velocity (from the perspective of the gps) in order to for the heading to converge without mags.  It really works well for fixed wing flight (higher dynamic motion.)  For quads that spend much of their time hovering or for slow moving surface vehicles, often there isn't enough change in velocity for the EKF heading to converge well during the flight.  I developed a conformal hud overlay system to help evaluate the quality of an EKF and the flight control system.  We don't generally fly pixhawk, but I was given a couple data sets a while back.  My overall impression was that the px4 ekf also performed well.  The px4 datasets had drop out issues due to running with the stock (crappy/slow) sd card.  That seemed to only be a data logging issue that was largely resolved with an sd card upgrade.
    We've found that our EKF filter runs identically with 4-byte floats versus 8-byte floats as long as we store position (lon, lat) with double precision floats.

    I have a love/hate relationship with mags!  They are subject to so many various sources of interference that will pull the ekf solution away from truth.  Things like throttle changes can't be easily calibrated out on the ground.  So in many ways they help the system to be converged right out of the starting gate, but then over and over I see that they converge to not quite the right answer because the mag calibration is never perfect and always tugging the solution away from the truth.

    We have a variant of our UMN EKF that incorporates mags so I've played with that a bit.  For fixed wing flights I ended up preferring the original non-mag version.

    The px4 ekf seems to have deweighted the mags quite a bit so in flight they don't have much affect, but after landing, you can see the attitude estimate slowly drift off to align with the mag calibration which again is easy to be 10-20 degrees off.

    I've posted this before (so apologies for that) but here is an example of what I'm talking about.  This is the UMN 15-state EKF solution being drawn over the top of action-cam video.  The horizon shows how well the pitch/roll estimate is doing (it's not perfect.)  I also draw sun/moon/shadow markers which can help show the accuracy of the heading estimate against real world objects (truth?)  Also I'm drawing what the flight control system is trying to do which in this case is an auto landing:

    https://www.youtube.com/watch?v=Su3sL4JhcQc

    I haven't seen anyone do anything similar with the px4 or arudpilot ekf ... might be interesting to see a comparison?

    A lot of this boils down to use-case.  I'm not trying to sell our EKF to anyone here, I just find it interesting to talk about and compare and contrast, and wanted to add a comment about some of my experiments with in-flight calibration based on trusting our 15-state EKF.

  • the 15 state ekf did cause some disappointing results in comparison with the px4 ekf.

    if it starts raining again i will redo some of my tests - hopefully with a double precision fpu.

    6 axis sensor fusion is ok as the mag do tends to disappear.

  • Hi Matthew,

    Nice explanation of the important issues with our UAV sensors.

    I work for Prof. Gebre (listed in your references) at the U of MN UAV lab.  For attitude determination we primarily fly a 15-state ekf he published a few years back.  This EKF models accel and gyro biases and does not use a magnetometer (good or bad depending on your use case.) I have been experimenting with some calibration ideas that trust the results of the EKF.

    1. We log IMU temp and Accel biases.  Then in post process over the course of multiple flights, we can biuld a temperature calibration fit for each individual IMU.  The fit improves and spans a wider and wider temp range the more we fly.  This is probably not as good as a lab calibration in some respects, but it does yield a helpful improvement over accels that are only calibrated at a single temp.

    2. Similarly, we can compare the ideal magnetometer vector (computed from EKF attitude and the NOAA world magnetic model) versus the raw sensed magnetometer vector.  Again we can log those values and later do a fit.  I've found that that the fit is generally pretty tight and linear in each axis.  The advantage of this style mag calibration is you are calibrating at typical flight conditions and throttle settings.

    It's extra work to post process the flight data, update the fit, and push that back to the aircraft, but it seems to work pretty well.  At some point I'd like to experiment with building this functionality directly into our in-house autopilot so the system would self calibrate as it flies.  All of this hinges on trust in our 15-state EKF.

  • thanks for sharing!

    a lot to read ...

This reply was deleted.