I’m getting some strange results when trying to read my gyroscope. As it sits there the gyro seems to accumulate angle: it will slowly count upwards, starting at zero and gradually drifting upwards into positive values. For the life of me I can’t figure out why, with the robot sitting dead still, the gyro reading does not stay at zero. Anyone else have this problem?
The gyro is a rate sensor. To get position, the library software integrates the rate. So if there is even the slightest null offset in the sensor, it will detect a non-zero rate even when perfectly still. When this non-zero rate is integrated, it will cause a slowly changing (angular) position.
Then I guess my next question is how do I fix it? Issuing a gyro.reset() command to return it to true constantly defeats the purpose of having a gyro to begin with.
It depends what you are trying to do, if you just need it for maneuvers that take short periods of time resetting is usually good enough. It’s also possible to take advantage of the temperature pins to increase the accuracy/reduce the drift. I’ve never actually done it, it won’t eliminate the the problem, but it should reduce the drift.
Autodrive routine. I want it to go forward while keeping true. Positive drift of the gyro will generally cause the bot to slowly curve to the right. I was also playing with the idea of a one button “auto true”, which would realign the bot to the scoring wall automatically.
I suppose I could use a floor function and round things off. Just bothers me that someone would build a gyro that doesn’t hold true. I suppose I could build my own and measure the torque created when I turn it, but that kind of project is more for between competitions.
Not terribly fast in the grand scheme of things, but all those tiny errors accumulate over time until you aren’t pointed right. Mostly I’m thinking in terms of auto-aiming the bot towards one end or another, and I can’t do that if the bot is 45 degrees off but the gyro reads 63.
I was exaggerating I’ll put a timer on it tonight and figure out the exact drift. Actually, I’ll do it a few times, see if the drift is constant. If it is it’ll be easy to correct depending on how long it’s been since the last reset.