I'm working with a system of IMUs where each IMU outputs an orientation quaternion which is then converted into Euler angles. I want to be able to standardize the meaning of the Euler angles across all of the sensors. However, the way the sensors are set up, the $x$-axis (heading) of the sensors are pointing in different directions. So the EulerX (and EulerY) angles from each sensor represent different kinds of movement (one represents what could be considered roll of the body and another pitch of the body). I want to be able to make it so that the EulerX output represents roll of the body on every sensor.

Now this seems doable by just switching the EulerX and EulerY components on the output (i.e. $[1.5, .3, .5]$ -> $[.3, 1.5, .5]$ where [roll, pitch, yaw]) however this seems inelegant and feels like it's missing a true understanding of how quaternions work. So I'm wondering if there's a method for determining the transformation quaternion that I can multiply each sensor by that will satisfy the swapping of the Euler angles laid out above when the quaternion is converted to Euler Angles.

If it helps the sensors are set up so that one sensor is pointing forward on the rigid body (the direction I want) another is set at a $90°$ angle and another is set at a $180°$ angle (with relatively similar pitch and roll values)

Previous Work

I had some success finding a representation of the sensor turned $180°$ by right multiplying the orientation quaternion (q1) by a $180°$ yaw rotation quaternion. This returned the following Euler results: $q1 = [eX, eY, eZ]$ -> $[-eX, -eY, eZ-180°]$

However when I try to do the same for the sensor that is $90°$ off by right multiplying by a quaternion representing a $90°$ rotation. That doesn't work. Clearly there's a lack of understanding I have about what these right hand multiplications represent.


In [219]: quat = np.matrix([0.6094978‌​, -0.757683, 0.05746635, -0.2261116]) print(Calc_Euler(qua‌​t)) Out [219]: [-1.7323621052571858‌​, -0.27608459761902809‌​, -0.38654233181239173‌​]

So these are the Euler Angles I get for the quaternion off the sensor. Now if I apply a right hand 90 degree rotation here's what I get.

In [221]: quat = np.matrix([0.6094978‌​, -0.757683, 0.05746635, -0.2261116]) sensfr = np.matrix([1,0,0,1])‌​/np.linalg.norm([1,0,‌​0,1]) new_q = QuatProd(quat, sensfr) print(Calc_Euler(new‌​_q)) Out [221]: [-2.087188748187, 1.251957112363, -0.9254284237615]


1 Answer 1


All you need is, for each sensor, a quaternion representing the IMU's orientation relative to the body.

Let IMU $i$ have a quaternion $b_i$ that represents its orientation relative to the body, and let $m_i$ be the orientation that the IMU measures (you haven't said what orientation this is).

Then $m_i b_i$ takes the measured orientation and puts it back in the body frame. You could then compute Euler angles from this, and these angles will correspond to rotations about the body axes.

  • $\begingroup$ So $m_i$ is the sensors orientation relative to a global frame defined by gravity and magnetic north. If i were to apply a rotation like you suggested wouldn't that give me completely different roll and pitch values? When in reality I basically want the roll and pitch values to be swapped and then the yaw value to be degree heading away from magnetic north. I'm basically trying to change the heading of the frame so that the y-axis is now the x-axis and the y-axis is 180 degree from the original x-axis. $\endgroup$ Aug 15, 2016 at 15:29
  • $\begingroup$ I guess another way of asking this is that...if I rotate the heading of my global reference frame 90 degrees, shouldn't that result in the pitch and roll values being flip flopped when I got to convert the resulting quaternion into Euler angles? $\endgroup$ Aug 15, 2016 at 16:14
  • $\begingroup$ I would expect so, but I think you're going to have to consider conventions about what is positive roll and pitch to make sure that all the signs are right. $\endgroup$
    – Muphrid
    Aug 15, 2016 at 17:40
  • $\begingroup$ I edited the OP to show the code I'm using that reflects what I think we've discussed...as you can see the Euler Angles don't come out as expected irrespective of accounting for the fact that some should be negative under the new reference. At a bit of a loss for why that is. $\endgroup$ Aug 17, 2016 at 1:21
  • $\begingroup$ I drew up a python code to compute the Euler angles and my numbers agree. I think the problem may be that your angles don't cleanly correspond to roll, pitch, and yaw. In particular, the formula I used that matches your numbers corresponds to yaw, then roll, then yaw. $\endgroup$
    – Muphrid
    Aug 18, 2016 at 0:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .