Skip to content

Commit

Permalink
feat: update inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Steggoo committed Feb 1, 2024
1 parent ac8b1ac commit d899bb3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 33 deletions.
1 change: 1 addition & 0 deletions src/main/java/frc/robot/subsystems/climber/ClimberIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class ClimberIOInputs {

default void setRightPosition(double degrees) {}
default void setLeftPosition(double degrees) {}
default void updateInputs(ClimberIOInputs inputs) {}
}
14 changes: 14 additions & 0 deletions src/main/java/frc/robot/subsystems/climber/ClimberIOPrototype.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,18 @@ public void setRightPosition(double degrees) {
final PositionVoltage m_request = new PositionVoltage(0).withSlot(0);
m_rightTalon.setControl(m_request.withPosition(degrees / 360.0));
}

@Override
public void updateInputs(ClimberIOInputs inputs) {
inputs.leftClimberPosition = m_leftTalon.getPosition().getValueAsDouble();
inputs.rightClimberPosition = m_rightTalon.getPosition().getValueAsDouble();
inputs.leftClimberVelocity = m_leftTalon.getVelocity().getValueAsDouble();
inputs.rightClimberVelocity = m_rightTalon.getVelocity().getValueAsDouble();
inputs.leftClimberCurrentDraw = m_leftTalon.getSupplyCurrent().getValueAsDouble();
inputs.rightClimberCurrentDraw = m_rightTalon.getSupplyCurrent().getValueAsDouble();
inputs.leftClimberCurrentSetpoint = m_leftTalon.getClosedLoopReference().getValueAsDouble();
inputs.rightClimberCurrentSetpoint = m_rightTalon.getClosedLoopReference().getValueAsDouble();
inputs.leftClimberAppliedOutput = m_leftTalon.getBridgeOutput().getValueAsDouble();
inputs.rightClimberAppliedOutput = m_rightTalon.getBridgeOutput().getValueAsDouble();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

public class ClimberSubsystem extends SubsystemBase {
private final ClimberIO m_io;
private final ClimberIOInputsAutoLogged m_inputs;
public ClimberSubsystem(ClimberIO io) {
m_io = io;
m_inputs = new ClimberIOInputsAutoLogged();
}

public void setClimberPower(double power) {
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIOPrototype.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ public ShooterIOPrototype() {
m_intakeRight.burnFlash();
}

@Override
public void updateInputs(ShooterIOInputs inputs) {
inputs.tLAngularVelocity = m_topLeftMotor.getEncoder().getVelocity() * Math.PI;
inputs.tRAngularVelocity = m_topRightMotor.getEncoder().getVelocity() * Math.PI;
inputs.bLAngularVelocity = m_bottomLeftMotor.getEncoder().getVelocity() * Math.PI;
inputs.bRAngularVelocity = m_bottomRightMotor.getEncoder().getVelocity() * Math.PI;
inputs.kickerAngularVelocity = m_kickerMotor.getEncoder().getVelocity() * Math.PI;

inputs.tLAppliedInputs = m_topLeftMotor.getAppliedOutput();
inputs.tRAppliedInputs = m_topRightMotor.getAppliedOutput();
inputs.bLAppliedInputs = m_bottomLeftMotor.getAppliedOutput();
inputs.bRAppliedInputs = m_bottomRightMotor.getAppliedOutput();
inputs.kickerAppliedInputs = m_kickerMotor.getAppliedOutput();
}

@Override
public void setMotorVoltageTL(double voltage) {
m_topLeftMotor.setVoltage(voltage);
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,7 @@ public class ShooterIOSim implements ShooterIO{
private double bRAppliedVolts = 0.0;
private double kickerAppliedVolts = 0.0;

@Override
public void updateInputs(ShooterIOInputs inputs) {
m_simTL.update(LOOP_PERIOD_SECS);
m_simTR.update(LOOP_PERIOD_SECS);
m_simBL.update(LOOP_PERIOD_SECS);
m_simBR.update(LOOP_PERIOD_SECS);

inputs.tLAngularVelocity = m_simTL.getAngularVelocityRadPerSec();
inputs.tRAngularVelocity = m_simTR.getAngularVelocityRadPerSec();
inputs.bLAngularVelocity = m_simBL.getAngularVelocityRadPerSec();
inputs.bRAngularVelocity = m_simBR.getAngularVelocityRadPerSec();
inputs.kickerAngularVelocity = m_simKicker.getAngularVelocityRadPerSec();

inputs.tLAppliedInputs = tLAppliedVolts;
inputs.tRAppliedInputs = tRAppliedVolts;
inputs.bLAppliedInputs = bLAppliedVolts;
inputs.bRAppliedInputs = bRAppliedVolts;
inputs.kickerAppliedInputs = kickerAppliedVolts;
}

@Override
public void setMotorVoltageTL(double voltage) {
Expand Down

0 comments on commit d899bb3

Please sign in to comment.