Thread: Autonomous
View Single Post
  #4   Spotlight this post!  
Unread 18-02-2014, 22:49
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: Autonomous

Another option would be to use the system clock:

We used similar code on an alliance partner's robot at week 0 and it worked flawlessly.

Code:
public void autonomous() {
     long startTime = System.currentTimeMills();
     while(isAutonomous()){  //Place everything in a loop.
        long timePassed = System.currentTimeMills() - startTime;
        if(timePassed < 5000){
                //in the first 5 seconds of auto
                robotDrive.drive(0.1,0.0);
        }else {
                robotDrive.drive(0,0.0);
        }
        Timer.delay(.05);
     }
This code should not cause any drive not updated enough issues because the delay is only .05 second, and you should still be able to have the safety enabled.

Also you'll noticed I chanced the speed to .01, you only need to cross the line, so I would slowly increment the speed until it matches your needs. Driving at half speed for 5 seconds could have some unintended consequences.
__________________
"Never let your schooling interfere with your education" -Mark Twain

Last edited by mwtidd : 18-02-2014 at 22:54.
Reply With Quote