ROMI gyro erratic behaviour affecting trajectory-following code with Ramsete

While experimenting with ROMI and the trajectory-following code on Github using Ramsete, I had an issue with the gyroscope calibration which cause the ROMI to do erratic behaviour after a couple of seconds, like spinning on itself or driving full speed in the wrong direction. I suspected first that I simply needed to recalibrate the gyro using the tool at http://10.0.0.2, but the gyro calibration, although coming out successful, did not solve the problem.

I then started checking the raw gyro angle values, using the robot simulator (top-left corner, under RomiGyro). When the robot was at rest, the X value was increasing steadily (drifting), at a rate of 1 degree per second. My gyro offsets from the calibration were X = -0.56, Y = -6.23 and Z = -3.938. Multiple re-calibration yielded similar offsets, all within 5% of those values.

I finally solved the problem by re-flashing the rPi SD card. The gyro offset values at first were all resetted to zero, but then, when I calibrated the gyro for the first time, I got X = 3.535, Y = -6.28 and Z = -3.883. Notice that the X offset changed drastically, by almost 4. The Y and Z offset were similar. Using these offsets, the trajectory following algorithm with Ramsete worked well, and the gyro drift in the X axis was much slower, similar to Y and Z.

I am curious if anyone had the same issue as me, and I was also wandering:

1 - Why the Romi gyro calibration yielded several times false results, and why I had to re-flash the SD card for things to go back to normal?

2 – Why a large gyro drift in the X axis makes the trajectory-following algorithm fail? One would assume that only the Z axis gyro reading and encoder values would be needed for computation.

It would be appreciated if someone who has answers to these questions could reply, and possibly fix the calibration issue in the next software release.

1 Like

This is a known issue with the gyro hardware in the Romi. Some units experience drift in the reported gyro angle. You can see this without any WPILIB code involved if you run the Rotation Resist sample Arduino program that Pololu provides. Some Romis will slowly spin when running this program due to gyro drift.

The manufacturer’s data sheet for the gyro mentions that the chip is sensitive to how it is soldered down to the circuit board, and that it can be affected by stresses on the PC board. So it is possible that you may be able to alleviate the drift by loosening and carefully re-tightening the mounting hardware holding the PC board onto the chassis.

In really bad cases of drift, it is possible to measure the drift rate and then compensate for drift as a function over time. I think the later versions of WPILIB do something like this internally, which may explain why reflashing and recalibrating the gyro made an improvement.

2 – Why a large gyro drift in the X axis makes the trajectory-following algorithm fail? One would assume that only the Z axis gyro reading and encoder values would be needed for computation.

This won’t cause it to fail. I suspect there is missing information here, and that missing information is why it would fail.

Additionally, sharing code is great.

1 Like

The code is here, unmodified. It am not the author, just a user.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.