08-01-2022 01:19 PM - edited 08-01-2022 01:19 PM
Hi Team,
I have got the quaternion values from BHI160 using MCU. Now we need to read RPY data from the BHI160B IMU. I found that if we change VS_TYPE to "VS_TYPE_ORIENTATION", will that helps to get RPY data?
because we have one call-back function which gives only Quaterninons x,y,z, and w data.
Is there any process to read RPY or the same function enough based VS_TYPE? If Yes, where is that RPY data located?
Could you let me know the way to get RPY?
Any help would be very thankful.
Solved! Go to Solution.
08-09-2022 10:19 AM
Hi vamshi,
The above code converts the data output by the algorithm into standard quaternion . The conversion from quaternion to Euler angles needs to be implemented by yourself. In fact, there are many examples on the Internet. You can search them.
08-11-2022 11:43 AM
Thank you @BSTRobin ,
I have done the following to get Euler Angles
q[0] = sensor_data->data_quaternion.x;
q[1] = sensor_data->data_quaternion.y;
q[2] = sensor_data->data_quaternion.z;
q[3] = sensor_data->data_quaternion.w;
euler[0] = atan2(2 * q[1] * q[2] - 2 * q[0] * q[3], 2 * q[0]*q[0] + 2 * q[1] * q[1] - 1); // psi
euler[0] = (euler[0]*57.2958f);
euler[1] = -asin(2 * q[1] * q[3] + 2 * q[0] * q[2]); // theta
euler[1] = (euler[1]*57.2958f);
euler[2] = atan2(2 * q[2] * q[3] - 2 * q[0] * q[1], 2 * q[0] * q[0] + 2 * q[3] * q[3] - 1); // phi
euler[2] = (euler[2]*57.2958f);
Now I'm able to get Euler angles with Standard Quaternions.
Thanks for your help.
08-12-2022 08:31 AM
Welcome, vamshi.