Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Gyroscope Programming (http://www.chiefdelphi.com/forums/showthread.php?t=141468)

curtis0gj 11-01-2016 16:34

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:

curtis0gj 11-01-2016 17:15

Re: Gyroscope Programming
 
Quote:

Originally Posted by curtis0gj (Post 1521360)
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.

Joe Ross 11-01-2016 17:28

Yes. See http://wpilib.screenstepslive.com/s/...e-2015-to-2016

rzoeller 11-01-2016 17:28

Re: Gyroscope Programming
 
Quote:

Originally Posted by curtis0gj (Post 1521410)
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.

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

TimTheGreat 13-01-2016 00:17

Quote:

Originally Posted by rzoeller (Post 1521423)
Probably better to do `Gyro gyro = new AnalogGyro(1);`. You'll want to read up on interfaces and abstract classes.


Why is it better?

Fauge7 13-01-2016 00:24

Re: Gyroscope Programming
 
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

curtis0gj 13-01-2016 14:03

Re: Gyroscope Programming
 
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.

techkid86 27-01-2016 16:29

Re: Gyroscope Programming
 
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


All times are GMT -5. The time now is 10:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi