View Single Post
  #6   Spotlight this post!  
Unread 25-02-2016, 16:58
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Autonomous Timer Issue

I did not see the source for your DriveForward command. I'm guessing it should look something like the following:

Code:
public class DriveForward extends Command {
	
	private double timeToRun;

	public DriveForward(double timeout) {
		requires(Robot.drivetrain);
		timeToRun = timeout;
	}

	@Override
	protected void initialize() {
	}

	@Override
	protected void execute() {
		// Change to method to apply power to your drivetrain
		drivetrain.setPower(0.4, 0.4);
	}

	@Override
	protected boolean isFinished() {
		return (timeSinceInitialized() >= timeout);
	}

	@Override
	protected void end() {
		// Don't forget to stop
		drivetrain.setPower(0, 0);
	}

	@Override
	protected void interrupted() {
		end();
	}
}
Is it possible that your isFinished() implementation was not checking that enough time had elapsed? If your isFinished() never returns true and you don't set a time out to interrupt your DriveCommand, the command will never stop and your robot will just keep going forward (which sounds like the condition you were describing).

Also, don't forget to stop the motors in your end() and interrupted() methods - unless you want the robot to continue to move even after the command terminates.
Reply With Quote