Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 0bb034c

Browse files
committed
Start adding centering motor to intake subsystem
1 parent 5fbec9a commit 0bb034c

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

src/main/java/frc/robot/Hardware.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public class Hardware {
1515
new TalonFX(RobotConfig.get().queuer().motorID(), RobotConfig.get().queuer().canBusName());
1616

1717
public final TalonFX intake =
18-
new TalonFX(RobotConfig.get().intake().motorID(), RobotConfig.get().intake().canBusName());
18+
new TalonFX(
19+
RobotConfig.get().intake().mainMotorID(),
20+
RobotConfig.get().intake().mainMotorCanBusName());
1921

2022
public final TalonFX armLeft =
2123
new TalonFX(RobotConfig.get().arm().leftMotorID(), RobotConfig.get().arm().canBusName());

src/main/java/frc/robot/config/CompConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@ class CompConfig {
6666
999,
6767
CANIVORE_NAME,
6868
999,
69+
999,
6970
new TalonFXConfiguration()
7071
.withClosedLoopRamps(CLOSED_LOOP_RAMP)
7172
.withOpenLoopRamps(OPEN_LOOP_RAMP)
7273
.withCurrentLimits(
7374
new CurrentLimitsConfigs()
7475
.withStatorCurrentLimit(20)
7576
.withSupplyCurrentLimit(25)),
77+
centeringMotor -> {
78+
centeringMotor.setSmartCurrentLimit(20);
79+
centeringMotor.burnFlash();
80+
},
7681
new Debouncer(3.0 * 0.02)),
7782
new ArmConfig(
7883
CANIVORE_NAME,

src/main/java/frc/robot/config/RobotConfig.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.ctre.phoenix6.configs.TalonFXConfiguration;
44
import com.ctre.phoenix6.mechanisms.swerve.utility.PhoenixPIDController;
5+
import com.revrobotics.CANSparkMax;
56
import edu.wpi.first.math.filter.Debouncer;
67
import edu.wpi.first.math.interpolation.InterpolatingDoubleTreeMap;
78
import java.util.function.Consumer;
@@ -35,10 +36,12 @@ public record ShooterConfig(
3536
Consumer<InterpolatingDoubleTreeMap> speakerDistanceToRpm) {}
3637

3738
public record IntakeConfig(
38-
int motorID,
39-
String canBusName,
39+
int mainMotorID,
40+
String mainMotorCanBusName,
41+
int centeringMotorID,
4042
int sensorID,
41-
TalonFXConfiguration motorConfig,
43+
TalonFXConfiguration mainMotorConfig,
44+
Consumer<CANSparkMax> centeringMotorConfig,
4245
Debouncer debouncer) {}
4346

4447
public record ArmConfig(

src/main/java/frc/robot/intake/IntakeSubsystem.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
import frc.robot.util.state_machines.StateMachine;
1010

1111
public class IntakeSubsystem extends StateMachine<IntakeState> {
12-
private final TalonFX motor;
12+
private final TalonFX mainMotor;
1313
private final DigitalInput sensor;
1414
private boolean sensorHasNote = false;
1515
private boolean debouncedSensorHasNote = false;
1616
private final Debouncer debouncer = RobotConfig.get().intake().debouncer();
1717

18-
public IntakeSubsystem(TalonFX motor, DigitalInput sensor) {
18+
public IntakeSubsystem(TalonFX mainMotor, DigitalInput sensor) {
1919
super(SubsystemPriority.INTAKE, IntakeState.IDLE);
2020

2121
this.sensor = sensor;
22-
this.motor = motor;
23-
motor.getConfigurator().apply(RobotConfig.get().intake().motorConfig());
22+
this.mainMotor = mainMotor;
23+
24+
mainMotor.getConfigurator().apply(RobotConfig.get().intake().mainMotorConfig());
25+
26+
// TODO: Uncomment this once the centeringMotor code is written
27+
// RobotConfig.get().intake().centeringMotorConfig().accept(centeringMotor);
2428
}
2529

2630
public void setState(IntakeState newState) {
@@ -45,18 +49,18 @@ public boolean hasNote() {
4549
@Override
4650
protected void afterTransition(IntakeState newState) {
4751
switch (newState) {
48-
case IDLE -> motor.disable();
49-
case INTAKING -> motor.setVoltage(0); // around 10
50-
case OUTTAKING -> motor.setVoltage(0); // around -6
52+
case IDLE -> mainMotor.disable();
53+
case INTAKING -> mainMotor.setVoltage(0); // around 10
54+
case OUTTAKING -> mainMotor.setVoltage(0); // around -6
5155
}
5256
}
5357

5458
@Override
5559
public void robotPeriodic() {
5660
super.robotPeriodic();
57-
DogLog.log("Intake/StatorCurrent", motor.getStatorCurrent().getValueAsDouble());
58-
DogLog.log("Intake/SupplyCurrent", motor.getSupplyCurrent().getValueAsDouble());
59-
DogLog.log("Intake/AppliedVoltage", motor.getMotorVoltage().getValueAsDouble());
61+
DogLog.log("Intake/StatorCurrent", mainMotor.getStatorCurrent().getValueAsDouble());
62+
DogLog.log("Intake/SupplyCurrent", mainMotor.getSupplyCurrent().getValueAsDouble());
63+
DogLog.log("Intake/AppliedVoltage", mainMotor.getMotorVoltage().getValueAsDouble());
6064
DogLog.log("Intake/RawSensor", sensorHasNote);
6165
DogLog.log("Intake/DebouncedSensor", hasNote());
6266
}

0 commit comments

Comments
 (0)