2024-01-16 02:14 AM
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:
2024-01-18 12:47 AM
Hi @Gorbit99 ,
Have you already done gyroscope and accelerometer calibration in order to compensate the offset? If not, please do this and let me know if this helps.
2024-01-18 04:50 AM
Hi Federica,
It's not about an offset, it's some values that are physically impossible to hit. Specifically around the 180 degrees. Even if a sensor is perfectly calibrated, it will skip some values.
2024-01-18 05:13 AM
Hi @Federica Bossi , to explain further:
According to the image, the gaps around the 180-degree mark correspond to the limitations of FP16 in representing values when X approaches -1 with high precision. There are fewer representable numbers close to X = -1, which results in larger gaps in the possible quaternion values, and hence in the perceived rotation.
This is a known issue with FP16, as it has only 10 bits for the fraction (mantissa), limiting its ability to represent numbers close together when they are near the ends of its range. As rotations approach 180 degrees, the quaternions tend to have components near x= -1, and the precision of FP16 is not sufficient to represent small changes in angle, resulting in the observed "gaps".
A possible fix would be to enhance the sensor fusion algorithms to utilize FP32 instead of FP16 through a firmware update, if possible.
2024-01-22 03:01 AM
Bump
We're still facing this issue, and it'd be very important for us to get this fixed somehow. I'd assume that there's some built in solution to this, but neither the samples, nor the datasheet is of any help.
2024-01-29 06:20 AM - edited 2024-01-29 06:21 AM
Bump.
Here's a more detailed explanation of what is causing the issue:
1. As per the datasheet, LSM6DSV sends the game rotation vector data using 16-bit floating-point format.
2. The largest number less than one FP16 can represent is approximately 0.99951172, which means there are no representable numbers between that and 1.0.
3. The game rotation vector data is sent as quaternions, so the 0.99951172 figure represents a quaternion component.
4. Using any utility to convert quaternions to Euler angles, entering 0.99951172 as a Z component results in a rotation of approximately 176.41885993 degrees along the Z axis.
This implies that LSM6DSV cannot send any rotation values between the -176.42, 180.00, 176.42 points, which is exactly the issue we experience and what is shown in the calculated plot above. The rotation values simply snap into one of those points, skipping the 180-degree point most of the time because the sensor is not perfectly horizontal. This results in a 7.16 degrees gap, which may be further worsened if we utilize any kind of prediction algorithms to compensate network delays.
@Federica Bossi This flaw in the product design makes the game rotation vector feature unusable in its current state. Other IMUs avoid this problem by utilizing a fixed-point format with, for example, a 14 Q-point value (although 15 would be ideal in this case). I hope it is possible to release a firmware update for this IMU to change the number format.
2024-01-30 07:22 AM
Hi all,
You wrote that: the game rotation vector data is sent as quaternions, so the 0.99951172 figure represents a quaternion component.
However you can refer to the AN5922 where in section 9.6.3 we explain that: Game rotation vector: X, Y, and Z axes (vector part of the quaternion) are stored in half-precision floatingpoint format, where w (scalar part of the quaternion) is computed in software after reading the data from the FIFO, since the game rotation vector is a unit quaternion.
For more details you can also look at wikipedia:
2024-01-30 11:02 AM
Hi Federica,
I appreciate the help, but that's not the issue. We do calculate the w component of the quaternion from the x^2 + y^2 + z^2 + w^2 = 1 equation. Let's assume z=0.99951172, x and y are 0. From that equation, one can calculate w being 0.03124614504. So we get a quaternion of the form:
x=0, y=0, z=0.99951172, w=0.03124614504
Converting that quaternion to an angle, we get z=176.4188726 degrees as a result. It's physically impossible to get anywhere closer to 180 degrees, because that would need the z value to be closer to 1. For example, to get 178 degrees, we would need z=0.9998477, which will be rounded to either 1 or 0.99951172 because of the half precision. Therefore there is a significant gap between about 176 degrees and 180 degrees that are unrepresentable.
This is our problem.
2024-02-01 07:56 AM
Hi @Gorbit99 ,
I understand your problem now. It is a known issue on which we are working.
For our next product it will be fixed and all the quaternion components will be saved in FIFO.
Sorry for that.
2024-02-01 09:07 AM
Sorry, but are you telling me that the stock we already have is essentially useless? I don't quite understand, how storing all components in the FIFO would fix this issue, if they are still half precision, the same error would still show up.