Team 4203 is having issues with the KOP gyro. We have it connected to the RoboRio and are using JAVA. When we observe the behavior of the gyro on our dashboard, there is not a stable reading. We went through our regional last year by having one of the drivers continuously reset the gyro but would rather not have to do that. Any ideas welcome. By the way, we have three of these gyros and have swapped them all in with exact same results. Could it be code? Could it be there is a specific port we need to plug it into…
Could you elaborate a bit? When you say you’re not getting a stable reading, do you mean that your reading is jumping all over the place (lots of noise in the signal) or that it’s changing constantly in one direction even though the robot is standing still (drifting)?
It probably isn’t the gyro itself that’s the issue. Either that or three gyros were all bad in the same way.
Something that would probably help troubleshooting is the hardware setup: where the gyro was mounted and plugged in. As well as the requested info on what kind of “bad reading” you were getting.
This sounds like an improperly initialized gyro. Assuming you’re using the WPILib Gyro class here. Call the Gyro constructor or initGyro method when you’re sure the robot is not moving to make sure it is properly initialized.
The gyro senses turning rate, so the code needs to know not only a zero heading reference (established when the constructor is called and when the reset method is called), it also needs to know a reference signal for “not moving.” It does this by averaging the gyro for a few samples, calling that rate zero, and subtracting it from all future signals for a turning rate to feed to the integrator. This average happens when the constructor is called, and when you call the initGyro method. Make sure to do this when the robot is not moving (either don’t move it while the code is booting, or call initGyro later, by a button press or something, while the robot is not moving).
http://team2168.org/javadoc/edu/wpi/first/wpilibj/Gyro.html#initGyro--
In addition to ensuring you are not accessing the gyro heading data while calibration is in progress, note that Analog sensors like the KOP gyro are more sensitive to noise than sensors that have onboard analog-to-digital converters. So if you are using long signal wires that run near powerful motors, there may be some interference that disturbs the signal.
Another option is to use a digital sensor, like the NavX-MXP. This sensor also has accelerometers and magnetometers, and exhibits lower drift than the KOP gyro, and is used by many FRC teams to implement Field-centric drive and other features. As a bonus, it has expansion io, and plugs directly into the RoboRIO making it very easy to mount.
Thank all of you who have responded. Last night our group met and read through the literature. We believe we discovered one thing. We had the gyro plugged into a digital port on the RoboRio. We bench tested the gyro using 5V power supply and slowly rotated it in both directions. We got good readings, moving away from zero in each direction indicating that we probably have a functioning gyro.
However, when mounted back on the robot using an analog port, and viewing the dashboard, our driver reported that we still had drifting as he drove the robot. We now believe we either have a programming mistake or a bad Roborio. Fortunately we have a back up Rio so that test can be made either this evening or tomorrow.
We have someone working on a software fix, but if anyone has an idea or a quick copy paste from the WPI Library that might work, feel free to post or email to any/all of the following. Again we are programming in JAVA: [email protected] [email protected]
How much drifting were you seeing? Drift is a standard part of using a gyro alone, we usually a couple of degrees per minute before compensating with a compass and accelerometer.
The drift was enough so he had to manually reset the gyro while driving, continuously.
Sorry but “continuously” isn’t a very precise word here. To me it means “pressing reset once a second” but I assume you mean something different. Was it once a minute? If it really was once a second what would happen if he didn’t reset it? Would it gradually increase in one direction? Or was it jumping around? You can try other things in the mean time, but figuring out exactly what is happening is probably the next step in coming up with a fix for it.