View Single Post
  #9   Spotlight this post!  
Unread 04-02-2012, 11:17
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Integrating Gyro Code

Quote:
Originally Posted by RufflesRidge View Post
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.
I'm not intimately familiar with the FRC Java Framework so I can't comment in detail about RufflesRidge's comments above, but I will add the following remarks:

Whatever rate you are doing the integration at, that's the cycle_time you should use in the integration. And, as mentioned above, if that rate is not expected to be very steady, it might help to measure the actual elapsed time each cycle and use that elapsed time in your calculation.

If you are concerned about gyro drift, you should add a button that the driver can press during the match to zero the gyro when it's at a known position.

Reply With Quote