Go to Post This is about more than building a robot, we cannot only do the fun things. If you are fully involved than you will be prepared to do anything in life. - Andy Brockway [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-02-2016, 18:37
Rocinante Rocinante is offline
Registered User
FRC #1994
 
Join Date: Jan 2016
Location: Kansas City Kansas
Posts: 4
Rocinante is an unknown quantity at this point
Autonomous Timer Issue

I am having problems with the timer for our autonomous code in iterative command based java.
We can get our first addSequential command to run in our autonomous group but it will not stop.

Here is what we did to try to call a timer for our autonomous command group:

public static double getFPGATimestamp() {
return 0;
}

Does anybody have any ideas how to call a timer to test our code?

Thank you for any information you may offer.

Last edited by Rocinante : 23-02-2016 at 18:41. Reason: Did not include "command based java".
Reply With Quote
  #2   Spotlight this post!  
Unread 23-02-2016, 23:23
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Autonomous Timer Issue

I'm sorry I'm tired but going off of this bit of text

Quote:
but it will not stop.
i think you want to put a

Code:
setTimeout(timeToPause)
in your initialize() method of the command (not command group) (though I think you can set the timeout from the command group too? just do like

Code:
AutonCommand c = new AutonCommand()
c.setTimeout(1)
addSequential(c)
if i remember correctly.
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #3   Spotlight this post!  
Unread 24-02-2016, 10:04
Rocinante Rocinante is offline
Registered User
FRC #1994
 
Join Date: Jan 2016
Location: Kansas City Kansas
Posts: 4
Rocinante is an unknown quantity at this point
Re: Autonomous Timer Issue

Cool, thank you we will give it a shot.
Reply With Quote
  #4   Spotlight this post!  
Unread 24-02-2016, 13:43
Waz Waz is offline
Strategy and programming mentor
AKA: Steve
FRC #2357 (System Meltdown)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2009
Location: Raymore, MO
Posts: 12
Waz is an unknown quantity at this point
Re: Autonomous Timer Issue

Quote:
Originally Posted by Rocinante View Post
Cool, thank you we will give it a shot.
Also working from fuzzy memory, but I think you will need to call something like isTimedOut() in your isFinished() method and return true or false appropriately. If I recall correctly, setting a timeout does not mean the command will automatically be stopped.

Hope this helps,
Steve
Reply With Quote
  #5   Spotlight this post!  
Unread 25-02-2016, 15:34
Rocinante Rocinante is offline
Registered User
FRC #1994
 
Join Date: Jan 2016
Location: Kansas City Kansas
Posts: 4
Rocinante is an unknown quantity at this point
Re: Autonomous Timer Issue

Here is our code as of bagging up the robot. We cannot get it to move to the next steps of ArmDown, Turn. and Shoot. It just keep driving forward. If we switch code around whatever is in the top slot just keeps going on and on. So we are attaching to the code however the code does not seem to attach to a timer. So trying to attach a timer.

Public classAutonomous extends CommandGroup

public static double getFPGATimestamp() {
return 0;
}

public Autonomous() {
requires(Robot.drivetrain);
requires(Robot.robotshooter);
requires(Robot.armstart);

addSequential(new DriveForward(3.0));
addParallel(new ArmDown());
addSequential(new Turn(2.0));
addSequential(new Shoot(2.0));

Last edited by Rocinante : 25-02-2016 at 15:46. Reason: Forgot a line of code that could be helpful.
Reply With Quote
  #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
  #7   Spotlight this post!  
Unread 26-02-2016, 16:27
Rocinante Rocinante is offline
Registered User
FRC #1994
 
Join Date: Jan 2016
Location: Kansas City Kansas
Posts: 4
Rocinante is an unknown quantity at this point
Re: Autonomous Timer Issue

So you are putting the timer in the Drive Forward code not the Autonomous code. I have seen several ways. I think I like this one best. I will give it a shot. Thank you very much.
Reply With Quote
Reply


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 03:30.

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