|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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". |
|
#2
|
||||
|
||||
|
Re: Autonomous Timer Issue
I'm sorry I'm tired but going off of this bit of text
Quote:
Code:
setTimeout(timeToPause) Code:
AutonCommand c = new AutonCommand() c.setTimeout(1) addSequential(c) |
|
#3
|
|||
|
|||
|
Re: Autonomous Timer Issue
Cool, thank you we will give it a shot.
|
|
#4
|
|||
|
|||
|
Re: Autonomous Timer Issue
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 |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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();
}
}
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. |
|
#7
|
|||
|
|||
|
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|