View Single Post
  #2   Spotlight this post!  
Unread 02-02-2012, 23:29
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
Re: Autonomous Motor Problems

For the motor's safety, if it doesn't get called often, it'll automatically stop it. And Timer.delay() stops the whole thread.

I'm assuming you want to run the motor for 8 seconds, this is one way you could do:

Code:
public void autonomous() {
	Timer timer = new Timer();
	timer.start();
	while (isAutonomous() && isEnabled()) {
		if(timer.get() < 8) { // Double check this; don't exactly remember what it returns
			driveTrain.drive(0.5, 0.0);
		}
		Timer.delay(0.005);
	}
	timer.stop();
}
Reply With Quote