I’m trying to make my first PID for VEX and while researching I found out about gyros. It seems pretty difficult and not particularly useful for auto (at least this year). What do you guys think? It it useful? Is it difficult? Does its usefulness make it worth the time and effort spent?

The yaw rate gyro that vex provides is very useful and easy to use. The robot brain handles all the calculations for you and the gyro sensor will output the angle the robot has turned. It is very accurate and useful for autons.

From my own post a few hours ago:

Hi there!

Gyros track rotation in degrees. If you plug in a gyro and rotate it a full revolution, it will return a value of 360.

The gyro code can look as simple as

if(SensorValue(gyro) < 200){
motor(leftDrive) = 127;
motor(rightDrive) = -127;

Or if you want to get a little fancier, you can use P or PID control. This can be tricky to learn, but here’s a simplified version of the P loop I used on my worlds bot last year. If you want to learn PID control for the first time, check out this youtube video and it’s sequels.

Here’s my P loop.

float kp = 0.1;	
error = target- SensorValue(gyro); //error is distance from target to actual
if(error != 0){
	turnSpeed = error * kp; //set turn speed to error times a constant

and then later in the code,

motor(rightFrontDrive) = motor(rightBackDrive) = forwardSpeed - turnSpeed; //move
motor(leftFrontDrive) = motor(leftBackDrive) = forwardSpeed + turnSpeed;

Basically, at some point in autonomous, I set the target to (for instance) 100. Then, the P loop calculated the error between the real value, 0, and the target, 100 and set the motors accordingly to a speed of 10. The kp is an arbitrary constant that you need to tune. This P loop was very simple and produced a consistent autonomous routine (at least when we were testing on our own fields without antistatic, ;( )

However, 2 things to note about the gyro:

Gyros are fairly finicky. If you run too long a wire between the gyro and the cortex or if you have too much metal near either, it may return random values and be inaccurate. Further, gyros are not compatible with v5 even though most other legacy sensors are. If you’re using v5, you will need to track your location some other way.

Hope this helps, good luck!

Unless I’m missing something, I really don’t think this is true, and current gyroscopes should work just fine with V5.

RMS has a V5 library for the gyro.

Also, the gyro’s electrical connection to the Cortex/Brain is no different from any other analog sensor, so the Cortex/Brain wouldn’t be able to distinguish between a gyro and anything else anyway.

VCS also has a gyro value as well as read analog. The old gyro should work just fine (or at least as fine as it did before!)