forked from Team254/FRC-2019-Public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DriveOpenLoopAction.java
37 lines (29 loc) · 943 Bytes
/
DriveOpenLoopAction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.team254.frc2019.auto.actions;
import com.team254.frc2019.subsystems.Drive;
import com.team254.lib.util.DriveSignal;
import edu.wpi.first.wpilibj.Timer;
public class DriveOpenLoopAction implements Action {
private static final Drive mDrive = Drive.getInstance();
private double mStartTime;
private final double mDuration, mLeft, mRight;
public DriveOpenLoopAction(double left, double right, double duration) {
mDuration = duration;
mLeft = left;
mRight = right;
}
@Override
public void start() {
mDrive.setOpenLoop(new DriveSignal(mLeft, mRight));
mStartTime = Timer.getFPGATimestamp();
}
@Override
public void update() {}
@Override
public boolean isFinished() {
return Timer.getFPGATimestamp() - mStartTime > mDuration;
}
@Override
public void done() {
mDrive.setOpenLoop(new DriveSignal(0.0, 0.0));
}
}