From f817aa3aadee9212720a67202043174f4e107777 Mon Sep 17 00:00:00 2001 From: Logan Hollowood <98189655+GearBoxFox@users.noreply.github.com> Date: Sat, 3 Feb 2024 10:07:09 -0500 Subject: [PATCH] encapsulated autologged shooter inputs --- .../robot/subsystems/shooter/ShooterIO.java | 178 ++++++++++++++++-- .../shooter/ShooterIOPrototype.java | 42 ++--- .../subsystems/shooter/ShooterIOSim.java | 20 +- 3 files changed, 191 insertions(+), 49 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java index 13226a9a..e4d8f1b4 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java @@ -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) {} diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOPrototype.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOPrototype.java index a24b2f71..602f22fd 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOPrototype.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOPrototype.java @@ -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()); } } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java index 242594c6..df4bea89 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java @@ -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