Best practice to use gyro auto turn?

I am now using gyro sensor to measure the degrees my robot turns. I changed the SensorScale[gyro] to 137 and when I push the robot slowly rotate 180 degrees counter-clockwise, it’s no more than 1.5 degrees error, which is satisfying I think. But when I turn the robot back (e.g another 180 degrees but clockwise), the gyro will give about 5 degrees reading(which is 50 from SensorValue[gyro] in the robotC debugger window). Is this normal?

And when I restart the program(e.g. re-initialize the gyro sensor), and then rotate the robot 180 degrees clockwise, the reading is about -187, which is almost double the error when I turn the robot counter-clockwise. How could this happen?

As for the ‘drifting’ issue of gyro sensor in other threads, I have not noticed much drifting when the robot is completely still, so I think this should not be the cause of the problems above.

So if I want to use the gyro to auto-turn the robot for certain degrees, how can I eliminate the errors above to get a more precise value? Should I just turn the robot in only one direction throughout the auto phase? And should I zero the sensor value every time when I call the turn() function? Any tips?

making sure the sensor is away from vibration will help, what many teams do is put it on a standoff with plastic spacers
also placing the gyro at your center of gravity might help

it would help even more to smooth out your path, ie start slow, then go fast, then end slow so momentum doesnt add to your error

Thanks for your suggestions, I am indeed using rubber spacers to isolate the gyro to decrease vibration, and it works quite well.

My root question is the mentioned asymmetry values when rotating in opposite directions, which is weird and hard to eliminate; and whether should I zero out the sensor value each time before the call to turn() function? Do you have experience in these before?

Why did you feel the need to change the scale factor to 137? (default is 130 IIRC)

I modified your gyroLib2 code to display gyro values in LCD screen, and I find out that when I set the scale factor to 137, my five gyro sensors work quite well when rotating the robot counter-clockwise, which will give almost 1800 (no more than 20 error) for 180 degrees; but when I slowly turn the robot in the opposite direction, e.g clockwise, the error would be 30 to 40, which means about -1770 for -180 degrees. Have you ever experienced this before?

I did do a test last night, the gyro just isn’t very accurate, there is a tradeoff between removing drift and being able to detect slow movement. I also tried the simulation I had posted in the gyro lib project and it was working slightly better. Perhaps try turning off the drift control code I had added (or just look at the raw sensor values).

It sounds like you have a sensor with an asymmetric scale factor. I think that might be caused by mismatched push pull components on the board, but I’m not really an EE so I could be flat wrong.
If that is the case, you could take the raw vakue (after removing the bias) and scale it with different constants depending on if it’s positive or negative. You have already figured out your scale in one direction (137). With a little pen and paper or trial and error you could get the other.

Why do you have 5 gyros on your robot?

i think he meant he tested 5 gyros, hes not actually using them all for competition xD

try putting the gyro in a freezer and see if you get different results

Well in fact the anti-drifting code is not causing the problem, as I can see the abs(drift_error) never goes larger than 3…

As @capow08 pointed out asymmetric scale factor could be the issue, I will try apply two different factors to the raw value based on its sign.

And @Harrison, I am just testing 5 gyros I have to see if there are any difference… having 5 gyros in one robot does not seem to solve my problem :o

I feel like the gyro processing program of QCC2, VEXU world champion, would be helpful to look at here. Their gyro was more accurate than big red encoders, you all saw it. :slight_smile:

https://vexforum.com/showthread.php?p=379557