6
6
import com .ctre .phoenix6 .controls .VoltageOut ;
7
7
import com .ctre .phoenix6 .hardware .TalonFX ;
8
8
import com .ctre .phoenix6 .signals .NeutralModeValue ;
9
- import com .revrobotics .CANSparkLowLevel .MotorType ;
10
- import com .revrobotics .CANSparkMax ;
11
9
import edu .wpi .first .wpilibj .DigitalInput ;
12
10
import frc .robot .Constants .IntakeConstants ;
13
11
import frc .robot .Constants .SensorConstants ;
14
12
15
- public class IntakeIOSparkMax implements IntakeIO {
13
+ public class IntakeIOFalcon implements IntakeIO {
16
14
17
- private CANSparkMax leftIntake =
18
- new CANSparkMax (IntakeConstants .leftIntakeMotorID , MotorType .kBrushless );
19
- private CANSparkMax rightIntake =
20
- new CANSparkMax (IntakeConstants .rightIntakeMotorID , MotorType .kBrushless );
15
+ private TalonFX leftIntake = new TalonFX (IntakeConstants .leftIntakeMotorID );
21
16
22
17
private TalonFX belt = new TalonFX (IntakeConstants .indexTwoMotorID );
23
18
24
19
DigitalInput bannerSensor = new DigitalInput (SensorConstants .uptakeSensorPort );
25
20
26
- public IntakeIOSparkMax () {
27
- leftIntake .setSmartCurrentLimit (50 );
28
- rightIntake .setSmartCurrentLimit (50 );
29
-
21
+ public IntakeIOFalcon () {
30
22
leftIntake .setInverted (true );
31
- rightIntake .setInverted (true );
32
23
33
24
belt .setInverted (true );
34
25
26
+ TalonFXConfigurator leftConfig = leftIntake .getConfigurator ();
27
+ leftConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Coast ));
28
+ leftConfig .apply (
29
+ new CurrentLimitsConfigs ()
30
+ .withStatorCurrentLimit (120 )
31
+ .withStatorCurrentLimitEnable (true ));
32
+
35
33
TalonFXConfigurator beltConfig = belt .getConfigurator ();
36
34
beltConfig .apply (new MotorOutputConfigs ().withNeutralMode (NeutralModeValue .Brake ));
37
35
beltConfig .apply (
@@ -42,11 +40,8 @@ public IntakeIOSparkMax() {
42
40
43
41
@ Override
44
42
public void updateInputs (IntakeIOInputs inputs ) {
45
- inputs .leftIntakeVoltage = leftIntake .getAppliedOutput () * 12 ;
46
- inputs .leftIntakeStatorCurrent = leftIntake .getOutputCurrent ();
47
-
48
- inputs .rightIntakeVoltage = rightIntake .getAppliedOutput () * 12 ;
49
- inputs .rightIntakeStatorCurrent = rightIntake .getOutputCurrent ();
43
+ inputs .leftIntakeVoltage = leftIntake .getMotorVoltage ().getValueAsDouble ();
44
+ inputs .leftIntakeStatorCurrent = leftIntake .getStatorCurrent ().getValueAsDouble ();
50
45
51
46
inputs .beltVoltage = belt .getMotorVoltage ().getValueAsDouble ();
52
47
inputs .beltStatorCurrent = belt .getStatorCurrent ().getValueAsDouble ();
@@ -57,8 +52,7 @@ public void updateInputs(IntakeIOInputs inputs) {
57
52
58
53
@ Override
59
54
public void setIntakeVoltage (double volts ) {
60
- leftIntake .set (volts / 12 );
61
- rightIntake .set (volts / 12 );
55
+ leftIntake .setControl (new VoltageOut (volts ));
62
56
}
63
57
64
58
@ Override
0 commit comments