Skip to content

Commit

Permalink
More logging added in subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekChen1 committed Dec 8, 2023
1 parent 374b3a2 commit 5d17022
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/IntakeIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public default void updateInputs(IntakeIOInputs inputs) {}
/** Run closed loop at the specified velocity. */
public default void setMotorPower(double power) {}

public default void setIsCone(boolean isCone) {}

/** Stop in open loop. */
public default void stop() {}
}
11 changes: 6 additions & 5 deletions src/main/java/frc/robot/subsystems/IntakeIOSim.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.simulation.FlywheelSim;
import edu.wpi.first.wpilibj.simulation.DCMotorSim;

public class IntakeIOSim implements IntakeIO {
// Note: Intakes have no simulation feature, so this simulation class is only here as a
// placeholder. To see an actual simulation, go to
// https://github.dev/Mechanical-Advantage/RobotCode2022/blob/main/src/main/java/frc/robot/subsystems and look at the simulations that have been implemented
private FlywheelSim sim = new FlywheelSim(null, 0, 0);
// Note: Intakes have no simulation feature, so this simulation uses the DC motor sim instead. To
// see other implementations of simulations, go to
// https://github.dev/Mechanical-Advantage/RobotCode2022/blob/main/src/main/java/frc/robot/subsystems
// and look at the simulations that have been implemented
private DCMotorSim sim = new DCMotorSim(null, 1, 4.69);
}
16 changes: 5 additions & 11 deletions src/main/java/frc/robot/subsystems/IntakeIOTalonFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,12 @@ public void setIsCone(boolean isCone) {
this.isCone = isCone;
}

public boolean getIsCone() {
return isCone;
}

public double getFilterOutput() {
return filterOutput;
}

public void updateInputs(IntakeIOInputs inputs) {
inputs.currentIntakeMode = inputs.currentIntakeMode.toString();
inputs.filterOutput = getFilterOutput();
inputs.isCone = getIsCone();
inputs.currentIntakeMode =
inputs.currentIntakeMode
.toString(); // The modes are updated in the subsystem instead of here
inputs.filterOutput = filter.calculate(inputs.filterOutput);
inputs.isCone = inputs.isCone; // This is also updated in the subsystem
inputs.motorOutput = getMotorPower();
}
}
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public void intakePeriodic(Modes modes) {

@Override
public void periodic() {
inputs.currentIntakeMode = mode.toString();

if (inputs.isCone && inputs.filterOutput >= Intake.CONE_STATOR_LIMIT) {
mode = Modes.HOLD;
} else if (inputs.filterOutput >= Intake.CUBE_STATOR_LIMIT) {
Expand Down

0 comments on commit 5d17022

Please sign in to comment.