Hello,
I'm trying to use MPU6050 with pyBoard, I use this libs
https://github.com/micropython-IMU/micropython-mpu9x50
and
https://github.com/micropython-IMU/micropython-fusion
MPU6050 don't have magnetometro, so I use Fusion.update_nomag.
Pitch value and roll value are pretty stable, value of heading (Yaw) is constant 0.
For me is important value of heading so I copy calculation from Fusion.update and rewrite
self heading = 0
to
self.heading = self.declination + degrees(atan2(2.0 * (self.q[1] * self.q[2] + self.q[0] * self.q[3]),
self.q[0] * self.q[0] + self.q[1] * self.q[1] - self.q[2] * self.q[2] - self.q[3] * self.q[3]))
The value of heading is good but after while it start integrating some mistake. And value continuously change after 5 minutes almost up to 180°, without rotating mpu6050.
I guess that it is some static mistake from gyro, is there any way how to calibrate it?
Really thank for help
MPU6050 calibration
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: MPU6050 calibration
Heading information comes from the magnetometer. In the case of the MPU6050 driver we deliberately set heading to zero because there is no way to deduce absolute heading without a magnetometer.
Trying to infer a relative heading value by integrating the gyro output twill inevitably cause any error to accumulate. A true inertial measurement as used on spacecraft requires equipment with much higher precision than an MPU6050. Out of curiosity I experimented with this myself and concluded it was a lost cause. This did not come as a surprise.
You could try adding in ad hoc calibration values prior to integration but I don't hold out any hope for long term stability: any gyro offsets are liable to vary with changes in temperature, supply voltage or the phase of the moon
Trying to infer a relative heading value by integrating the gyro output twill inevitably cause any error to accumulate. A true inertial measurement as used on spacecraft requires equipment with much higher precision than an MPU6050. Out of curiosity I experimented with this myself and concluded it was a lost cause. This did not come as a surprise.
You could try adding in ad hoc calibration values prior to integration but I don't hold out any hope for long term stability: any gyro offsets are liable to vary with changes in temperature, supply voltage or the phase of the moon

Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.