Hey Guys,
I decided to get autonomous to work this year and ran into the problem of an unlimited run time despite a set stopping point.
Can someone check this out and find the problem? I honestly don't know what the problem is.
I may be overlooking something simple, but I am clearly not seeing it.
Code:
public void autonomousInit() {
// schedule the autonomous command (example)
// if (autonomousCommand != null) autonomousCommand.start();
//autonomousCommand.start();
// Reset timer to 0sec
edu.wpi.first.wpilibj.Timer myTimer = new edu.wpi.first.wpilibj.Timer();
myTimer.reset();
// Start timer
myTimer.start();
// move(-0.5,3.0);
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
// link -https://www.reddit.com/r/FRC/comments/3zcc2d/timer_not_working/
// If is has been less than 2 seconds since autonomous started, drive forwards
edu.wpi.first.wpilibj.Timer myTimer = new edu.wpi.first.wpilibj.Timer();
if(myTimer.get() < 2.0){
Robot.drivetraintank.setLeft_Back(0.5);
Robot.drivetraintank.setLeft(0.5);
Robot.drivetraintank.setRight(0.5);
Robot.drivetraintank.setRight_Back(0.5);
}
// If more than 2 seconds have elapsed, stop driving and turn off the timer
else {
Robot.drivetraintank.setLeft_Back(0.5);
Robot.drivetraintank.setLeft(0.5);
Robot.drivetraintank.setRight(0.5);
Robot.drivetraintank.setRight_Back(0.5);
myTimer.stop();
}
}
// Scheduler.getInstance().run();