Also if you don't need interrupts it may be helpful to have a timed command class:
This class is designed for commands that don't have interrupts and have static motor speeds.
If you wanted dynamic motor speeds you wouldn't want to override execute.
Code:
public abstract class TimedCommand extends Command{
public TimedCommand(double time){
super(time);
}
@Override
protected void execute() {
//do nothing
}
@Override
protected boolean isFinished() {
return isTimedOut();
}
@Override
protected void interrupted() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Code:
public class RunMotor extends TimedCommand{
private static double time = 1.0;
public RunMotor(){
super(time);
}
@Override
protected void initialize() {
motor.set(1);
}
@Override
protected void end() {
motor.set(0);
}
}