View Single Post
  #8   Spotlight this post!  
Unread 04-02-2012, 11:01
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Integrating Gyro Code

Quote:
Originally Posted by Ether View Post
The code I showed you should be in TeleOp so that it runs every time TeleOp runs (which is about once every .02 seconds).

That depends what template is being used. In the Simple Template you add your own loop and it will not necessarily run every 20 ms, the TeleopPeriodic method of the Iterative template will run ~ every 20ms provided your code in that method returns in less than 20ms.

It also depends on what you are using the gyro for and if it has to keep track of it's orientation starting at the very beginning of the match. To do that you could make an object called something like CustomGyro that extends AnalogChannel and add the appropriate variables and code Ether listed. Instantiate a copy of your object in RobotInit, then call your CustomGyro.Integrate method from AutonomousPeriodic, TeleopPeriodic and DisabledPeriodic (if the robot might be turning at the beginning of auto and continue rotating a bit in disabled, otherwise leave this one out to avoid drift)

If you really need precision you probably need to calculate the delta time each time you go to integrate instead of trusting it to be ~20ms.
Reply With Quote