Bosch Sensortec Community

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

    What are the algorithms to be used to generate Quaternion data on Nicla Sense ME?

    What are the algorithms to be used to generate Quaternion data on Nicla Sense ME?

    hkayan
    Member

    Hi,

    I have Nicla Sense ME which contains BHI260AP & BMM150. I am curious about the algorithms to be used to generate Quaternion and euler angle.

    Also what are the units for accelerometer, gyroscope, and magnetometer data?  

    8 REPLIES 8

    BSTRobin
    Community Moderator
    Community Moderator

    Hello hkayan,

    Do you mean the RAW data unit output by the sensor or the unit output by the driving interface?

    Hi Robin,

    I mean the unit output by driving interface. I am adding an example code of how I generate my data.

    #include "Arduino.h"
    #include "Arduino_BHY2.h"
    #include "Nicla_System.h"
    
    SensorQuaternion rotation(SENSOR_ID_RV);
    SensorOrientation euler(SENSOR_ID_ORI);
    float heading = 0;
    float pitch = 0;
    float roll = 0;
    void setup()
    {
      Serial.begin(115200);
      while(!Serial);
      BHY2.begin();
      rotation.begin();
      euler.begin();
      //rotation.configure(50, 20); does not work
    }
    
    void loop()
    {
      // Update function should be continuously polled
      BHY2.update();
      float qX = rotation.x();
      float qY = rotation.y();
      float qZ = rotation.z();
      float qW = rotation.w();
      heading = euler.heading();
      pitch = euler.pitch();
      roll = euler.roll();
    }

     

    BSTRobin
    Community Moderator
    Community Moderator

    Hello hkayan,

    The unit of pitch, roll and heading is in degree.

    Thanks Robin. How about the accelerometer, gyroscope and magnetometer on below example? I never seen accelerometer generating data value as 3000.

    #include "Arduino.h"
    #include "Arduino_BHY2.h"
    #include "Nicla_System.h"
    
    SensorXYZ accelerometer(SENSOR_ID_ACC);
    SensorXYZ gyro(SENSOR_ID_GYRO);
    SensorXYZ mag(SENSOR_ID_MAG);
    short accX = accelerometer.x();
    short accY = accelerometer.y();
    short accZ = accelerometer.z();
    short gyroX = gyro.x();
    short gyroY = gyro.y();
    short gyroZ = gyro.z();
    short magX = mag.x();
    short magY = mag.y();
    short magZ = mag.z();

     

    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