Absolute angle from MPU6050

Hi there,
I am trying to read absolute angles (0 - 360) from the MPU 6050 IMU. I am using acceleration from the IMU to calculate the angles. The issue is that the angles are correct only when my IMU is stable. If I start moving my IMU in Y or Z axis then the acceleration in that axis changes and my angles become corrupt. How to get the absolute angles from MPU 6050 so that motion does not affect my data. Below is my code snippet-

float get_pitch() {
    // Request only the bytes for AcY and AcZ
    Wire.beginTransmission(MPU_addr);
    Wire.write(0x3D);  // AcY high byte register
    Wire.endTransmission(false);
    Wire.requestFrom(MPU_addr, 4, true); // 2 bytes each for AcY and AcZ

    AcY = Wire.read() << 8   | Wire.read();
    AcZ = Wire.read() << 8 | Wire.read();
   
    // Calculate pitch using only AcY and AcZ
    float pitch_raw = atan2(-AcY, -AcZ) * RAD_TO_DEG + 180.0f; // or your chosen formula/convention
    //Filtered value (if Kalman filter is available)
    pitch = kf_x.updateEstimate(pitch_raw);
    return pitch;
}

Unfortunately it is not possible to do what you want with consumer grade IMUs. They are too noisy and inaccurate.

Professional quality, absolute orientation IMUs are available, but at prices in the general range USD 10K-100K.

Cant I use BNO055 IMU? is it effective in this regard?
Isnt there any way to filter the reading of MPU6050 when the sensor is in motion?

If a $10 sensor could do what you want, they would already be in use, everywhere.

Filters help, but cannot solve the problem with consumer grade IMUs. To determine absolute orientation, you must be able to very accurately separate the acceleration due to gravity from the accelerations due to other forices.

Read more about why in this archived article: Using Accelerometers to Estimate Position and Velocity | CH Robotics

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.