Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Gyro Code (http://www.chiefdelphi.com/forums/showthread.php?t=102415)

2869Robotics 09-02-2012 21:19

Gyro Code
 
Could someone give me some sample code for using the gyro? I'm not sure how to program for it.

Derek012 09-02-2012 22:04

Re: Gyro Code
 
The wpilibj offers a class on their API http://www.wbrobotics.com/javadoc/ed...libj/Gyro.html
but you would need to create the Gyro object then specify which analog port on the cRio you are using,
Gyro gyr = new Gyro(aPort);
...
Then in the method your choosing for your implementation you would call the angle using, gyr.getAngle();
This method isn't exactly what it seems though because a gyro calculates its angles by rate you may need to set your sensitivity different depending on your gyroscope using gyr.setSensitivity(int volt/degree/sec);
Also for those times were you need to reset to zero there is a reset() that you can use.


All times are GMT -5. The time now is 09:56.

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