Now that I'm using my new Robovero/Mikrokopter interface board, I figured it was about time that I recalibrated the accelerometer and compass to reflect the new orientation.  When I started the recalibration procedure I realized that I never really documented my calibration in the first place.  Here's how I did it this time:Accelerometer (roll/pitch)

  1. Using Simulink and the Robovero/Mikrokopter block, enable the sensor output.  Set the output rate to something around 50 (Hz).
  2. Position the quadrotor so that it's perfectly flat with Zb (body frame Z axis) down.
  3. Run the Simulink code for 60 seconds or so to collect the data.  If it's running via ssh, will need to use pscp.exe to download from the Gumstix.
  4. Position the quadrotor upside down so that Zb is up.
  5. Run the Simulink code again for 60 seconds and transfer the data back to the host computer (make sure to rename it, I like something like data_accel_z_down.mat or something like that).
  6. Do steps 2-5 for Yb and Xb, save all the data.
  7. Put the files in the appropriate folder and run "calibration_routine.m", that will generate m_accel, b_accel, m_accel_int and b_accel_int.  These are the floating point and integer gain and offset matrices, respectively.  To use them, take the raw data (x), multiply by m_ and add with b_ (y=m_*x+b_).
  8. The integer versions are scaled and can be directly inputted into the Robovero attitude estimator.

Compass (heading)

  1. Again using the Simulink block, save a large (5 minutes) about of data while rotating the quadrotor around in 3D.  Essentially you want to rotate it around to generate a shere of compass measurements.
  2. Save this data (data_compass.mat).
  3. Position the quadrotor with Zb down.  Construct a means of rotating it around this position (Zb is easy, other axis require fixing quadrotor arm to block of wood and leveling).
  4. Collect about 60 seconds worth of data of rotating with Zb (Yb, Xb) down.  This should scribe out a circle of compass data.  Do for Zb, Yb and Xb down.
  5. Save this data (data_compass_z_down.mat).
  6. Move this data to the appropriate folder and run the compass "calibration_routine.m", it needs to be done cell by cell.  The first cell will generate the data_compass.txt file needed by MagCal.
  7. Run MagCal.exe, can be found by following links/instructions here.
  8. Use H_inf = 1 so that we get a sphere of unit radius, open your data_compass.txt file and hit calibrate.  Save the file (data_compass_magcal.txt).
  9. The next cell in the routine assumes you saved the MagCal parameters in data_compass_magcal.txt, it will then load those parameters and calculate one of the gains and offsets.
  10. Next it loads your 2D circles and calculates the misalignment matrix.
  11. When it's done, it will generate m_compass, b_compass, m_compass_int and b_compass_int.  These are used in the same way as the accelerometer matrices.

This should give a decent result for attitude estimation.  For more accurate MagCal measurements, you can use magneto12.exe (same website), it gives more sig-figs.

Last modified Sun, 7 Jul, 2013 at 13:57