cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSL gyroscope and rotation order

AdB
Associate II

Hello,

I am trying to use the output of the LSM6DSL (accelerometer + gyroscope) to feed an orientation filter. While the accelerometer part is easy to interpret, I am having some trouble with the gyroscope. Apologies if my question is trivial, I have not found any clear answer on the subject so I must have missed something very obvious.

 

The LSM6DSL returns the angular velocity of the device as a vector of 3 Euler angles, one per axis. With this sort of representation this usually means that the underlying rotation R is a composition of 3 axial rotations, either intrinsic or extrinsic, such as R = R_x * R_y * R_z or any of the permutations. The actual order of the permutation being crucial. The documentation is not 100% clear to me in what order I should apply the axial rotations to describe R.

There is no textual mention of this in the Application Note but on page 2 there is a diagram showing:

  • The axis of the accelerometer
  • The rotation Omega_Y, Omega_P, Omega_R

Where I guess that Omega_Y, _P and _R respectively stand for Yaw, Pitch, Roll. From my understanding when using this sort of notations, this implies that:

  • The rotation is intrinsic
  • The rotation around the Yaw axis should be applied first, then the pitch, finally the Roll, as in R = R_roll * R_pitch * R_yaw. 

When matching this information with the axis of the accelerometer, this would mean that R = Ry * Rx * Rz.

Is this correct ? Or should this still be R = Rx * Ry * Rz which is the most widespread (and natural) rotation order ? Or any other thing really ?

 

Thank you for your time,

AdB

1 ACCEPTED SOLUTION

Accepted Solutions

Design Tip DT0060 on st.com: dt0060-exploiting-the-gyroscope-to-update-tilt-measurement-and-ecompass-stmicroelectronics.pdf

It explains how to update the Euler angles or the quaternion representation.

 

View solution in original post

7 REPLIES 7
Federica Bossi
ST Employee

Hi @AdB ,

There are different methodologies to get rotation from a 6 Axis sensor (Accelerometer + Gyroscope), for example you can use Euler Angles or Quaternions, you can refer to DT0060.

Euler angles are for sure easier to be interpreted but suffers from ambiguity; different rotations sequence can land in different angles. With quaternions, instead, you have a single representation of rotation without ambiguity. Gimbal lock problem is also solved with quaternion representation.

In case of quaternions you can refer to ST MotionFX library at the following link that is able to generate quaternions from accelerometer and gyroscope data. Please note that convert quaternion in euler angles is also possible.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
AdB
Associate II

Hello,

Thank you for your answer. Unfortunately I can't open your first link, which seems to be missing a domain name. I have followed your 2nd link which leads to the documentation of a dedicated hardware running a complementary filter, probably close to what Mahony introduced in 2008. However, I seek to build my custom filter on top of the LSM6DSL, and for that I need to understand in detail the data it provides.

Quaternions representations are indeed very useful to avoid Gimbal Locks, ambiguities (since there are only 2 equivalent representations of the same angle as a quaternion), and also singularities around the +-90° points.

I'll rephrase my question: how can I use and interpret the data returned by the LSM6DSL ? Are the 3 values returned by the LSM6DSL independent of each other ? Or are they correlated and should be interpreted in a certain way  ?

In the first case, I can directly build a quaternion from them with a formula like q = [0, Wx, Wy, Wz]. where Wx, Wy, Wz are the axial angular velocities.

In the second case, I have to consider an Euler representation R_xyz= Rx * Ry * Rz where the order of rotation is important (what is it ?) before finding the corresponding quaternion.

Does my question make sense ?

Thank you for your time,

AdB

AdB
Associate II

Hello,

 

I managed to get my filter to work by using the quaternion q = [0, Wx, Wy, Wz].

I had unexpected behaviors at first and couldn't figure out whether it was because of bugs in my code or because I mishandled the LSM6DSL data, hence my post here, but I finally sorted it out and it was all on my part.

Thank your for your support,

Kind regards, AdB

Hi @AdB ,

I'm glad to hear that you solved the issue! Can you share here what the error was? maybe it can be helpful for someone else :)

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
AdB
Associate II

Sure, I doubt this will help anybody but who knows :)

I had 2 errors stacked over each other:

_ As I render the 3D model of my physical sensor on a 3rd party tool, I had to make a coordinate switch which in this case was a renaming of the axis. But for some reason, as this particular place in the code I was using euler angles instead of quaternions, which resulted in errors since the rotation order was not kept consistent. The solution was simply to make the switch using quaternions there too.

_ I am using a physical model of my system similar to the [Madgwick, 2010] paper to integrate the angular velocity as an orientation. But for some reason the rotation of the LSM6DSL resulted in a rotation relative to the Earth frame rather than the Sensor frame on the screen. As a solution I added an ad-hoc coordinate switch when computing the derivative of the orientation quaternion, that sadly does not add up with maths but probably compensate some error elsewhere instead (sad face).

The process was a little clunky but I am satisfied with the result. 

Thank you again.

Design Tip DT0060 on st.com: dt0060-exploiting-the-gyroscope-to-update-tilt-measurement-and-ecompass-stmicroelectronics.pdf

It explains how to update the Euler angles or the quaternion representation.

 

AdB
Associate II

I can confirm that this document would have been helpful had I my hands on it, though it could include references to mentioned literature.

 

Have a good day.