-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHYPER_TalonSRX.java
More file actions
54 lines (45 loc) · 1.42 KB
/
HYPER_TalonSRX.java
File metadata and controls
54 lines (45 loc) · 1.42 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.hyperonline.hyperlib.controller;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.util.sendable.SendableBuilder;
import org.hyperonline.hyperlib.controller.meta.RawController;
import java.util.function.DoubleConsumer;
/**
* wrapper for added behavior on the {@link WPI_TalonSRX}
*
* <strong>added behavior</strong> *
* <ul>
* <li>automatically add datapoints to LiveWindow</li>
* </ul>
*
* @author Chris McGroarty
*/
public class HYPER_TalonSRX extends WPI_TalonSRX implements RawController {
private final boolean m_useSensor;
public DoubleConsumer consumeSpeed = speed -> this.set(speed);
/**
* Constructor for motor controller
*
* @param deviceNumber device ID of motor controller
* @param useSensor should the sensor values be pushed to LiveWindow
*/
public HYPER_TalonSRX(int deviceNumber, boolean useSensor) {
super(deviceNumber);
m_useSensor = useSensor;
}
public HYPER_TalonSRX(int deviceNumber) {
this(deviceNumber, false);
}
@Override
public void initSendable(SendableBuilder builder) {
super.initSendable(builder);
if (m_useSensor) {
builder.addDoubleProperty("Position", this::getSelectedSensorPosition, null);
builder.addDoubleProperty("Velocity", this::getSelectedSensorVelocity, null);
}
}
@Override
public void resetMotorConfig() {
this.configFactoryDefault();
this.clearStickyFaults();
}
}