Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    Read RPY Data from BHI160B IMU using STM32-L053R8

    Read RPY Data from BHI160B IMU using STM32-L053R8

    vamshi
    Established Member

    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.

    7 REPLIES 7

    BSTRobin
    Community Moderator
    Community Moderator

    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.

    vamshi
    Established Member

    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.

    BSTRobin
    Community Moderator
    Community Moderator

    Welcome, vamshi.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist