-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiagSparkMaxAbsEncoder.java
More file actions
30 lines (25 loc) · 1 KB
/
DiagSparkMaxAbsEncoder.java
File metadata and controls
30 lines (25 loc) · 1 KB
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
package frc.robot.utils.diag;
import com.ctre.phoenix6.hardware.CANcoder;
/**
* A diagnostics class for digital encoder. The diagnostics will turn green once the encoder has traveled at least a given
* distance from its initial position (measured at initialization or after a reset)
*/
public class DiagSparkMaxAbsEncoder extends DiagDistanceTraveled {
private CANcoder canCoder;
/**
* Constructor
*
* @param name - the name of the unit. Will be used on the Shuffleboard
* @param requiredTravel - the required difference between the initial position to qualify for success
* @param canSparkMax - the encoder instance to test
*/
public DiagSparkMaxAbsEncoder(String title, String name, double requiredTravel, CANcoder canCoder) {
super(title, name, requiredTravel);
this.canCoder = canCoder;
reset();
}
@Override
protected double getCurrentValue() {
return canCoder.getAbsolutePosition().getValueAsDouble();
}
}