Consistent Skills auton


My team uses a gyro and encoders for skills. We are having trouble getting consistency for it. I have a PD (PID loop without the I) and a Gyro function I found in RobotC sample code. I was trying to make a PID loop for the Gyro but I didn’t have enough time to get it to work. I would like some tips or other sensors I should for skills.


If you can’t get the gyro working in time, you can use your encoders to measure turning, although it won’t be quite as good due to wheel slippage (although I didn’t use a gyro at all last season and never had any major issues). Here’s some sample code for rotating using encoders:

float wheel_spacing = 17.0; // set this variable to the distance between your left and right wheels (inches)
float wheel_diameter = 4.125; // set this to the diameter of your wheels (NOTE: 4 inch omnis are actually 4.125 inches)
float encoder_ratio = 1.0; // change this to the gear ratio between your encoder and your wheel, for example 36 teeth on your wheel to 12 teeth on your encoder will be (36/12) or 3
float tuning_factor = 1.0; // increase this if it doesn't rotate enough, decrease if it turns too much

// calculate ticks for rotation
int rotate(float degrees) {

    // calculate circumference of wheels and turn
    float wheel_circ = wheel_diameter * 3.141592;
    float turn_circ = wheel_spacing * 3.141592;
    // calculate encoder ticks for each side
    float dist = turn_circ * (degrees/wheel_circ) * tuning_factor * encoder_ratio;

    // return rounded value
    return round(dist);



function will return the appropriate amount of encoder ticks for a rotation of


degrees. Feed the number returned into your regular PID function, with the difference that the right value must be reversed (for example, if it returns 100 ticks, feed 100 into your left and -100 to the right). If you post your PID code, we can help integrate it a bit better.

New Zealand 2012 Championship

Thank You!


will this work if there was only one encoder