Yaw measurement with gyro and magnetometer

Home Forums Forums General discussion Yaw measurement with gyro and magnetometer

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18271
    kar_ee
    Participant

    Hi there,

    I couldn’t find any information for yaw measurement by BerryIMU in Ozzmaker webpage. Is there any tutorial with yaw measurement?

    Thanks,

    Kar

    #18272
    richardp
    Participant

    Hi Kar

    You need to use the compass (magnetometer) to measure yaw.  follow the tutorials on this site,  make sure you calibrate the compass and use the code which includes tilt compensation

     

     

     

    Richard --OzzMaker.com --

    #18278
    kar_ee
    Participant

    Hi Richard,

    Thank you so  much for your reply.

    I have questions about the magnetometer calibration in hard and soft iron interference. In the code of compass_tutorial04.c for the heading formula uses

    //Compute heading
    float heading = 180 * atan2(magRaw[1],magRaw[0])/M_PI;

    but after calibration and add my blue text output (magX,Y,Zmax and magX,Y,Zmin) to compass_tutorial03.c, the heading formula in the tutorial03 code uses

    //Compute heading
    float heading = 180 * atan2(scaledMag[1],scaledMag[0])/M_PI;

    //Apply hard iron calibration
    magRaw[0] -= (magXmin + magXmax) /2 ;
    magRaw[1] -= (magYmin + magYmax) /2 ;
    magRaw[2] -= (magZmin + magZmax) /2 ;

    //Apply soft iron calibration
    scaledMag[0] = (float)(magRaw[0] – magXmin) / (magXmax – magXmin) * 2 – 1;
    scaledMag[1] = (float)(magRaw[1] – magYmin) / (magYmax – magYmin) * 2 – 1;
    scaledMag[2] = (float)(magRaw[2] – magZmin) / (magZmax – magZmin) * 2 – 1;

    My question is that if the calibration is to eliminate both hard and soft iron distortion, why the heading formula in tutorial03 and 04 are different and which one I should be using? I’m still a rookie to understand all these things and it will be great if anyone could help me to clarify my confusion.

    Thank you.

    #18279
    richardp
    Participant

    What you could do is just apply hard iron offset , this should be good enough.

    You would only need to use the code below;

    //Apply hard iron calibration
    magRaw[0] -= (magXmin + magXmax) /2 ;
    magRaw[1] -= (magYmin + magYmax) /2 ;
    magRaw[2] -= (magZmin + magZmax) /2 ;
    //Compute heading
    float heading = 180 * atan2(magRaw[1],magRaw[0])/M_PI;

    Richard --OzzMaker.com --

    #18281
    kar_ee
    Participant

    I see. Thank you for your confirmation.

    Is the yaw measurement equivalent to the heading measurement from the magnetometer provided in the code?

    If using it on a stationary device, is the heading measurement still usable or I do need to come up with the yaw measurement by using gyro and magnetometer?

    #18283
    richardp
    Participant

    You should be able to use the heading Measurment only. When rotating along yaw, you can just work out the difference in heading values from start to finish to see how far you have rotated.

    Richard --OzzMaker.com --

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop…