-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intake subsystem + minor tweaks to queuer and shooter
- Loading branch information
Showing
6 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package frc.robot.intake; | ||
|
||
public enum IntakeState { | ||
IDLE, | ||
INTAKING, | ||
OUTTAKING; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package frc.robot.intake; | ||
|
||
import com.ctre.phoenix6.hardware.TalonFX; | ||
|
||
import dev.doglog.DogLog; | ||
import edu.wpi.first.math.filter.Debouncer; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import frc.robot.util.scheduling.SubsystemPriority; | ||
import frc.robot.util.state_machines.StateMachine; | ||
|
||
public class IntakeSubsystem extends StateMachine<IntakeState> { | ||
private final TalonFX motor; | ||
private final DigitalInput sensor; | ||
private boolean sensorHasNote = false; | ||
private boolean debouncedSensorHasNote = false; | ||
private final Debouncer debouncer = new Debouncer(3.0*0.02); | ||
|
||
public IntakeSubsystem (TalonFX motor,DigitalInput sensor){ | ||
super(SubsystemPriority.INTAKE, IntakeState.IDLE); | ||
|
||
this.sensor = sensor; | ||
this.motor = motor; | ||
} | ||
public void setState (IntakeState newState){ | ||
setStateFromRequest(newState); | ||
} | ||
|
||
@Override | ||
protected void collectInputs(){ | ||
sensorHasNote=sensor.get(); | ||
debouncedSensorHasNote=debouncer.calculate(sensorHasNote); | ||
} | ||
@Override | ||
protected IntakeState getNextState(IntakeState currentState){ | ||
return currentState; | ||
} | ||
public boolean hasNote(){ | ||
return debouncedSensorHasNote; | ||
} | ||
@Override | ||
protected void afterTransition(IntakeState newState){ | ||
switch (newState){ | ||
case IDLE->motor.disable(); | ||
case INTAKING->motor.setVoltage(0);//around 10 | ||
case OUTTAKING->motor.setVoltage(0);//around -6 | ||
} | ||
} | ||
@Override | ||
public void robotPeriodic(){ | ||
super.robotPeriodic(); | ||
DogLog.log("Intake/StatorCurrent", motor.getStatorCurrent().getValueAsDouble()); | ||
DogLog.log("Intake/SupplyCurrent", motor.getSupplyCurrent().getValueAsDouble()); | ||
DogLog.log("Intake/AppliedVoltage", motor.getMotorVoltage().getValueAsDouble()); | ||
DogLog.log("Intake/RawSensor",sensorHasNote); | ||
DogLog.log("Intake/DebouncedSensor",hasNote()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters