View Single Post
  #1   Spotlight this post!  
Unread 12-02-2012, 14:51
ItzWarty ItzWarty is offline
Registered User
FRC #1072 (Harker Robotics)
Team Role: Leadership
 
Join Date: Jan 2012
Rookie Year: 2010
Location: California
Posts: 15
ItzWarty is an unknown quantity at this point
Re: Using a Gyro on any port (How to code that)?

Quote:
Originally Posted by omalleyj View Post
If you only need low performance from the third gyro you could try integrating the output yourself. Allocate a regular AnalogChannel, poll it regularly, and add the values up.
Code:
pseudocode:
thisSample = gyroAnalog.getValue
thisTimeStamp = Timer.getTimestamp
thisAmountTurned = ((thisSample + lastSample)/2) * (thisTimestamp - lastTimestamp) * (Kgyro)
currentHeading += thisAmountTurned
lastSample = thisSample
lastTimeStamp = thisTimeStamp
lather, rinse, repeat
I doubt you will get performance anywhere near the FPGA, but it is pretty quick to try.
If you're running anything else on your robot, it might be worthwhile to run this on a separate thread. I'm not sure how nice Thread.Sleep() is on the robot, though.
__________________
Leader of Team 1072. Software developer of RAF Manager.
Follow me on Twitter: Twitter.com/ItzWarty/
Reply With Quote