1
1
package frc .robot .subsystems .arm .pivot ;
2
2
3
- import com .ctre .phoenix6 .controls .CoastOut ;
3
+ import com .ctre .phoenix6 .configs .MotorOutputConfigs ;
4
+ import com .ctre .phoenix6 .configs .TalonFXConfigurator ;
4
5
import com .ctre .phoenix6 .controls .Follower ;
5
- import com .ctre .phoenix6 .controls .StaticBrake ;
6
6
import com .ctre .phoenix6 .controls .VoltageOut ;
7
7
import com .ctre .phoenix6 .hardware .TalonFX ;
8
+ import com .ctre .phoenix6 .signals .NeutralModeValue ;
8
9
9
10
import edu .wpi .first .wpilibj .DutyCycleEncoder ;
10
11
import frc .robot .Constants ;
@@ -21,12 +22,16 @@ public class PivotIOFalcon implements PivotIO {
21
22
private double lastPosition ;
22
23
23
24
public PivotIOFalcon () {
25
+ TalonFXConfigurator rightConfig = rightMotor .getConfigurator ();
26
+ rightConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Brake ));
27
+
28
+ TalonFXConfigurator leftConfig = leftMotor .getConfigurator ();
29
+ leftConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Brake ));
30
+
24
31
rightMotor .setInverted (false );
25
32
26
33
leftMotor .setControl (new Follower (CANDevices .rightPivotMotorID , true ));
27
34
28
- rightMotor .setControl (new StaticBrake ());
29
-
30
35
//I have no idea how to set a current limit with the API
31
36
32
37
lastPosition = getPosition ();
@@ -44,7 +49,20 @@ public void updateInputs(PivotIOInputsAutoLogged inputs) {
44
49
45
50
@ Override
46
51
public void setBrakeMode (boolean brake ) {
47
- rightMotor .setControl (brake ? new StaticBrake () : new CoastOut ());
52
+ //TODO: find a more effient way to do this
53
+ if (brake ) {
54
+ TalonFXConfigurator rightConfig = rightMotor .getConfigurator ();
55
+ rightConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Brake ));
56
+
57
+ TalonFXConfigurator leftConfig = leftMotor .getConfigurator ();
58
+ leftConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Brake ));
59
+ } else {
60
+ TalonFXConfigurator rightConfig = rightMotor .getConfigurator ();
61
+ rightConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Coast ));
62
+
63
+ TalonFXConfigurator leftConfig = leftMotor .getConfigurator ();
64
+ leftConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Coast ));
65
+ }
48
66
}
49
67
50
68
@ Override
0 commit comments