I'm working with the LSM6DSV16X IMU sensor, which comes with a Sensor Fusion Low-Power (SFLP) algorithm providing a 6-axis game rotation vector (quaternion) stored directly in the FIFO. The datasheet mentions that the FIFO stores the x, y, z components of the quaternion, but (as far as I can tell) it lacks specific details on how to interpret these raw data bytes into meaningful quaternion values (specifically, the scaling factor or format used for these components).
Here's what I know based on the datasheet:
The FIFO stores data in 7-byte words, with the first byte being a tag (indicating data type) and the following 6 bytes containing the fixed data. My goal is to extract and convert these raw x, y, and z components into floating-point numbers that accurately represent the quaternion's orientation.
However, I cannot find explicit documentation on the scaling or representation of these components, I'm not sure what the correct approach is to decode this data.
I've experimented with common scaling factors but haven't confidently determined the correct method.
My questions are:
- Has anyone worked with the LSM6DSV16X or similar IMUs and can provide insights into decoding the quaternion data from the FIFO?
- What common scaling factors or methods might apply to this sensor for converting raw data bytes into meaningful quaternion components?
Any help is appreciated!
How I am extracting the raw FIFO data
// Retrieve the raw FIFO data.
if (lsm6dsv16x_fifo_out_raw_get(&sfe_dev, &raw) != 0 || raw.tag != 0x13)
{
// No good
return false;
}
// Extract the quaternion data from the raw FIFO data
int16_t raw_x = ((raw.data[1] << 8) | raw.data[0]);
int16_t raw_y = ((raw.data[3] << 8) | raw.data[2]);
int16_t raw_z = ((raw.data[5] << 8) | raw.data[4]);
// Store the quaternion data
quat->xData = raw_x;
quat->yData = raw_y;
quat->zData = raw_z;
return true;
Output:
The output is really stable and the correct axis responds when moved.
x, y, z - Raw Quaternion Data: 8324, 7590, 13069
x, y, z - Raw Quaternion Data: 8324, 7590, 13069
x, y, z - Raw Quaternion Data: 8325, 7591, 13069
x, y, z - Raw Quaternion Data: 8326, 7591, 13069
x, y, z - Raw Quaternion Data: 8324, 7593, 13069
x, y, z - Raw Quaternion Data: 8322, 7596, 13069
x, y, z - Raw Quaternion Data: 8320, 7597, 13069
x, y, z - Raw Quaternion Data: 8318, 7603, 13069