cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSV half precision error at ~180 degrees

Gorbit99
Associate III

Hi,

We're using the lsm6dsv's SFLP algorithm to calculate IMU rotation. Recently however we noticed that the resulting rotation has big gaps at around the 180degree mark. We believe this is because of the half float precision, specifically because there aren't a lot of representable values near 1. See below image for our calculated accuracy results which match the actual results we're seeing:

1000000957.png

 

23 REPLIES 23
Federica Bossi
ST Employee

Hi @Gorbit99 ,

It is not an ST problem related to our libreries and sensors but it is an arithmetical problem when recalculating the weight. We are working to offer a workaround for the next generation IMUs.

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.

Hi Federica,

Sorry, but either we aren't talking about the same problem, or we are on entirely different pages about the issue.

The issue I am talking about is the following: With the number format the sensor is currently using, it is physically impossible for the sensor to send over a rotation representing 178 degrees. This isn't an arithmetical problem, it's simply a firmware problem, therefore it's an issue with the actual sensor, even if not with the hardware side of it.

And just so you understand my side of this issue, we've invested a not obvious amount of time and money into this sensor, so it'd be best if there was a workaround to this issue.

Hi @Gorbit99 ,

If you have bought a lot of parts and you need support, you should contact the OLS opening a ticket at this page.

This is not a case for st community.

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.

Dear Federica,

I have opened a ticket (two even), first I was told that this isn't a support issue and I should instead post here, then I was referred to this answer...

dorpomi
Associate

Hi @Federica Bossi ,

Can you please ask the engineers behind the IMU whether it is possible to flash another firmware on the IMU or override it on boot? We believe that the current issue can be resolved by simply encoding the rotational values in a slightly different format, and the ability to update the firmware is the first step towards a fix.

Simon24
Associate

Hi all,

What is the status of this issue? Is there already a firmware update available? We bought a large quantity of lsm6dsv with the idea of using the sensor fusion function provided to us. We therefore need a solution to this issue really soon.

flaufer
Associate II

Hi @Federica Bossi ,

are there any updates on this issue? I agree with @dorpomi - the fix is a matter of representation/encoding and a solution would be rather straight-forward.

Btw. does the ISM330BX use the same SFLP algorithm and has the same issues?

Kine regards,

Felix

phly
Associate

Need an update on this

Andrea VITALI
ST Employee

You are correct: the issue you are facing is related to the quantization of the half-precision float components of the quaternion stored in the FIFO.

The quaternion is made of four components: the scalar component qw = cos(angle/2), and the vector component qx qy qz = sin(angle/2) multiplied by the normalized direction of rotation [x,y,z]. Quaternion components satisfy the relation qw^2 + qx^2 + qy^2 + qz^2 = 1. Also, Q = [qw, qx, qy, qz] represents the same orientation as -Q. The SFLP output quaternion is chosen to have qw >= 0 always.

For efficiency, in LSM6DSV sensors the FIFO only stores 3 components: qx, qy, qz. The 4th component qw is recomputed as +sqrt(1 - qx^2 - qy^2 - qz^2) - newer generation sensors have been improved, see note below.

When any of the vector components, qx qy or qz, is near +/-1, the accuracy of qw is reduced as you have observed. 

The workaround is to readout the quaternion components from the embedded advanced features registers before the next accelerometer and gyroscope data sample is taken; the readout must be performed when the computation of the embedded functions is completed, otherwise the embedded functions will not work as expected and the device must be rebooted.

- All 4 quaternion components are stored in page 3, from 0x4C to 0x53 (qw, qx, qy, qz).

- Wait for the rising edge of INT2_EMB_FUNC_ENDOP to be sure readout is completed after the computation of the embedded functions is completed

- Advanced features registers must be read one byte at a time (multiple-byte readout operation is not available)

Example application code is attached.

Newer generation sensors store all 4 quaternion components in the FIFO. Contact sales and marketing for more information.

Andrea VITALI
ST Employee

The sensor fusion can also be performed on the STM32 microcontroller: see MotionFX in X-Cube-MEMS software package. User manual UM2220.

MotionFX is available as 6-axis sensor fusion (accelerometer and gyroscope) or 9-axis sensor fusion (accelerometer, gyroscope, magnetometer).