View Single Post
  #3   Spotlight this post!  
Unread 11-12-2015, 15:31
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 243
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Re: Command based code secan

Quote:
Originally Posted by notmattlythgoe View Post
If you are using the command based structure then using long running loops and wait commands can be very detrimental. What you want to do is us the execute methods of your commands to the time. You can treat the execute method like it is the body of a loop.
I understand enough that long loops would be bad in this environment. Do I use waits and loops in the execute method? Then use the isFinished() command or a condition of the loop to end the code. What happens the loop was running still when the execute method is called again and again. Or do I record the time since last execute to calculate my time sensitive code? most of the documentation I read is is the execute and isFinished is called "ABOUT" 50 times / sec or every 20ms.

This is not what I'm aiming for but simply put every 1 sec i want to add 10 to double myCounter

Code:
double myCounter = 0;

while(true){

   myCounter = myCounter + 10;
   wait(1000); //Wait 1 sec

}
Reply With Quote