Compensation for IMU mounting misalignment

I have an MPU6050 IMU and I would like to mount it on an FSAE car and use it to measure the yaw, pitch, roll, and angular velocities as it drives. As it's impossible to mount it perfectly flat and align the IMU axes with the axes of the car, I am looking for a way to calibrate and compensate for the rotational offset of the car's frame and the IMU's frame.

From the IMU I can get quaternions, Euler angles, raw acceleration and angular velocity data, or yaw, pitch, and roll values. I imagine the solution will involve matrix and trig calculations, but I didn't pay nearly enough attention in multivariable calc to figure this out.

• This question has a similar cousin on this exchange site. Did you check for that already? Commented Dec 22, 2017 at 18:32
• @GürkanÇetin If there is a similar/duplicate post, you should flag and/or provide the link in your comment Commented Jul 20, 2018 at 22:07

You need the transformation from the car to the IMU.

You can get this by recording the IMU published attitude with the car in known orientations.

You should be able to construct the IMU to car transformation by grabbing the IMU orientation while the car is flat, pitched up a bit (30 deg would should enough), and rolled (again, 30 deg should be enough).

Using the three known car attitudes and the three measured IMU attitudes you should be able to construct the car IMU transformation.

• Thanks! Could you go a little more into detail about how the compensation would work once I have measured offsets around two axes? Because offset in one axis results in compounded changes in other axes, I imagine there's some compensation matrix I would have to multiply against, but I'm not sure how I would construct such a matrix. Commented Jun 25, 2017 at 14:58

I am going through a similar issue. Please check this link below for initial calibration in all the axis. This is not for MPU but a similar method could be followed. I am still working on it and, If I find a suitable solution, I will update. Hope this helps.

https://chionophilous.wordpress.com/2011/08/26/accelerometer-calibration-ii-simple-methods/

Also, refer to this pdf below. This is just for the accelerometer. But might be helpful.

https://www.st.com/resource/en/application_note/dm00119044.pdf