View Single Post
  #6   Spotlight this post!  
Unread 25-03-2012, 12:04
Jay Meldrum's Avatar
Jay Meldrum Jay Meldrum is offline
Registered User
FRC #0067 (H.O.T.)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2003
Location: Michigan
Posts: 42
Jay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud of
Re: Wait/Pause function?

Something like this maybe useful for pausing. This example is directed towards auton, but can be applied in any instance of pausing

Code:
m_autoPeriodicLoops++;
//Make sure in your init you set m_autonomousCase = 1;
switch(m_autonomousCase)
{
case 1:
{
    //Reset auto counter
    m_autoPeriodicLoops = 0;
    m_autonomousCase = 2;
}
case 2:
{
     if(m_autoPeriodicLoops < 50)
     {
         //Wait for 50 loops 50 * ~20ms = ~1 second
         robotDrive->TankDrive(0.0 , 0.0);
     }
     else
     {
         //Robot will drive after the 50 loops have completed
         robotDrive->TankDrive(0.5 , 0.5);
      }
}
This will pause the robot for about one second (this can vary depending on how much other code is running, and what you have your Periodic loop set to refresh at). Default is about 20 ms.

By using this method you can have other things in the background running in your loops but you are not "stopping" the cRio completely by using a Wait function.
__________________
2012-2015 - FRC 67 - Programming/Controls Lead Mentor
2003-2005 - FRC 857 - Driver

Check us out at http://www.hotteam67.org
Previous year design docs, programming tutorials, and more!
Reply With Quote