Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Combining sensor's 3 xyz axis g values into resultant vector

    Combining sensor's 3 xyz axis g values into resultant vector

    New Poster

    After reading out three individual g values from x, y and z axis of sensor, what is the maths formula to calculate the 'resultant' vector (direction and magnitude)?   How is the maths notation of 'direction' vector?   For aeroplane, traditionally it will be three values, pitch, yaw and roll?  Is there a 'single value' for the vector's direction (or may be something called euler angle)?

    How to calculate the difference between 'TWO VECTORS'?  For example, if the sesnor is placed flat on table, x and y axis is zero.  Z is 9.81 ms-2 (g value).   Call this VECTOR_0 as base reference.   If I rotate the sesnor and the x,y,z resultant is VECTOR_1.   How to calculate the difference between VECTOR_0 (base reference) and VECTOR_1 (new value)?

    Any standard c language library to do the maths?

    Many thanks

    1 REPLY 1

    Community Moderator
    Community Moderator


    Thanks for your inquiry.

    3-axis accelerometer is able to measure the tilt angle pitch and roll with respect to earth gravity. The magnitude of 3-axis accelerometer is sqrt(x^2+y^2+z^2). Because accelerometer is not able to measure yaw angle, the direction of the magnitude vector can be pointing to anywhere in 360 degrees like a cone.

    If you want to have yaw angle, then you need to use IMU which is accel + gyro. This will give you 6DoF sensor fusion for absolute pitch/roll angles and relative yaw angle. Relative yaw angle means future rotations are with respect to the initial direction of the magnitude vector. You will not be able to go back to the initial direction after operation because of gyro drift.

    If you want to have absolute yaw, then you need to use IMU + magnetometer to form 9DoF sensor fusion. You can do online search for 9DoF sensor fusion C language libraries. BHI360 + BMM350 can give you absolute heading/pitch/roll Euler angles and the 9DoF sensor fusion algorithm is running inside BHI360. Please see the attached document for evaluation.