9
9
10
10
import com .ctre .phoenix6 .BaseStatusSignal ;
11
11
import com .ctre .phoenix6 .StatusSignal ;
12
- import com .ctre .phoenix6 .controls .MotionMagicVoltage ;
13
- import com .ctre .phoenix6 .controls .NeutralOut ;
14
- import com .ctre .phoenix6 .controls .PositionVoltage ;
15
- import com .ctre .phoenix6 .controls .VoltageOut ;
12
+ import com .ctre .phoenix6 .controls .*;
16
13
import com .ctre .phoenix6 .hardware .TalonFX ;
17
14
import frc .robot .utils .PhoenixUtil ;
18
15
import frc .robot .utils .TalonUtil ;
19
16
20
17
public class ClimbIOTalonFX implements ClimbIO {
21
18
22
- private final TalonFX climbMotor = new TalonFX (ClimbConstants .kLeftClimbMotorID );
19
+ private final TalonFX leftClimbMotor = new TalonFX (ClimbConstants .kLeftClimbMotorID );
23
20
private final PositionVoltage positionRequest = new PositionVoltage (0 ).withSlot (0 );
24
21
private final MotionMagicVoltage motionMagicRequest = new MotionMagicVoltage (0 ).withSlot (0 );
25
22
private final VoltageOut voltageReq = new VoltageOut (0 );
26
23
27
- private final StatusSignal <Double > climbMotorVoltage = climbMotor .getMotorVoltage ();
28
- private final StatusSignal <Double > climbMotorVelocity = climbMotor .getVelocity ();
29
- private final StatusSignal <Double > climbMotorPosition = climbMotor .getPosition ();
30
- private final StatusSignal <Double > climbMotorStatorCurrent = climbMotor .getStatorCurrent ();
31
- private final StatusSignal <Double > climbMotorSupplyCurrent = climbMotor .getSupplyCurrent ();
32
- private final StatusSignal <Double > climbMotorTemperature = climbMotor .getDeviceTemp ();
24
+ private final StatusSignal <Double > climbMotorVoltage = leftClimbMotor .getMotorVoltage ();
25
+ private final StatusSignal <Double > climbMotorVelocity = leftClimbMotor .getVelocity ();
26
+ private final StatusSignal <Double > climbMotorPosition = leftClimbMotor .getPosition ();
27
+ private final StatusSignal <Double > climbMotorStatorCurrent = leftClimbMotor .getStatorCurrent ();
28
+ private final StatusSignal <Double > climbMotorSupplyCurrent = leftClimbMotor .getSupplyCurrent ();
29
+ private final StatusSignal <Double > climbMotorTemperature = leftClimbMotor .getDeviceTemp ();
33
30
private final StatusSignal <Double > climbMotorReferenceSlope =
34
- climbMotor .getClosedLoopReferenceSlope ();
31
+ leftClimbMotor .getClosedLoopReferenceSlope ();
32
+
33
+ private final TalonFX rightClimbMotor = new TalonFX (ClimbConstants .kRightClimbMotorID );
34
+
35
+ private final Follower rightClimbFollowReq = new Follower (leftClimbMotor .getDeviceID (), false );
35
36
36
37
public ClimbIOTalonFX () {
37
- var motorConfig = ClimbConstants .motorConfig ;
38
- PhoenixUtil .checkErrorAndRetry (() -> climbMotor .getConfigurator ().refresh (motorConfig ));
39
- TalonUtil .applyAndCheckConfiguration (climbMotor , motorConfig );
38
+ var leftClimbConfig = ClimbConstants .leftClimbConfig ;
39
+ PhoenixUtil .checkErrorAndRetry (() -> leftClimbMotor .getConfigurator ().refresh (leftClimbConfig ));
40
+ TalonUtil .applyAndCheckConfiguration (leftClimbMotor , leftClimbConfig );
41
+
42
+ var rightClimbConfig = ClimbConstants .righClimbConfig ;
43
+ PhoenixUtil .checkErrorAndRetry (
44
+ () -> rightClimbMotor .getConfigurator ().refresh (rightClimbConfig ));
45
+ TalonUtil .applyAndCheckConfiguration (rightClimbMotor , rightClimbConfig );
40
46
41
47
BaseStatusSignal .setUpdateFrequencyForAll (
42
48
ClimbConstants .updateFrequency ,
@@ -47,7 +53,8 @@ public ClimbIOTalonFX() {
47
53
climbMotorSupplyCurrent ,
48
54
climbMotorTemperature ,
49
55
climbMotorReferenceSlope );
50
- climbMotor .optimizeBusUtilization ();
56
+ leftClimbMotor .optimizeBusUtilization ();
57
+ rightClimbMotor .setControl (rightClimbFollowReq );
51
58
}
52
59
53
60
@ Override
@@ -72,30 +79,30 @@ public void updateInputs(ClimbIOInputs inputs) {
72
79
@ Override
73
80
public void setPosition (double position ) {
74
81
if (ClimbConstants .kUseMotionMagic ) {
75
- climbMotor .setControl (motionMagicRequest .withPosition (position ));
82
+ leftClimbMotor .setControl (motionMagicRequest .withPosition (position ));
76
83
} else {
77
- climbMotor .setControl (positionRequest .withPosition (position ));
84
+ leftClimbMotor .setControl (positionRequest .withPosition (position ));
78
85
}
79
86
}
80
87
81
88
@ Override
82
89
public void setVoltage (double voltage ) {
83
- climbMotor .setVoltage (voltage );
90
+ leftClimbMotor .setVoltage (voltage );
84
91
}
85
92
86
93
@ Override
87
94
public void off () {
88
- climbMotor .setControl (new NeutralOut ());
95
+ leftClimbMotor .setControl (new NeutralOut ());
89
96
}
90
97
91
98
@ Override
92
99
public void zero () {
93
- climbMotor .setPosition (0 );
100
+ leftClimbMotor .setPosition (0 );
94
101
}
95
102
96
103
@ Override
97
104
public TalonFX getMotor () {
98
- return climbMotor ;
105
+ return leftClimbMotor ;
99
106
}
100
107
101
108
@ Override
0 commit comments