Hello,
I am in process of building an autonomous wheeled robot and planning to use an MPU6050 Gyro as source of current heading. So I have built a UNO test rig and it is successful chatting to the 6050 this rig is returning absolute heading Gyro Z from calibration and rate of change deg/sec Z values .
I have tried two 6050 libraries:
Problem i am having is that both libraries suffer from Gyro Z axis drift, inasmuch as the Gyro Z axis heading value slowly changes/drifts from its calibration heading with the 6050 completely stationary.
Is this normal or any ideas how to fix this issue please, i see others have had similar issues when using gyro's for balancing robots.
Yes this is completely normal, MEMS sensors are not very precise(*). For heading control you require a compass or GPS. The 3D gyro is for short-term 3D rotational awareness, not heading control. You would typically use some sort of sensor-fusion method to combine attitude information from a gyro and compass in an IMU.
(*) Mechanical gyro precision goes up dramatically with the size of the device, something a few mm across cannot be performant due to the tiny MoI and torque forces involved at small size.
Hello MarkT & jremington and many thanks for the input.
I figured MEMS gyro not going to be wonderful but was expecting something better re Z axis drift.
For example I initialized my sketch and calibrated gyro this lunchtime and fixed the rig to my desk, hence it has not moved and Z axis drift is currently at 88 deg so that is about 18 deg per hour drift.
So I figure given this drift I am going to use Z axis deg/sec Rate of Turn when the robot makes a turn and use it as a short term navigational solution using Dead Reckoning, backed up by the onboard GPS.
Unless someone has better solution gyro directional stability .
Thanks again imk
18 deg per hour drift is remarkably small for a MEMS gyro.
The only way to fix that is with an external zero reference. Most people use a magnetometer as a compass, which of course can be confused by motors and other environmental magnetic fields or nearby iron-containing objects.
Since that depends on the circumstances, give it a try. If you do, be sure to calibrate the magnetometer. They don't work satisfactorily out of the box.
jremington,
Well sketch has been running for 5hr'ish and I have been been away from desk in garage doing bit of woodwork so maybe it has in fact done a 360 + 88...
I'll have a look at the other 6050 libraries and test the other 6050 i have to see how they compare.
thanks again imk
The drift will be much larger if the sensor is being moved and shaken, assume 10--30 seconds is about the maximum time to rely on the data with any accuracy in the absense of other inputs. As I said a 3D MEMS gyro is useful for tracking short-term 3D orientation only, and its invaluable for that.
A typical IMU uses 9 or 10DoF (degrees-of-freedom), ie a 3D accelerometer, 3D gyro, 3D compass and sometimes a barometer too. Not sure why its called DoF, because they aren't all independent - I guess its from robot arm kinematics. Anyway the accelerometer and compass combined can give long-term 3D orientation, and the gyro can handle the short-term orientation during rapid manoeuvring when the accelerometer output is unusable for measuring the gravity-vector.
Such a 9/10DoF IMU enough to track orientation (and height), but you still need something like GPS to hold position laterally (MEMS accelerometers have drift too).
And compasses can have issues, they need careful calibration and to be kept away from ferrous metal parts of the robot.
Which is why you want it far from metal, so that you don't have to calibrate it again. Basically you can use an actual compass to check the mounting location is basically free from magnetic disturbance.
There are special regulations for air-freight of powerful magnets specifically so they don't have to re-calibrate the aircraft's compass after loading. Yes aircraft have compasses for navigation - they don't rely just on GPS
I spent 11 years working as a shipboard navigation tech working on shipboard navigation equipment from dead reckoning to military grade inertial's. Good luck.
Hello and many thanks to for the inputs.
Interesting to know other are flyers and sailors as i also worked in aviation for most of my career and used to sail regularly so familiar with swing yachts to establish compass deviation and correction. But i am still surprised at how much the MEMS gyros drift so much, that said i am not 100% sure it is all gyro drift as the libraries may have over simplified the math.
So i have been doing a little experimenting with respect to resetting the math post calibration and varying how often the 6050 is polled for rate of change. Also using a rolling average on the rate of change, this along with the polling rate seem to improve bearing drift. What is not clear at this time is why the bearing drift returns to zero after some hours of the 6050 being completely stationary. Math, temperature or is it the Ghost of Christmas past. I have more testing todo but somewhere between the motor turn HALL sensors, the gyro/accelerometer, GPS and nine ToF VL53L0XV2 sensors I am sure ERIN wont go to far of course.
More input most graciously received and a happy festive season to all imk