Problems with the Gyro, non-stop (but yet not a constant) change in the angle.

Hey.

A few days ago we set the new gyro we got in the KOP on our robot and tried it out, wanting to know the angle of our robot in real time.
It worked great, but yesterday we’ve noticed a very weird problem: we reset the Gyro and disabled the driving motors so the robot did not move an inch. we looked at the values of the gyro and it still showed a change in the angle. (No more than 0.05 per 5 seconds, negative\positive)
This change seemed to affect our algorithm.
We thought maybe the gyro was damaged, so we tried another Gyro only to come up with the same results.

Anyone came up with this problem? how did you fix it?

Thank you.

This is called bias, and is usually present in any sensor like the gyro.

There’s a couple fixes, depending on how much work you want to do

  1. Ignore it (it’ll still be accurate enough over short periods)
  2. Try to calculate the bias when the robot is known to be sitting still (I believe the gyro code already does this, but you can add a longer bias calculation for a bit more accuracy)

I think you should be able to buy a gyro chip with better specifications that will drift less if it really is a deal-killer.

If both gyros have bias of the same direction and same magnitude (and have similar specifications), I always wondered if mounting them both on top of each other would allow the error to cancel out.

There are usually two things: bias and noise.
Bias is the steady state voltage the gyro returns when it sits perfectly still (the DC offset). If you put the gyro signal on an oscilloscope and zoom in on the time scale, you will see high frequency variations. That’s noise. In the perfect world, noise will cancel out over the long run (equal amount of positive and negative noise levels). But in reality, it may still have a small residue amount over a period of time. The gyro is a sensor measuring angular velocity (turn rate: degrees/sec). This means that in order to get the heading, you need to integrate the turn rate over time. So if the turn rate is not quite zero, the time integrator will eventually integrate to some value (i.e. indicating the robot slowly turning). To minimize these effects, when initializing the gyro, you will need to calibrate it. This involves taking a large number of samples and take an average on them. This will give you the bias. So when you read the gyro value, the bias is subtracted from the reading. So this will eliminate the bias but not the noise. To take care of the noise, during the calibration period, you will also need to determine the amplitude of the noise (the max and min level of the signal while the robot is sitting still). I usually double that range to form a deadband. So when you read the gyro, not only you need to subtract the bias from the reading, you also determine if the resulting reading is within the deadband. If so, you consider it zero. This will cause you to lose accuracy when moving very very slowly. But in reality, this is not an issue. So when integrating the adjusted reading, it is much less likely to have the robot slowly turning while it is actually sitting still. Unfortunately, the world is not perfect, gyro output can be affected by temperature. In other words, as temperature changes, the bias may shift. This means that the bias you have determined sometime ago during intialization may not be correct any more.
So there are good news and bad news. The bad news is, the world is not perfect, you can only minimize the drifting problem but never eliminiate it. The good news is, the match is short. It lasts only 2+ minutes. With all the adjustments done to correct the problem, it should be neglible within the match period. Another good news is, the WPI library is taking care of the calibration and eliminating the bias for you. So the above explanation is really for your information. You don’t need to do anything. Having said that, if you carefully examine the WPI library code, you will see it is using the accumulator to do the averaging to determine the m_offset (bias) but I don’t see it taking care of the noise deadband. Like Bongle said, it is probably good enough for most scenarios. If you reset the gyro before each operation that you need it, the drift should be insignificant. The only scenario that may be affected by this is if you want to maintain an absolute heading during the entire match. If this is really important to you, you may want to use an absolute heading sensor instead (e.g. compass).

I’m curious what you’re doing that you need better then 1.5 degree position accuracy over a 2 minute match.

The drift actually seems fairly good compared to most gyros I’ve used.

1.5 degrees and I wouldn’t sweat it. 1.5 radians, and you’ve got a big problem. :yikes: