Open elodotwe opened 6 years ago
I think there may be a better solution: WPI Library comes with a 'setTimeout()' function
public waitFor(double seconds){
setTimeout(seconds); //amount in seconds
}
protected boolean isFinished() {
return isTimedOut();
}
Has anyone tested the Wait command?
Untested, but I don't see any reason why it won't work.
This command should do nothing but sit and wait a number of seconds before completing.
My recommendation would be to use the [currentTimeMillis() function built into Java](https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#currentTimeMillis()). When the command starts, you'll need to save (into a variable) the current time, and in the
execute()
function of the command you'll need to check whether the specified number of seconds have elapsed since you saved that time (if (currentTimeMillis() - startTime >= howLongWeShouldWait
or something like that).The constructor for this Command should take a number of milliseconds as a parameter:
public Command(long waitTimeMsec)
In case it's new to you, a millisecond is 1/1000 seconds, so 1000 milliseconds is 1 second for example.
I anticipate using this block in a list of commands--we'll do a
WaitFor(500)
followed byDriveTo(12)
etc.