ADXRS450 Gyro not reading the correct angle

I have recently mounted an ADXRS450 Gyro sensor (the one provided in the kit of parts) to the RoboRIO SPI port and got it working. I’m trying to use it in order to tell the robot to turn x degrees during autonomous. I tried testing it by telling it to turn 360 degrees, however it goes over, roughly to 375 degrees. Is there a way to recalibrate the gyro in order to make it accurate?

Thanks,
Alex

How are you running your PID loop, if any? Are you simply driving fast and telling the robot to go to motor output zero once 360 degrees is reached? If so, you are likely overshooting the desired setpoint and not correcting afterwards.

A better way to write this is to have the drivebase motors output proportionally to the setpoint - so, as you get closer to 360 degrees (or whatever setpoint you are looking for,) the robot slows down, and if you overshoot the setpoint, the robot will correct.

If you are scaling your PID loop properly and your robot gyro reads 360 degrees when it stops:

Are you near any strong magnetic interference? If not, you may be able to call YOUR_GYRO_OBJECT.calibrate() in Java or something similar in C++. I’m unfamiliar with the LabView API for this gyro so I wouldn’t be able to help there.

I’m using Java. I haven’t been using a PID loop - I never knew it was necessary. I’ve just been trying an auton that first calibrates the robot, then launches a while loop that tells the motors to turn until the gyro angle is greater than or equal to 360. It seems that the scale is just off. It is consistently resetting to zero before that while loop begins, so that’s not the problem. Currently, when I do a full 360 degree turn, the gyro measures around 341 degrees (this is consistent).

As far as electromagnetic interference is concerned, the roborio is fairly close to a few cim motors, but that doesn’t seem to be affecting the calibration.

How far is the gyro from the center of rotation of the robot?

Is the gyro parallel to the ground?

Quick side question: How much does it matter if the gyro is far from the center of rotation of the robot? I have had success with gyros anywhere from the middle to the outsides of robots, and it doesn’t seem intuitive to me why the location of the gyro is important. If the robot turns 30 degrees, the gyro will also turn 30 degrees, no matter where it is on the robot. However, I know next to nothing about the internal workings of the gyro.

A couple years ago I had a discussion a mentor who insisted that the gyro belongs in the center of rotation of the robot. He did not provide any explanation other than “It just makes sense! The gyro measures rotation so we gotta put it at the center of rotation!”. Can someone explain in further detail?