0
\$\begingroup\$

I'm building a project that uses an IMU (Inertial Measurement Unit). The project involves the device to be mounted inside a vehicle and I should provide the acceleration, angular velocity and Euler angles of the vehicle (and not the device).
After a few reading I understand that I must rotate the 3D axis of acceleration from the device frame (reference frame) into the Earth frame. To do this I can use quaternion rotation as described here (SO Question). But what about angular velocity? Can the gyroscope axis rotations also be rotated using quaternions?
And as I'm a bit confused, once I rotate the axes, I can calculate the Euler angles from the quaternions. Am I right?
I have come across many algorithms that calculate the quaterions (Madwick's Algo). After the calculation of the quaternions can I use "SO question"'s approach to rotate the device frame into Earth frame?

In brief:
I need to get accelerometer, gyroscope, Euler angle data for the earth plane. I'm a bit confused and so this question is just to understand the best approach for this problem.

\$\endgroup\$
2
\$\begingroup\$

The IMU should have the same axes for the accelerometer, gyroscope and whatever else there is inside. Just look it up in the datasheet.

My approach to this would be to first make sure that the axes of your IMU are alligned with the axes of your vehicle since the IMU can only measure the velocity, euler angles and so on of itself.

To get the euler angles from your IMU you can use this:

https://robotics.stackexchange.com/questions/4511/euler-angles-from-9dof-imu

assuming your IMU has a Magnetometer. Otherwise there are many tutorials on how to get the roll, pitch and yaw angle from IMUs:

https://engineering.stackexchange.com/questions/3348/calculating-pitch-yaw-and-roll-from-mag-acc-and-gyro-data

After this, you already have the euler angles you need and you can rotate the vectors you want (acceleration and angular velocity) into the earth frame. This can be done with quaternions as you mentioned. For this there are also a lot of tutorials online. The madgwick paper where you got the algorithm from has a good explanation for this problem.

So to clarify: You calculate the orientation of your reference frame relative to your world frame (Euler angles) with your IMU. Then you can rotate whatever vectors your IMU gives you (acceleration, angular velocity, ...) from your reference frame into the earth frame and use them (calculate trajectory, compensate gravity, calculate movement etc.)

\$\endgroup\$
  • \$\begingroup\$ I don't have to have my IMU aligned with the vehicle axes, do I? I can rotate the axes into the earth frame after calculating the quaternions or DCM. But, thank you! Could you also link in some material I can go through if you have prior experience in this. \$\endgroup\$ – clmno Sep 11 '18 at 4:13
  • \$\begingroup\$ Depends if you need your values (acceleration etc.) in your earth frame or the car frame (Acceleration along the cars x-axis and so on). For the first case you are right, the axes don't need to be alligned. For the second case it is helpful since you don't need to think about how your car axes differ from your IMU axes. The euler angles are ofter referred to as "roll", "pitch" and "yaw": en.wikipedia.org/wiki/Aircraft_principal_axes \$\endgroup\$ – Robert Reichel Sep 11 '18 at 5:46
  • \$\begingroup\$ To calculate these angles use the info in my previous answer or just google it (eg: "get yaw from magnetometer"). You can get roll and pitch from your accelerometer, yaw from your magnetometer and the gyroscope records the relative change in these angles. For the quaternions I would recommend the original paper from madgwick: x-io.co.uk/res/doc/madgwick_internal_report.pdf Not only does it explain the filter algorithm but it also has a great explanation of quaternions in chapter 2. \$\endgroup\$ – Robert Reichel Sep 11 '18 at 5:50
  • \$\begingroup\$ After this you should be able to rotate your acceleration etc. to whatever frame you want. The just subtract gravity from your accelerometer to get the acceleration of your car. The euler angles are already known. And for the angular velocity just do the same as for the acceleration, rotate it into the earth frame. Angular velocity is measured with your gyroscope: en.wikipedia.org/wiki/Gyroscope en.wikipedia.org/wiki/Angular_velocity It is basically the change in your angle over time just like velocity is the change in position over time. \$\endgroup\$ – Robert Reichel Sep 11 '18 at 5:53
  • \$\begingroup\$ If something is unclear or you need further help just ask. And sorry for the multiple comments, somehow I used up all allowed characters for my comments in the previous ones so I had to split them up, I am still a bit of a newbie^^ \$\endgroup\$ – Robert Reichel Sep 11 '18 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.