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

Commit 6ef110c

Browse files
authored
Add queuer (#13)
1 parent c6ea8c0 commit 6ef110c

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

src/main/java/frc/robot/queuer/QueuerSubsystem.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,60 @@
22

33
import com.ctre.phoenix6.hardware.TalonFX;
44

5+
import dev.doglog.DogLog;
6+
import edu.wpi.first.math.filter.Debouncer;
57
import edu.wpi.first.wpilibj.DigitalInput;
68
import frc.robot.util.scheduling.SubsystemPriority;
79
import frc.robot.util.state_machines.StateMachine;
810

11+
912
public class QueuerSubsystem extends StateMachine<QueuerState> {
1013
private final TalonFX motor;
1114
private final DigitalInput sensor;
15+
private boolean sensorHasNote = false;
16+
private boolean debouncedSensorHasNote = false;
17+
private final Debouncer debouncer= new Debouncer(3 * 0.02);
1218

1319
public QueuerSubsystem(TalonFX motor, DigitalInput sensor) {
1420
super(SubsystemPriority.QUEUER, QueuerState.IDLE_NO_GP);
1521

1622
this.sensor = sensor;
1723
this.motor = motor;
18-
}}
24+
}
25+
public void seState(QueuerState newState){
26+
setStateFromRequest(newState);
27+
}
28+
@Override
29+
protected void collectInputs(){
30+
sensorHasNote=sensor.get();
31+
debouncedSensorHasNote = debouncer.calculate(sensorHasNote);
32+
}
33+
34+
@Override
35+
protected QueuerState getNextState(QueuerState currentState){
36+
// State transitions are done by robot manager, not here
37+
return currentState;
38+
}
39+
40+
public boolean hasNote() {
41+
return debouncedSensorHasNote;
42+
}
43+
44+
45+
@Override
46+
protected void afterTransition(QueuerState newState){
47+
switch(newState){
48+
case IDLE_NO_GP->motor.disable();
49+
case IDLE_WITH_GP->motor.disable();
50+
case SHOOTING->motor.setVoltage(0);//probably like 12
51+
case INTAKING->motor.setVoltage(0);//probably like 4
52+
case OUTTAKING->motor.setVoltage(0);//proabably like -4
53+
}
54+
}
55+
@Override
56+
public void robotPeriodic(){
57+
DogLog.log("Queuer/StatorCurrent", motor.getStatorCurrent().getValueAsDouble());
58+
DogLog.log("Queuer/SupplyCurrent", motor.getSupplyCurrent().getValueAsDouble());
59+
DogLog.log("Queuer/AppliedVoltage", motor.getMotorVoltage().getValueAsDouble());
60+
}
61+
}

src/main/java/frc/robot/shooter/ShooterSubsystem.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.ctre.phoenix6.controls.VelocityVoltage;
44
import com.ctre.phoenix6.hardware.TalonFX;
55

6+
import dev.doglog.DogLog;
67
import edu.wpi.first.math.MathUtil;
78
import edu.wpi.first.math.interpolation.InterpolatingDoubleTreeMap;
89
import frc.robot.util.scheduling.SubsystemPriority;
@@ -80,5 +81,11 @@ protected void afterTransition(ShooterState newState) {
8081
}
8182

8283
@Override
83-
public void robotPeriodic() {}
84+
public void robotPeriodic() {
85+
// Log stator current, supply current, current velocity in RPM, applied voltage
86+
DogLog.log("Shooter/StatorCurrent",motor.getStatorCurrent().getValueAsDouble());
87+
DogLog.log("Shooter/SupplyCurrent", motor.getSupplyCurrent().getValueAsDouble());
88+
DogLog.log("Shooter/RPM",motor.getVelocity().getValueAsDouble()*60.0);
89+
DogLog.log("Shooter/AppliedVoltage",motor.getMotorVoltage().getValueAsDouble());
90+
}
8491
}

0 commit comments

Comments
 (0)