View Single Post
  #5   Spotlight this post!  
Unread 11-12-2015, 15:37
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

pseudo code

Code:
public class myCounterCommand extends CommandBase {

double myCounter;

   protected void initialize() {
      myCounter = 0;
   }
....
....
....

   protected void execute() {
      myCounter = myCounter + 10;
      
      wait(1000);
    }
or do I

Code:
...
...
   protected void execute() {
      while(true){
         myCounter = myCounter + 10;
      
         wait(1000);
      }
    }
here since the first called execute is not done will sequential calls be skipped?

here what happens the 49 times this execute is called when the wait is not done?


or do I

Code:
double lastScan,thisScan:
...
...
   protected void execute() {
     
      thisScan = *some clock value;

      if(thisScan < lastScan + 1000){

         myCounter = myCounter + 10;
         lastScan = thisScan;

      }

    }
Seems then we can only safely calculate with time values Greater than 20ms and could be of by +19ms

Last edited by cpapplefamily : 11-12-2015 at 15:47. Reason: added comments
Reply With Quote