Go to Post Physical items will be lost along the way eventually but memories will never be forgotten. - Connor McBride [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 02-25-2016, 04:58 PM
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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:28 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi