fixed time logic

This commit is contained in:
aarav18
2022-03-22 00:33:05 -06:00
parent 2e22a1a23c
commit 8af4535191
4 changed files with 5 additions and 3 deletions
@@ -460,6 +460,8 @@ public class RobotContainer {
new RunCommand(() -> m_robotStorage.runStorage(StorageConstants.STORAGE_SPEED), m_robotStorage)
));
// TODO: we should test TrackTarget timing with my RunCommandForTime thing at some point, same with DriveWithInput timing
// * aim with RotateUntilTarget
// return new SequentialCommandGroup( new InstantCommand(() -> m_robotSwerveDrive.resetGyro(), m_robotSwerveDrive),
// new DriveWithInputForTime(m_robotSwerveDrive, new double[] {0.5, 0.5, 0.0, 0.0}, 1.0),
@@ -54,6 +54,6 @@ public class DriveWithInputForTime extends CommandBase {
// Returns true when the command should end.
@Override
public boolean isFinished() {
return (((long) duration) >= (start - elapsed));
return (elapsed >= duration);
}
}
@@ -70,9 +70,9 @@ public class RunCommandForTime extends CommandBase {
@Override
public boolean isFinished() {
if (this.override) {
return (((long) this.duration) >= (this.elapsed - this.start));
return (this.elapsed >= this.duration);
} else {
return (this.command.isFinished() && (((long) this.duration) >= (this.elapsed - this.start)));
return (this.command.isFinished() && (this.elapsed >= this.duration));
}
}
}