View Single Post
  #6   Spotlight this post!  
Unread 11-12-2015, 15:42
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Command based code secan

Quote:
Originally Posted by cpapplefamily View Post
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?
This will actually cause your entire robot to lock up for 1 second. A general rule of thumb when using the Command Based structure is to never use a wait().

Instead use a Date field to store the time and increment your count when the time has exceeded a second.
Reply With Quote