Noise when using tilt compensation

Forums Technical Support for BerryIMU Noise when using tilt compensation

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5867
    Sten-Helge
    Participant

    After using the berry imu for some time, I discovered that the sensor is producing some noise when tilt compensation is activated. See below printout from the berryIMU.py in the python-BerryIMU-gryo-accel-compass directory;
    ....
    Loop Time | 0.04| HEADING 35.99 tiltCompensatedHeading 35.87 kalmanX 0.17 kalmanY -0.54
    Loop Time | 0.04| HEADING 36.07 tiltCompensatedHeading 8.75 kalmanX -3.56 kalmanY 0.00
    Loop Time | 0.04| HEADING 35.51 tiltCompensatedHeading 25.42 kalmanX -2.36 kalmanY -3.57
    ....
    Loop Time | 0.04| HEADING 34.94 tiltCompensatedHeading 35.63 kalmanX 0.21 kalmanY -0.14
    Loop Time | 0.04| HEADING 35.12 tiltCompensatedHeading 7.86 kalmanX -3.45 kalmanY -0.17
    Loop Time | 0.04| HEADING 35.23 tiltCompensatedHeading 7.59 kalmanX -5.97 kalmanY -0.10
    Loop Time | 0.04| HEADING 35.29 tiltCompensatedHeading 35.57 kalmanX -3.97 kalmanY -0.07
    ....
    Loop Time | 0.04| HEADING 5.18 tiltCompensatedHeading 6.04 kalmanX 0.38 kalmanY -0.42
    Loop Time | 0.04| HEADING 5.61 tiltCompensatedHeading 339.89 kalmanX -3.44 kalmanY -0.63
    Loop Time | 0.04| HEADING 5.39 tiltCompensatedHeading 339.59 kalmanX -5.95 kalmanY -0.59
    Loop Time | 0.04| HEADING 5.41 tiltCompensatedHeading 6.47 kalmanX -3.87 kalmanY -0.58
    ....
    Loop Time | 0.04| HEADING 194.33 tiltCompensatedHeading 195.10 kalmanX -0.06 kalmanY -0.92
    Loop Time | 0.04| HEADING 194.14 tiltCompensatedHeading 176.35 kalmanX 3.52 kalmanY -1.15
    Loop Time | 0.04| HEADING 194.09 tiltCompensatedHeading 194.22 kalmanX 2.40 kalmanY -1.00
    ....

    The same thing happens in my own c/c++ code. At first I thought that there might be some bad soldering or loose connectors on the sensor or on the RPI card, but that is sorted out.
    Is this something I have to live with, or is it a logical explanation.

    Thanks

    #5868
    Mark Williams
    Keymaster

    The C code is much better to use than the python code as it is more time accurate for the gyro tracking.

    Do you get the same issue if you are using the C code?

    Mark --OzzMaker.com --

    #5869
    Sten-Helge
    Participant

    It was actually in my own C/C++ code I discovered this issue at first. I will investigate i bit more with different sensors before I conclude.

    A workaround has been to implement a circular buffer to the final output like so;

    ....
    float avgHeading[30];
    ....
    avgHeading) )] = tiltCompensatedHeading;
    i++;
    for (ii=0; ii < (int)( sizeof(avgHeading) / sizeof(avgHeading[0])); ii++){

    float radX = avgHeading[ii] * (M_PI/180); //Convert to radians
    float radY = avgHeading[ii] * (M_PI/180); //Convert to radians
    radX = cos(radX);
    x += radX;
    radY = sin(radY);
    y += radY;
    }
    float smoothData = (180/M_PI) * atan2(y,x);
    x = 0.0; y = 0.0;
    if(smoothData < 0)
    smoothData += 360;

    printf("Comp Head %7.3f \t Filt Head %7.1f\n", heading, smoothData);

    ....

    I guess there are more elegant ways to filter the output. Your advice would be highly appreciated.

    Thanks

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

Blip, blop, bloop...