Gyroscope Programming

Howdy fellow robotic enthusiasts. I am in dire need of assistance programming our teams gyroscope. I am working with the iterative robot template and I am trying to instantiate my gyroscope. However, I always get the error, “Cannot instantiate the type Gyro.” I have read that it has to do with instantiating interfaces. But I am bad at programming so I am unsure about this. Please help. :eek:

Here is a glimpse of what I am trying to accomplish.

Gyro gyro = new Gyro(1);

:confused:

I think I have solved the error last year it was, Gyro gyro = new Gyro(1); to instantiate. This year it seems to be, AnalogGyro gyro = new AnalogGyro(1); If someone could confirm this that would be awesome.

Yes. See http://wpilib.screenstepslive.com/s/4485/m/13809/l/480120-c-java-changes-and-porting-guide-2015-to-2016

Probably better to do Gyro gyro = new AnalogGyro(1);. You’ll want to read up on interfaces and abstract classes.

Why is it better?

he doesnt mean its better, the Gyro class is simply a “template” to use so all 3000 teams that use gyros dont have to make their own classes…the class you are looking for is the analogGyro

Does anyone know where I find an example of a PID controller that turns the robot 90 degrees using the gyro. I was looking at the examples that came with the robot java development plugin and I learned a bit from the potentiometer PID example but I couldn’t figure out how to apply it to the gyro.

To just turn 90 Deg, you just need to supply it to the PIDController where the encoder would normally go, as it is already a defined PID source. you would then use your drive motors as output. you would need to invert one motor, so that it turns, but that should be the extent if the mods. I’m not sure you need PID for this simple task though. It’s likely easier to just stop after turning 90