|
Re: Using a Gyro on any port (How to code that)?
Quote:
Originally Posted by omalleyj
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/
|