Skip to content

Commit

Permalink
encapsulated autologged shooter inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
GearBoxFox committed Feb 3, 2024
1 parent 18813fa commit f817aa3
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 49 deletions.
178 changes: 160 additions & 18 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,169 @@
public interface ShooterIO {
@AutoLog
class ShooterIOInputs {
public double tlVelocityRots = 0.0;
public double trVelocityRots = 0.0;
public double blVelocityRots = 0.0;
public double brVelocityRots = 0.0;
public double tlAppliedVolts = 0.0;
public double trAppliedVolts = 0.0;
public double blAppliedVolts = 0.0;
public double brAppliedVolts = 0.0;
public double kickerAppliedVolts = 0.0;
public double tlCurrentDraw = 0.0;
public double trCurrentDraw = 0.0;
public double blCurrentDraw = 0.0;
public double brCurrentDraw = 0.0;
public double kickerCurrentDraw = 0.0;
public double tlTemperature = 0.0;
public double trTemperature = 0.0;
public double blTemperature = 0.0;
public double brTemperature = 0.0;
protected double tlVelocityRots = 0.0;
protected double trVelocityRots = 0.0;
protected double blVelocityRots = 0.0;
protected double brVelocityRots = 0.0;
protected double tlAppliedVolts = 0.0;
protected double trAppliedVolts = 0.0;
protected double blAppliedVolts = 0.0;
protected double brAppliedVolts = 0.0;
protected double kickerAppliedVolts = 0.0;
protected double tlCurrentDraw = 0.0;
protected double trCurrentDraw = 0.0;
protected double blCurrentDraw = 0.0;
protected double brCurrentDraw = 0.0;
protected double kickerCurrentDraw = 0.0;
protected double tlTemperature = 0.0;
protected double trTemperature = 0.0;
protected double blTemperature = 0.0;
protected double brTemperature = 0.0;


public double getTlVelocityRots() {
return tlVelocityRots;
}

public void setTlVelocityRots(double tlVelocityRots) {
this.tlVelocityRots = tlVelocityRots;
}

public double getTrVelocityRots() {
return trVelocityRots;
}

public void setTrVelocityRots(double trVelocityRots) {
this.trVelocityRots = trVelocityRots;
}

public double getBlVelocityRots() {
return blVelocityRots;
}

public void setBlVelocityRots(double blVelocityRots) {
this.blVelocityRots = blVelocityRots;
}

public double getBrVelocityRots() {
return brVelocityRots;
}

public void setBrVelocityRots(double brVelocityRots) {
this.brVelocityRots = brVelocityRots;
}

public double getTlAppliedVolts() {
return tlAppliedVolts;
}

public void setTlAppliedVolts(double tlAppliedVolts) {
this.tlAppliedVolts = tlAppliedVolts;
}

public double getTrAppliedVolts() {
return trAppliedVolts;
}

public void setTrAppliedVolts(double trAppliedVolts) {
this.trAppliedVolts = trAppliedVolts;
}

public double getBlAppliedVolts() {
return blAppliedVolts;
}

public void setBlAppliedVolts(double blAppliedVolts) {
this.blAppliedVolts = blAppliedVolts;
}

public double getBrAppliedVolts() {
return brAppliedVolts;
}

public void setBrAppliedVolts(double brAppliedVolts) {
this.brAppliedVolts = brAppliedVolts;
}

public double getKickerAppliedVolts() {
return kickerAppliedVolts;
}

public void setKickerAppliedVolts(double kickerAppliedVolts) {
this.kickerAppliedVolts = kickerAppliedVolts;
}

public double getTlCurrentDraw() {
return tlCurrentDraw;
}

public void setTlCurrentDraw(double tlCurrentDraw) {
this.tlCurrentDraw = tlCurrentDraw;
}

public double getTrCurrentDraw() {
return trCurrentDraw;
}

public void setTrCurrentDraw(double trCurrentDraw) {
this.trCurrentDraw = trCurrentDraw;
}

public double getBlCurrentDraw() {
return blCurrentDraw;
}

public void setBlCurrentDraw(double blCurrentDraw) {
this.blCurrentDraw = blCurrentDraw;
}

public double getBrCurrentDraw() {
return brCurrentDraw;
}

public void setBrCurrentDraw(double brCurrentDraw) {
this.brCurrentDraw = brCurrentDraw;
}

public double getKickerCurrentDraw() {
return kickerCurrentDraw;
}

public void setKickerCurrentDraw(double kickerCurrentDraw) {
this.kickerCurrentDraw = kickerCurrentDraw;
}

public double getTlTemperature() {
return tlTemperature;
}

public void setTlTemperature(double tlTemperature) {
this.tlTemperature = tlTemperature;
}

public double getTrTemperature() {
return trTemperature;
}

public void setTrTemperature(double trTemperature) {
this.trTemperature = trTemperature;
}

public double getBlTemperature() {
return blTemperature;
}

public void setBlTemperature(double blTemperature) {
this.blTemperature = blTemperature;
}

public double getBrTemperature() {
return brTemperature;
}

public void setBrTemperature(double brTemperature) {
this.brTemperature = brTemperature;
}
}
default void setMotorVoltageTL(double voltage) {}
default void setMotorVoltageTR(double voltage) {}
Expand Down
42 changes: 21 additions & 21 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIOPrototype.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,26 @@ public void updateInputs(ShooterIOInputs inputs) {
m_bottomLeftPidProperty.updateIfChanged();
m_bottomRightPidProperty.updateIfChanged();

inputs.tlVelocityRots = m_topLeftMotor.getEncoder().getVelocity();
inputs.trVelocityRots = m_topRightMotor.getEncoder().getVelocity();
inputs.blVelocityRots = m_bottomLeftMotor.getEncoder().getVelocity();
inputs.brVelocityRots = m_bottomRightMotor.getEncoder().getVelocity();

inputs.tlAppliedVolts = m_topLeftMotor.getAppliedOutput() * m_topLeftMotor.getBusVoltage();
inputs.trAppliedVolts = m_topRightMotor.getAppliedOutput() * m_topRightMotor.getBusVoltage();
inputs.blAppliedVolts = m_bottomLeftMotor.getAppliedOutput() * m_bottomLeftMotor.getBusVoltage();
inputs.brAppliedVolts = m_bottomRightMotor.getAppliedOutput() * m_bottomRightMotor.getBusVoltage();
inputs.kickerAppliedVolts = m_kickerMotor.getAppliedOutput() * m_kickerMotor.getBusVoltage();

inputs.tlCurrentDraw = m_topLeftMotor.getOutputCurrent();
inputs.trCurrentDraw = m_topRightMotor.getOutputCurrent();
inputs.blCurrentDraw = m_bottomLeftMotor.getOutputCurrent();
inputs.brCurrentDraw = m_bottomRightMotor.getOutputCurrent();
inputs.kickerCurrentDraw = m_kickerMotor.getOutputCurrent();

inputs.tlTemperature = m_topLeftMotor.getMotorTemperature();
inputs.trTemperature = m_topRightMotor.getMotorTemperature();
inputs.blTemperature = m_bottomLeftMotor.getMotorTemperature();
inputs.brTemperature = m_bottomRightMotor.getMotorTemperature();
inputs.setTlVelocityRots(m_topLeftMotor.getEncoder().getVelocity());
inputs.setTrVelocityRots(m_topRightMotor.getEncoder().getVelocity());
inputs.setBlVelocityRots(m_bottomLeftMotor.getEncoder().getVelocity());
inputs.setBrVelocityRots(m_bottomRightMotor.getEncoder().getVelocity());

inputs.setTlAppliedVolts(m_topLeftMotor.getAppliedOutput() * m_topLeftMotor.getBusVoltage());
inputs.setTrAppliedVolts(m_topRightMotor.getAppliedOutput() * m_topRightMotor.getBusVoltage());
inputs.setBlAppliedVolts(m_bottomLeftMotor.getAppliedOutput() * m_bottomLeftMotor.getBusVoltage());
inputs.setBrAppliedVolts(m_bottomRightMotor.getAppliedOutput() * m_bottomRightMotor.getBusVoltage());
inputs.setKickerAppliedVolts(m_kickerMotor.getAppliedOutput() * m_kickerMotor.getBusVoltage());

inputs.setTlCurrentDraw(m_topLeftMotor.getOutputCurrent());
inputs.setTrCurrentDraw(m_topRightMotor.getOutputCurrent());
inputs.setBlCurrentDraw(m_bottomLeftMotor.getOutputCurrent());
inputs.setBrCurrentDraw(m_bottomRightMotor.getOutputCurrent());
inputs.setKickerCurrentDraw(m_kickerMotor.getOutputCurrent());

inputs.setTlTemperature(m_topLeftMotor.getMotorTemperature());
inputs.setTrTemperature(m_topRightMotor.getMotorTemperature());
inputs.setBlTemperature(m_bottomLeftMotor.getMotorTemperature());
inputs.setBrTemperature(m_bottomRightMotor.getMotorTemperature());
}
}
20 changes: 10 additions & 10 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public void updateInputs(ShooterIOInputs inputs) {
m_simLeft.update(LOOP_PERIOD_SECS);
m_simRight.update(LOOP_PERIOD_SECS);

inputs.tlVelocityRots = m_simLeft.getAngularVelocityRadPerSec();
inputs.trVelocityRots = m_simRight.getAngularVelocityRadPerSec();
inputs.blVelocityRots = m_simLeft.getAngularVelocityRadPerSec();
inputs.brVelocityRots = m_simRight.getAngularVelocityRadPerSec();

inputs.tlAppliedVolts = leftAppliedVolts;
inputs.trAppliedVolts = rightAppliedVolts;
inputs.blAppliedVolts = leftAppliedVolts;
inputs.brAppliedVolts = rightAppliedVolts;
inputs.kickerAppliedVolts = kickerAppliedVolts;
inputs.setTlVelocityRots(m_simLeft.getAngularVelocityRadPerSec());
inputs.setTrVelocityRots(m_simRight.getAngularVelocityRadPerSec());
inputs.setBlVelocityRots(m_simLeft.getAngularVelocityRadPerSec());
inputs.setBrVelocityRots(m_simRight.getAngularVelocityRadPerSec());

inputs.setTlAppliedVolts(leftAppliedVolts);
inputs.setTrAppliedVolts(rightAppliedVolts);
inputs.setBlAppliedVolts(leftAppliedVolts);
inputs.setBrAppliedVolts(rightAppliedVolts);
inputs.setKickerAppliedVolts(kickerAppliedVolts);
}

@Override
Expand Down

0 comments on commit f817aa3

Please sign in to comment.