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)
- Using Simulink and the Robovero/Mikrokopter block, enable the sensor output. Set the output rate to something around 50 (Hz).
- Position the quadrotor so that it's perfectly flat with Zb (body frame Z axis) down.
- 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.
- Position the quadrotor upside down so that Zb is up.
- 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).
- Do steps 2-5 for Yb and Xb, save all the data.
- 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_).
- The integer versions are scaled and can be directly inputted into the Robovero attitude estimator.
- 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.
- Save this data (data_compass.mat).
- 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).
- 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.
- Save this data (data_compass_z_down.mat).
- 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.
- Run MagCal.exe, can be found by following links/instructions here.
- 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).
- 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.
- Next it loads your 2D circles and calculates the misalignment matrix.
- 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