From 55a3a544302c43824367d8ebef74d8142f99c3d2 Mon Sep 17 00:00:00 2001 From: Shaun Mathew <143555953+SpeedSlicer@users.noreply.github.com> Date: Sat, 4 Apr 2026 15:20:15 -0400 Subject: [PATCH 1/5] power --- .../subsystems/drive/DriveSubsystem.java | 35 ++++++++++++------- .../frc/robot/subsystems/hood/HoodIO.java | 2 ++ .../frc/robot/subsystems/hood/HoodIOReal.java | 3 +- .../frc/robot/subsystems/hood/HoodIOSim.java | 2 ++ .../frc/robot/subsystems/intake/IntakeIO.java | 2 ++ .../robot/subsystems/intake/IntakeIOReal.java | 3 +- .../robot/subsystems/intake/IntakeIOSim.java | 2 ++ .../intakeRollers/IntakeRollerIO.java | 2 ++ .../intakeRollers/IntakeRollerIOReal.java | 2 ++ .../intakeRollers/IntakeRollerIOSim.java | 2 ++ .../frc/robot/subsystems/kicker/KickerIO.java | 2 ++ .../robot/subsystems/kicker/KickerIOReal.java | 2 ++ .../robot/subsystems/kicker/KickerIOSim.java | 2 ++ .../frc/robot/subsystems/module/Module.java | 12 +++++++ .../frc/robot/subsystems/module/ModuleIO.java | 6 ++++ .../robot/subsystems/module/ModuleIOReal.java | 6 ++++ .../robot/subsystems/module/ModuleIOSim.java | 8 +++++ .../robot/subsystems/shooter/ShooterIO.java | 8 +++++ .../subsystems/shooter/ShooterIOReal.java | 7 +++- .../subsystems/shooter/ShooterIOSim.java | 7 +++- .../subsystems/spindexer/SpindexerIO.java | 2 ++ .../subsystems/spindexer/SpindexerIOReal.java | 2 ++ .../subsystems/spindexer/SpindexerIOSim.java | 4 +++ .../frc/robot/subsystems/turret/TurretIO.java | 2 ++ .../robot/subsystems/turret/TurretIOReal.java | 2 ++ .../robot/subsystems/turret/TurretIOSim.java | 3 ++ 26 files changed, 113 insertions(+), 17 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java b/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java index 34c7c837..ce5c4a51 100644 --- a/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java +++ b/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java @@ -77,19 +77,18 @@ public DriveSubsystem(Gyro gyro) { modules[3] = new Module(DriveSubsystem.getIOByMode(DriveConstants.BR), PivotId.BR); // custom format - sysIdRoutine = - new SwerveDriveSysidRoutine() - .createNewRoutine( - modules[0], - modules[1], - modules[2], - modules[3], - this, - new SysIdRoutine.Config( - Volts.per(Seconds).of(1), - Volts.of(8), - Seconds.of(15), - (state) -> Logger.recordOutput("SysIdTestState", state.toString()))); + sysIdRoutine = new SwerveDriveSysidRoutine() + .createNewRoutine( + modules[0], + modules[1], + modules[2], + modules[3], + this, + new SysIdRoutine.Config( + Volts.per(Seconds).of(1), + Volts.of(8), + Seconds.of(15), + (state) -> Logger.recordOutput("SysIdTestState", state.toString()))); // spotless format try { @@ -139,12 +138,22 @@ public void periodic() { double totalDriveCurrent = 0; double totalSteerCurrent = 0; + double totalDrawJoules = 0; + double totalDriveWattage = 0; + double totalSteerWattage = 0; for (Module module : modules) { totalDriveCurrent += module.getDriveCurrent(); totalSteerCurrent += module.getSteerCurrent(); + totalDrawJoules += module.getTotalDrawJoules(); + totalDriveWattage += module.getDriveWattage(); + totalSteerWattage += module.getSteerWattage(); } + Logger.recordOutput("Subsystems/Drive/totalDriveCurrent", totalDriveCurrent); Logger.recordOutput("Subsystems/Drive/totalSteerCurrent", totalSteerCurrent); + Logger.recordOutput("Subsystems/Drive/totalDriveWattage", totalDriveWattage); + Logger.recordOutput("Subsystems/Drive/totalSteerWattage", totalSteerWattage); + Logger.recordOutput("Subsystems/Drive/totalPowerDrawJoules", totalDrawJoules); } private void stop() { diff --git a/src/main/java/frc/robot/subsystems/hood/HoodIO.java b/src/main/java/frc/robot/subsystems/hood/HoodIO.java index fee2cc92..8e46a762 100644 --- a/src/main/java/frc/robot/subsystems/hood/HoodIO.java +++ b/src/main/java/frc/robot/subsystems/hood/HoodIO.java @@ -18,6 +18,8 @@ public class HoodIOInputs { public double motorCurrent; public double motorVoltage; public double motorTemperatureCelsius; + public double motorDrawJoules = 0; + public double motorWattage; } public default void setAngleRadians(double angle) { diff --git a/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java b/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java index 6c6e53d7..e12d1886 100644 --- a/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java +++ b/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java @@ -60,7 +60,8 @@ public void updateInputs(HoodIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorVoltage = m_motor.getAppliedOutput() * m_motor.getBusVoltage(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); - + inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; Logger.recordOutput("Subsystems/Hood/encoderPositionRaw", m_encoder.getPosition()); } diff --git a/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java b/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java index 6fb6c86b..963e1212 100644 --- a/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java +++ b/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java @@ -51,6 +51,8 @@ public void updateInputs(HoodIOInputs inputs) { inputs.angularVelocityDegreesPerSec = inputs.angularVelocityRadPerSec * 180 / Math.PI; inputs.motorCurrent = m_motor.getCurrentDrawAmps(); inputs.motorVoltage = m_motor.getInputVoltage(); + inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; inputs.motorTemperatureCelsius = 0; } } diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIO.java b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java index 1003c647..2508a132 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIO.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java @@ -12,6 +12,8 @@ public static class IntakeIOInputs { public double velocityRadPerSec; public double positionDegrees; public double velocityDegreesPerSec; + public double motorDrawJoules = 0; + public double motorWattage; } public default void updateInputs(IntakeIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java index 5b07f3b7..6626ddd6 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java @@ -86,7 +86,8 @@ public void updateInputs(IntakeIOInputs inputs) { inputs.velocityRadPerSec = m_encoder.getVelocity() * IntakeConstants.intakeEncoderToRadiansConversion; // rad/s inputs.positionDegrees = inputs.positionRadians * 180 / Math.PI; // degrees inputs.velocityDegreesPerSec = inputs.velocityRadPerSec * 180 / Math.PI; // deg/s - + inputs.motorDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W Logger.recordOutput("Subsystems/Intake/encoderPositionRaw", m_encoder.getPosition()); } } diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java index 0d96dd66..12503226 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java @@ -51,6 +51,8 @@ public void updateInputs(IntakeIOInputs inputs) { inputs.velocityRadPerSec = m_motor.getAngularVelocityRadPerSec(); // rad/s inputs.positionDegrees = inputs.positionRadians * 180 / Math.PI; inputs.velocityDegreesPerSec = inputs.velocityRadPerSec * 180 / Math.PI; + inputs.motorDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W intakeLigament.setAngle(90 - Units.radiansToDegrees(m_motor.getAngularPositionRad())); } diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java index 58299e2b..c5863a08 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java @@ -9,6 +9,8 @@ public static class IntakeRollerIOInputs { public double motorTemperatureCelsius; public double motorCurrent; public double encoderVelocityRadiansPerSecond; + public double motorDrawJoules = 0; + public double motorWattage; } public default void updateInputs(IntakeRollerIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java index 6b7f6fc3..73c5b004 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java @@ -45,5 +45,7 @@ public void updateInputs(IntakeRollerIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); // amps inputs.motorVoltage = m_motor.getAppliedOutput() * m_motor.getBusVoltage(); // volts inputs.encoderVelocityRadiansPerSecond = m_encoder.getVelocity() * 2 * Math.PI / 60; // rad/s + inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; // J + inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W } } diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java index 5d9c87fb..764e2754 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java @@ -41,5 +41,7 @@ public void updateInputs(IntakeRollerIOInputs inputs) { inputs.motorCurrent = m_motor.getCurrentDrawAmps(); // amps inputs.motorVoltage = m_motor.getInputVoltage(); // volts inputs.encoderVelocityRadiansPerSecond = m_motor.getAngularVelocityRadPerSec(); // rad/s + inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; // J + inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W } } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIO.java b/src/main/java/frc/robot/subsystems/kicker/KickerIO.java index 894208be..e4088d5b 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIO.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIO.java @@ -10,6 +10,8 @@ public class KickerIOInputs { public double motorTemperatureCelsius; public double motorVelocityRadPerSec; public double motorVelocityRPM; + public double motorDrawJoules = 0; + public double motorWattage; } public default void setVelocity(double velocity) { diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java index 2b92faf9..fca5241a 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java @@ -39,5 +39,7 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.motorVelocityRadPerSec = m_encoder.getVelocity() * 2 * Math.PI / 60; inputs.motorVelocityRPM = m_encoder.getVelocity(); + inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W } } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java index a0a3f9da..5c72f044 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java @@ -36,5 +36,7 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorTemperatureCelsius = 0; inputs.motorVelocityRadPerSec = m_motorSim.getAngularVelocityRadPerSec(); inputs.motorVelocityRPM = m_motorSim.getAngularVelocityRPM(); + inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; } } diff --git a/src/main/java/frc/robot/subsystems/module/Module.java b/src/main/java/frc/robot/subsystems/module/Module.java index a8a00866..d731aeab 100644 --- a/src/main/java/frc/robot/subsystems/module/Module.java +++ b/src/main/java/frc/robot/subsystems/module/Module.java @@ -149,4 +149,16 @@ public SwerveModulePosition getPosition() { public double getVelocity() { return inputs.driveVelocityMetersPerSecond; } + + public double getTotalDrawJoules() { + return inputs.totalDrawJoules; + } + + public double getDriveWattage() { + return inputs.driveWattage; + } + + public double getSteerWattage() { + return inputs.steerWattage; + } } diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIO.java b/src/main/java/frc/robot/subsystems/module/ModuleIO.java index 7d713737..aac31206 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIO.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIO.java @@ -26,7 +26,13 @@ public static class ModuleIOInputs { public double steerEncoderRawValue; public double steerEncoderRelative; // public int rawEncoderValue; + public double driveDrawJoules = 0; + public double steerDrawJoules = 0; + public double totalDrawJoules = 0; + public double driveWattage; + public double steerWattage; + public double totalWattage; public double[] odometryTimestamps = new double[]{}; public double[] odometryDrivePositionsMeters = new double[]{}; public Rotation2d[] odometryTurnPositions = new Rotation2d[]{}; diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java index 56e5b88b..e5ba6839 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java @@ -97,6 +97,12 @@ public void updateInputs(ModuleIOInputs inputs) { .mapToDouble((Double value) -> -(value / DriveConstants.driveGearRatio) / 60 * DriveConstants.wheelRadius * 2 * Math.PI) .toArray(); + inputs.driveDrawJoules += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; + inputs.steerDrawJoules += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; + inputs.totalDrawJoules += inputs.driveDrawJoules + inputs.steerDrawJoules; + inputs.driveWattage = inputs.driveAppliedVoltage * inputs.driveCurrentAmps; + inputs.steerWattage = inputs.steerAppliedVoltage * inputs.steerCurrentAmps; + inputs.totalDrawJoules = inputs.driveWattage + inputs.steerWattage; timestampQueue.clear(); drivePositionQueue.clear(); diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java b/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java index 5d673bd2..d93290fb 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java @@ -86,6 +86,14 @@ public void updateInputs(ModuleIOInputs inputs) { inputs.odometryDrivePositionsMeters = new double[]{inputs.drivePositionMeters}; inputs.odometryTurnPositions = new Rotation2d[]{Rotation2d.fromDegrees(inputs.steerAngleDegrees)}; inputs.driveVelocities = new double[]{inputs.driveVelocityMetersPerSecond}; + + inputs.driveDrawJoules += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; + inputs.steerDrawJoules += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; + inputs.totalDrawJoules += inputs.driveDrawJoules + inputs.steerDrawJoules; + inputs.driveWattage = inputs.driveAppliedVoltage * inputs.driveCurrentAmps; + inputs.steerWattage = inputs.steerAppliedVoltage * inputs.steerCurrentAmps; + inputs.totalDrawJoules = inputs.driveWattage + inputs.steerWattage; + } @Override diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java index a6857063..5c2707c9 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java @@ -22,6 +22,14 @@ public class ShooterIOInputs { public double followerMotorTemperatureCelsius; public double followerMotorPositionRotations; + public double leaderDrawJoules = 0; + public double followerDrawJoules = 0; + public double totalDrawJoules = 0; + + public double leaderWattage; + public double followerWattage; + public double totalWattage; + public double averageVoltage; } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java index e4f8d528..8137a726 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java @@ -77,7 +77,12 @@ public void updateInputs(ShooterIOInputs inputs) { inputs.followerMotorTemperatureCelsius = m_followerMotor.getMotorTemperature(); // celsius inputs.followerMotorCurrent = m_followerMotor.getOutputCurrent(); // amps inputs.followerMotorPositionRotations = m_followerEncoder.getPosition(); // rotations - + inputs.leaderDrawJoules += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J + inputs.followerDrawJoules += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J + inputs.totalDrawJoules += inputs.leaderDrawJoules + inputs.followerDrawJoules; // J + inputs.leaderWattage = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W + inputs.followerWattage = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W + inputs.totalWattage = inputs.leaderWattage + inputs.followerWattage; // W inputs.averageVoltage = (inputs.leaderMotorVoltage + inputs.followerMotorVoltage) / 2.0; // rad/s } } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java index 9b71becb..5384155d 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java @@ -61,7 +61,12 @@ public void updateInputs(ShooterIOInputs inputs) { inputs.followerMotorVoltage = m_motor.getInputVoltage(); inputs.followerMotorTemperatureCelsius = 0; inputs.followerMotorPositionRotations = m_motor.getAngularPositionRotations(); - + inputs.leaderDrawJoules += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J + inputs.followerDrawJoules += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J + inputs.totalDrawJoules += inputs.leaderDrawJoules + inputs.followerDrawJoules; // J + inputs.leaderWattage = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W + inputs.followerWattage = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W + inputs.totalWattage = inputs.leaderWattage + inputs.followerWattage; // W inputs.averageVoltage = m_motor.getInputVoltage(); } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java index 74ccf8c6..8b262864 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java @@ -11,6 +11,8 @@ public static class SpindexerIOInputs { public double motorCurrent = 0.0; public double motorTemperatureCelsius = 0.0; public boolean isJammed = false; + public double motorTotalDrawJoules = 0.0; + public double motorWattage; } public default void updateInputs(SpindexerIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java index 9e4d4717..dd118237 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java @@ -31,5 +31,7 @@ public void updateInputs(SpindexerIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.isJammed = m_currentEma.get() > SpindexerConstants.jamCurrentThresh; + inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java index 8d477ec1..387f6e68 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java @@ -6,6 +6,7 @@ public class SpindexerIOSim implements SpindexerIO { private final DCMotorSim m_motorSim; + public SpindexerIOSim() { DCMotor motorGearboxSim = DCMotor.getNEO(1); @@ -29,5 +30,8 @@ public void updateInputs(SpindexerIOInputs inputs) { inputs.motorCurrent = m_motorSim.getCurrentDrawAmps(); inputs.motorTemperatureCelsius = 0.0; inputs.isJammed = false; + inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + } } diff --git a/src/main/java/frc/robot/subsystems/turret/TurretIO.java b/src/main/java/frc/robot/subsystems/turret/TurretIO.java index f8203c6a..3ed69fc7 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretIO.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretIO.java @@ -15,6 +15,8 @@ public class TurretIOInputs { public double motorCurrent; public double motorVoltage; public double motorTemperatureCelsius; + public double motorTotalDrawJoules = 0; + public double motorWattage; } public default void setTurretState(ShotSetpoint setpoint) { diff --git a/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java b/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java index 7194fbdd..04367e9e 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java @@ -73,6 +73,8 @@ public void updateInputs(TurretIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorVoltage = m_motor.getBusVoltage() * m_motor.getAppliedOutput(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); + inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; Logger.recordOutput("Subsystems/Turret/encoderPositionRawVolts", m_encoder.getPosition()); Logger.recordOutput("Subsystems/Turret/encoderVelocityRawVoltsPerSecond", m_encoder.getVelocity()); diff --git a/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java b/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java index c1f37407..39e0a346 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java @@ -44,5 +44,8 @@ public void updateInputs(TurretIOInputs inputs) { inputs.motorCurrent = m_motor.getCurrentDrawAmps(); inputs.motorVoltage = m_motor.getInputVoltage(); inputs.motorTemperatureCelsius = 0; + inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + } } From be57e1371541c1f8bc0a10dd6159e165bcdb8c2c Mon Sep 17 00:00:00 2001 From: Shaun Mathew <143555953+SpeedSlicer@users.noreply.github.com> Date: Wed, 22 Apr 2026 19:28:35 -0400 Subject: [PATCH 2/5] pushg --- .../java/frc/robot/subsystems/intake/IntakeIO.java | 4 ++-- .../frc/robot/subsystems/intake/IntakeIOReal.java | 4 ++-- .../frc/robot/subsystems/intake/IntakeIOSim.java | 4 ++-- .../subsystems/intakeRollers/IntakeRollerIO.java | 4 ++-- .../intakeRollers/IntakeRollerIOReal.java | 5 +++-- .../intakeRollers/IntakeRollerIOSim.java | 4 ++-- .../java/frc/robot/subsystems/kicker/KickerIO.java | 4 ++-- .../frc/robot/subsystems/kicker/KickerIOReal.java | 4 ++-- .../frc/robot/subsystems/kicker/KickerIOSim.java | 4 ++-- .../java/frc/robot/subsystems/module/Module.java | 6 +++--- .../java/frc/robot/subsystems/module/ModuleIO.java | 12 ++++++------ .../frc/robot/subsystems/module/ModuleIOReal.java | 12 ++++++------ .../frc/robot/subsystems/module/ModuleIOSim.java | 12 ++++++------ .../frc/robot/subsystems/shooter/ShooterIO.java | 12 ++++++------ .../robot/subsystems/shooter/ShooterIOReal.java | 14 ++++++++------ .../frc/robot/subsystems/shooter/ShooterIOSim.java | 12 ++++++------ .../robot/subsystems/spindexer/SpindexerIO.java | 4 ++-- .../subsystems/spindexer/SpindexerIOReal.java | 4 ++-- .../robot/subsystems/spindexer/SpindexerIOSim.java | 4 ++-- 19 files changed, 66 insertions(+), 63 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIO.java b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java index 891c6a7d..7f0b15ad 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIO.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java @@ -12,8 +12,8 @@ public static class IntakeIOInputs { public double velocityRadPerSec; public double positionDegrees; public double velocityDegreesPerSec; - public double motorDrawJoules = 0; - public double motorWattage; + public double motorTotalEnergy = 0; + public double motorPower; } public default void updateInputs(IntakeIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java index 36263b36..ec136760 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOReal.java @@ -107,8 +107,8 @@ public void updateInputs(IntakeIOInputs inputs) { inputs.velocityRadPerSec = getVelocityRadPerSec(); // rad/s inputs.positionDegrees = inputs.positionRadians * 180 / Math.PI; // degrees inputs.velocityDegreesPerSec = inputs.velocityRadPerSec * 180 / Math.PI; // deg/s - inputs.motorDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W Logger.recordOutput("Subsystems/Intake/encoderPositionRaw", m_encoder.getPosition()); } } diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java index b9624a99..68c9c59d 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java @@ -51,8 +51,8 @@ public void updateInputs(IntakeIOInputs inputs) { inputs.velocityRadPerSec = m_motor.getAngularVelocityRadPerSec(); // rad/s inputs.positionDegrees = inputs.positionRadians * 180 / Math.PI; inputs.velocityDegreesPerSec = inputs.velocityRadPerSec * 180 / Math.PI; - inputs.motorDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W intakeLigament.setAngle(90 - Units.radiansToDegrees(m_motor.getAngularPositionRad())); } diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java index c5863a08..0d77f3d9 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIO.java @@ -9,8 +9,8 @@ public static class IntakeRollerIOInputs { public double motorTemperatureCelsius; public double motorCurrent; public double encoderVelocityRadiansPerSecond; - public double motorDrawJoules = 0; - public double motorWattage; + public double motorTotalEnergy = 0; + public double motorPower; } public default void updateInputs(IntakeRollerIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java index 73c5b004..ccb7fd69 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java @@ -45,7 +45,8 @@ public void updateInputs(IntakeRollerIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); // amps inputs.motorVoltage = m_motor.getAppliedOutput() * m_motor.getBusVoltage(); // volts inputs.encoderVelocityRadiansPerSecond = m_encoder.getVelocity() * 2 * Math.PI / 60; // rad/s - inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; // J - inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W + inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; // J + inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W } } + \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java index 764e2754..d681b015 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOSim.java @@ -41,7 +41,7 @@ public void updateInputs(IntakeRollerIOInputs inputs) { inputs.motorCurrent = m_motor.getCurrentDrawAmps(); // amps inputs.motorVoltage = m_motor.getInputVoltage(); // volts inputs.encoderVelocityRadiansPerSecond = m_motor.getAngularVelocityRadPerSec(); // rad/s - inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; // J - inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W + inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; // J + inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W } } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIO.java b/src/main/java/frc/robot/subsystems/kicker/KickerIO.java index e4088d5b..bdd4ae2f 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIO.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIO.java @@ -10,8 +10,8 @@ public class KickerIOInputs { public double motorTemperatureCelsius; public double motorVelocityRadPerSec; public double motorVelocityRPM; - public double motorDrawJoules = 0; - public double motorWattage; + public double motorTotalEnergy = 0; + public double motorPower; } public default void setVelocity(double velocity) { diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java index 5b9770c7..f347bc67 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java @@ -39,7 +39,7 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.motorVelocityRadPerSec = m_encoder.getVelocity() * 2 * Math.PI / 60; inputs.motorVelocityRPM = m_encoder.getVelocity(); - inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; // W + inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W } } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java index 5c72f044..56ee2049 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java @@ -36,7 +36,7 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorTemperatureCelsius = 0; inputs.motorVelocityRadPerSec = m_motorSim.getAngularVelocityRadPerSec(); inputs.motorVelocityRPM = m_motorSim.getAngularVelocityRPM(); - inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorCurrent; + inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; } } diff --git a/src/main/java/frc/robot/subsystems/module/Module.java b/src/main/java/frc/robot/subsystems/module/Module.java index bb00a5de..bdd1f6c8 100644 --- a/src/main/java/frc/robot/subsystems/module/Module.java +++ b/src/main/java/frc/robot/subsystems/module/Module.java @@ -156,14 +156,14 @@ public double getVelocity() { } public double getTotalDrawJoules() { - return inputs.totalDrawJoules; + return inputs.totalEnergy; } public double getDriveWattage() { - return inputs.driveWattage; + return inputs.drivePower; } public double getSteerWattage() { - return inputs.steerWattage; + return inputs.steerPower; } } diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIO.java b/src/main/java/frc/robot/subsystems/module/ModuleIO.java index aac31206..72f3cc0c 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIO.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIO.java @@ -26,13 +26,13 @@ public static class ModuleIOInputs { public double steerEncoderRawValue; public double steerEncoderRelative; // public int rawEncoderValue; - public double driveDrawJoules = 0; - public double steerDrawJoules = 0; - public double totalDrawJoules = 0; + public double driveTotalEnergy = 0; + public double steerTotalEnergy = 0; + public double totalEnergy = 0; - public double driveWattage; - public double steerWattage; - public double totalWattage; + public double drivePower; + public double steerPower; + public double totalPower; public double[] odometryTimestamps = new double[]{}; public double[] odometryDrivePositionsMeters = new double[]{}; public Rotation2d[] odometryTurnPositions = new Rotation2d[]{}; diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java index e5ba6839..5f546410 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java @@ -97,12 +97,12 @@ public void updateInputs(ModuleIOInputs inputs) { .mapToDouble((Double value) -> -(value / DriveConstants.driveGearRatio) / 60 * DriveConstants.wheelRadius * 2 * Math.PI) .toArray(); - inputs.driveDrawJoules += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; - inputs.steerDrawJoules += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; - inputs.totalDrawJoules += inputs.driveDrawJoules + inputs.steerDrawJoules; - inputs.driveWattage = inputs.driveAppliedVoltage * inputs.driveCurrentAmps; - inputs.steerWattage = inputs.steerAppliedVoltage * inputs.steerCurrentAmps; - inputs.totalDrawJoules = inputs.driveWattage + inputs.steerWattage; + inputs.driveTotalEnergy += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; + inputs.steerTotalEnergy += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; + inputs.totalEnergy = inputs.driveTotalEnergy + inputs.steerTotalEnergy; + inputs.drivePower = inputs.driveAppliedVoltage * inputs.driveCurrentAmps; + inputs.steerPower = inputs.steerAppliedVoltage * inputs.steerCurrentAmps; + inputs.totalPower = inputs.drivePower + inputs.steerPower; timestampQueue.clear(); drivePositionQueue.clear(); diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java b/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java index d93290fb..79b0959b 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIOSim.java @@ -87,12 +87,12 @@ public void updateInputs(ModuleIOInputs inputs) { inputs.odometryTurnPositions = new Rotation2d[]{Rotation2d.fromDegrees(inputs.steerAngleDegrees)}; inputs.driveVelocities = new double[]{inputs.driveVelocityMetersPerSecond}; - inputs.driveDrawJoules += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; - inputs.steerDrawJoules += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; - inputs.totalDrawJoules += inputs.driveDrawJoules + inputs.steerDrawJoules; - inputs.driveWattage = inputs.driveAppliedVoltage * inputs.driveCurrentAmps; - inputs.steerWattage = inputs.steerAppliedVoltage * inputs.steerCurrentAmps; - inputs.totalDrawJoules = inputs.driveWattage + inputs.steerWattage; + inputs.driveTotalEnergy += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; + inputs.steerTotalEnergy += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; + inputs.totalEnergy = inputs.driveTotalEnergy + inputs.steerTotalEnergy; + inputs.drivePower = inputs.driveAppliedVoltage * inputs.driveCurrentAmps; + inputs.steerPower = inputs.steerAppliedVoltage * inputs.steerCurrentAmps; + inputs.totalPower = inputs.drivePower + inputs.steerPower; } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java index 59cf85d9..1134aed2 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java @@ -22,13 +22,13 @@ public class ShooterIOInputs { public double followerMotorTemperatureCelsius; public double followerMotorPositionRotations; - public double leaderDrawJoules = 0; - public double followerDrawJoules = 0; - public double totalDrawJoules = 0; + public double leaderTotalEnergy = 0; + public double followerTotalEnergy = 0; + public double totalEnergy = 0; - public double leaderWattage; - public double followerWattage; - public double totalWattage; + public double leaderPower; + public double followerPower; + public double totalPower; public double averageVoltage; } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java index 63839b0c..0265f7da 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java @@ -89,12 +89,14 @@ public void updateInputs(ShooterIOInputs inputs) { inputs.followerMotorTemperatureCelsius = m_followerMotor.getMotorTemperature(); // celsius inputs.followerMotorCurrent = m_followerMotor.getOutputCurrent(); // amps inputs.followerMotorPositionRotations = m_followerEncoder.getPosition(); // rotations - inputs.leaderDrawJoules += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J - inputs.followerDrawJoules += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J - inputs.totalDrawJoules += inputs.leaderDrawJoules + inputs.followerDrawJoules; // J - inputs.leaderWattage = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W - inputs.followerWattage = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W - inputs.totalWattage = inputs.leaderWattage + inputs.followerWattage; // W + + inputs.leaderTotalEnergy += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J + inputs.followerTotalEnergy += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J + inputs.totalEnergy = inputs.leaderTotalEnergy + inputs.followerTotalEnergy; // J + inputs.leaderPower = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W + inputs.followerPower = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W + inputs.totalPower = inputs.leaderPower + inputs.followerPower; // W + inputs.averageVoltage = (inputs.leaderMotorVoltage + inputs.followerMotorVoltage) / 2.0; // rad/s } } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java index 02077c88..e8801e4a 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java @@ -61,12 +61,12 @@ public void updateInputs(ShooterIOInputs inputs) { inputs.followerMotorVoltage = m_motor.getInputVoltage(); inputs.followerMotorTemperatureCelsius = 0; inputs.followerMotorPositionRotations = m_motor.getAngularPositionRotations(); - inputs.leaderDrawJoules += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J - inputs.followerDrawJoules += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J - inputs.totalDrawJoules += inputs.leaderDrawJoules + inputs.followerDrawJoules; // J - inputs.leaderWattage = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W - inputs.followerWattage = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W - inputs.totalWattage = inputs.leaderWattage + inputs.followerWattage; // W + inputs.leaderTotalEnergy += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J + inputs.followerTotalEnergy += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J + inputs.totalEnergy = inputs.leaderTotalEnergy + inputs.followerTotalEnergy; // J + inputs.leaderPower = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W + inputs.followerPower = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W + inputs.totalPower = inputs.leaderPower + inputs.followerPower; // W inputs.averageVoltage = m_motor.getInputVoltage(); } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java index 8b262864..5cbcf13e 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java @@ -11,8 +11,8 @@ public static class SpindexerIOInputs { public double motorCurrent = 0.0; public double motorTemperatureCelsius = 0.0; public boolean isJammed = false; - public double motorTotalDrawJoules = 0.0; - public double motorWattage; + public double motorEnergyDraw = 0.0; + public double motorPower; } public default void updateInputs(SpindexerIOInputs inputs) { diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java index dd118237..d11f9cfa 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java @@ -31,7 +31,7 @@ public void updateInputs(SpindexerIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.isJammed = m_currentEma.get() > SpindexerConstants.jamCurrentThresh; - inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + inputs.motorEnergyDraw += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java index 387f6e68..25207a5f 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java @@ -30,8 +30,8 @@ public void updateInputs(SpindexerIOInputs inputs) { inputs.motorCurrent = m_motorSim.getCurrentDrawAmps(); inputs.motorTemperatureCelsius = 0.0; inputs.isJammed = false; - inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + inputs.motorEnergyDraw += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; } } From 6797b830b153c6c7dbc0b08999ea0e5b4a267f09 Mon Sep 17 00:00:00 2001 From: Shaun Mathew <143555953+SpeedSlicer@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:23:40 -0400 Subject: [PATCH 3/5] yessir --- src/main/java/frc/robot/subsystems/hood/HoodIO.java | 4 ++-- src/main/java/frc/robot/subsystems/hood/HoodIOReal.java | 4 ++-- src/main/java/frc/robot/subsystems/hood/HoodIOSim.java | 4 ++-- src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java | 3 ++- src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java | 1 + src/main/java/frc/robot/subsystems/module/ModuleIOReal.java | 1 + src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java | 2 ++ src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java | 2 +- .../java/frc/robot/subsystems/spindexer/SpindexerIOReal.java | 2 +- .../java/frc/robot/subsystems/spindexer/SpindexerIOSim.java | 2 +- src/main/java/frc/robot/subsystems/turret/TurretIO.java | 4 ++-- src/main/java/frc/robot/subsystems/turret/TurretIOReal.java | 4 ++-- src/main/java/frc/robot/subsystems/turret/TurretIOSim.java | 4 ++-- 13 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/hood/HoodIO.java b/src/main/java/frc/robot/subsystems/hood/HoodIO.java index 8e46a762..992abcec 100644 --- a/src/main/java/frc/robot/subsystems/hood/HoodIO.java +++ b/src/main/java/frc/robot/subsystems/hood/HoodIO.java @@ -18,8 +18,8 @@ public class HoodIOInputs { public double motorCurrent; public double motorVoltage; public double motorTemperatureCelsius; - public double motorDrawJoules = 0; - public double motorWattage; + public double motorTotalEnergy = 0; + public double motorPower; } public default void setAngleRadians(double angle) { diff --git a/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java b/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java index e12d1886..e1349ad0 100644 --- a/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java +++ b/src/main/java/frc/robot/subsystems/hood/HoodIOReal.java @@ -60,8 +60,8 @@ public void updateInputs(HoodIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorVoltage = m_motor.getAppliedOutput() * m_motor.getBusVoltage(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); - inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; Logger.recordOutput("Subsystems/Hood/encoderPositionRaw", m_encoder.getPosition()); } diff --git a/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java b/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java index 963e1212..f929933b 100644 --- a/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java +++ b/src/main/java/frc/robot/subsystems/hood/HoodIOSim.java @@ -51,8 +51,8 @@ public void updateInputs(HoodIOInputs inputs) { inputs.angularVelocityDegreesPerSec = inputs.angularVelocityRadPerSec * 180 / Math.PI; inputs.motorCurrent = m_motor.getCurrentDrawAmps(); inputs.motorVoltage = m_motor.getInputVoltage(); - inputs.motorDrawJoules = inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; inputs.motorTemperatureCelsius = 0; } } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java index f347bc67..342fa830 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java @@ -39,7 +39,8 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.motorVelocityRadPerSec = m_encoder.getVelocity() * 2 * Math.PI / 60; inputs.motorVelocityRPM = m_encoder.getVelocity(); - inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; + + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W } } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java index 56ee2049..eaa7c852 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java @@ -38,5 +38,6 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorVelocityRPM = m_motorSim.getAngularVelocityRPM(); inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; + } } diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java index 5f546410..bae94927 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java @@ -97,6 +97,7 @@ public void updateInputs(ModuleIOInputs inputs) { .mapToDouble((Double value) -> -(value / DriveConstants.driveGearRatio) / 60 * DriveConstants.wheelRadius * 2 * Math.PI) .toArray(); + inputs.driveTotalEnergy += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; inputs.steerTotalEnergy += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; inputs.totalEnergy = inputs.driveTotalEnergy + inputs.steerTotalEnergy; diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java index e8801e4a..d57c261f 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java @@ -61,12 +61,14 @@ public void updateInputs(ShooterIOInputs inputs) { inputs.followerMotorVoltage = m_motor.getInputVoltage(); inputs.followerMotorTemperatureCelsius = 0; inputs.followerMotorPositionRotations = m_motor.getAngularPositionRotations(); + inputs.leaderTotalEnergy += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J inputs.followerTotalEnergy += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J inputs.totalEnergy = inputs.leaderTotalEnergy + inputs.followerTotalEnergy; // J inputs.leaderPower = inputs.leaderMotorVoltage * inputs.leaderMotorCurrent; // W inputs.followerPower = inputs.followerMotorVoltage * inputs.followerMotorCurrent; // W inputs.totalPower = inputs.leaderPower + inputs.followerPower; // W + inputs.averageVoltage = m_motor.getInputVoltage(); } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java index 5cbcf13e..a8eec628 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java @@ -11,7 +11,7 @@ public static class SpindexerIOInputs { public double motorCurrent = 0.0; public double motorTemperatureCelsius = 0.0; public boolean isJammed = false; - public double motorEnergyDraw = 0.0; + public double motorTotalEnergy = 0.0; public double motorPower; } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java index d11f9cfa..704aa88f 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOReal.java @@ -31,7 +31,7 @@ public void updateInputs(SpindexerIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.isJammed = m_currentEma.get() > SpindexerConstants.jamCurrentThresh; - inputs.motorEnergyDraw += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java index 25207a5f..1f1e6573 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIOSim.java @@ -30,7 +30,7 @@ public void updateInputs(SpindexerIOInputs inputs) { inputs.motorCurrent = m_motorSim.getCurrentDrawAmps(); inputs.motorTemperatureCelsius = 0.0; inputs.isJammed = false; - inputs.motorEnergyDraw += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; } diff --git a/src/main/java/frc/robot/subsystems/turret/TurretIO.java b/src/main/java/frc/robot/subsystems/turret/TurretIO.java index 3ed69fc7..b26a8210 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretIO.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretIO.java @@ -15,8 +15,8 @@ public class TurretIOInputs { public double motorCurrent; public double motorVoltage; public double motorTemperatureCelsius; - public double motorTotalDrawJoules = 0; - public double motorWattage; + public double motorTotalEnergy = 0; + public double motorPower; } public default void setTurretState(ShotSetpoint setpoint) { diff --git a/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java b/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java index 04367e9e..6da8f9ce 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretIOReal.java @@ -73,8 +73,8 @@ public void updateInputs(TurretIOInputs inputs) { inputs.motorCurrent = m_motor.getOutputCurrent(); inputs.motorVoltage = m_motor.getBusVoltage() * m_motor.getAppliedOutput(); inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); - inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; Logger.recordOutput("Subsystems/Turret/encoderPositionRawVolts", m_encoder.getPosition()); Logger.recordOutput("Subsystems/Turret/encoderVelocityRawVoltsPerSecond", m_encoder.getVelocity()); diff --git a/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java b/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java index 39e0a346..52ffa4b7 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretIOSim.java @@ -44,8 +44,8 @@ public void updateInputs(TurretIOInputs inputs) { inputs.motorCurrent = m_motor.getCurrentDrawAmps(); inputs.motorVoltage = m_motor.getInputVoltage(); inputs.motorTemperatureCelsius = 0; - inputs.motorTotalDrawJoules += inputs.motorCurrent * inputs.motorVoltage * 0.02; - inputs.motorWattage = inputs.motorCurrent * inputs.motorVoltage; + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorPower = inputs.motorCurrent * inputs.motorVoltage; } } From f61d0e1913793eb034e8d28f0c5581b3b926cc97 Mon Sep 17 00:00:00 2001 From: Shaun Mathew <143555953+SpeedSlicer@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:25:06 -0400 Subject: [PATCH 4/5] representatives from the planet mars horrified humans drink WATER, what happens next is shocking! --- src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java | 2 +- .../frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java | 1 - src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java | 2 +- src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java | 2 +- src/main/java/frc/robot/subsystems/module/ModuleIOReal.java | 2 +- src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java index 68c9c59d..8d687476 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java @@ -51,7 +51,7 @@ public void updateInputs(IntakeIOInputs inputs) { inputs.velocityRadPerSec = m_motor.getAngularVelocityRadPerSec(); // rad/s inputs.positionDegrees = inputs.positionRadians * 180 / Math.PI; inputs.velocityDegreesPerSec = inputs.velocityRadPerSec * 180 / Math.PI; - inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W intakeLigament.setAngle(90 - Units.radiansToDegrees(m_motor.getAngularPositionRad())); diff --git a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java index ccb7fd69..15e2d879 100644 --- a/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java +++ b/src/main/java/frc/robot/subsystems/intakeRollers/IntakeRollerIOReal.java @@ -49,4 +49,3 @@ public void updateInputs(IntakeRollerIOInputs inputs) { inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W } } - \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java index 342fa830..88689721 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java @@ -39,7 +39,7 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorTemperatureCelsius = m_motor.getMotorTemperature(); inputs.motorVelocityRadPerSec = m_encoder.getVelocity() * 2 * Math.PI / 60; inputs.motorVelocityRPM = m_encoder.getVelocity(); - + inputs.motorTotalEnergy += inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; // W } diff --git a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java index eaa7c852..2cd75225 100644 --- a/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java +++ b/src/main/java/frc/robot/subsystems/kicker/KickerIOSim.java @@ -38,6 +38,6 @@ public void updateInputs(KickerIOInputs inputs) { inputs.motorVelocityRPM = m_motorSim.getAngularVelocityRPM(); inputs.motorTotalEnergy = inputs.motorCurrent * inputs.motorVoltage * 0.02; inputs.motorPower = inputs.motorVoltage * inputs.motorCurrent; - + } } diff --git a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java index bae94927..01f0b1c2 100644 --- a/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java +++ b/src/main/java/frc/robot/subsystems/module/ModuleIOReal.java @@ -97,7 +97,7 @@ public void updateInputs(ModuleIOInputs inputs) { .mapToDouble((Double value) -> -(value / DriveConstants.driveGearRatio) / 60 * DriveConstants.wheelRadius * 2 * Math.PI) .toArray(); - + inputs.driveTotalEnergy += inputs.driveAppliedVoltage * inputs.driveCurrentAmps * 0.02; inputs.steerTotalEnergy += inputs.steerAppliedVoltage * inputs.steerCurrentAmps * 0.02; inputs.totalEnergy = inputs.driveTotalEnergy + inputs.steerTotalEnergy; diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java index d57c261f..a09982eb 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java @@ -61,7 +61,7 @@ public void updateInputs(ShooterIOInputs inputs) { inputs.followerMotorVoltage = m_motor.getInputVoltage(); inputs.followerMotorTemperatureCelsius = 0; inputs.followerMotorPositionRotations = m_motor.getAngularPositionRotations(); - + inputs.leaderTotalEnergy += inputs.leaderMotorVoltage * inputs.leaderMotorCurrent * 0.02; // J inputs.followerTotalEnergy += inputs.followerMotorVoltage * inputs.followerMotorCurrent * 0.02; // J inputs.totalEnergy = inputs.leaderTotalEnergy + inputs.followerTotalEnergy; // J From d430548b9c5e58b77346868eaf231e19007a6a6d Mon Sep 17 00:00:00 2001 From: Shaun Mathew <143555953+SpeedSlicer@users.noreply.github.com> Date: Thu, 23 Apr 2026 05:26:12 -0400 Subject: [PATCH 5/5] yes --- .../java/frc/robot/subsystems/drive/DriveSubsystem.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java b/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java index bde59451..8593c422 100644 --- a/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java +++ b/src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java @@ -150,9 +150,9 @@ public void periodic() { Logger.recordOutput("Subsystems/Drive/totalDriveCurrent", totalDriveCurrent); Logger.recordOutput("Subsystems/Drive/totalSteerCurrent", totalSteerCurrent); - Logger.recordOutput("Subsystems/Drive/totalDriveWattage", totalDriveWattage); - Logger.recordOutput("Subsystems/Drive/totalSteerWattage", totalSteerWattage); - Logger.recordOutput("Subsystems/Drive/totalPowerDrawJoules", totalDrawJoules); + Logger.recordOutput("Subsystems/Drive/totalDrivePower", totalDriveWattage); + Logger.recordOutput("Subsystems/Drive/totalSteerPower", totalSteerWattage); + Logger.recordOutput("Subsystems/Drive/totalEnergy", totalDrawJoules); } private void stop() {