From 52fc9ccdb563942a4d4bebaf9c2a48903897aca6 Mon Sep 17 00:00:00 2001 From: 00magikarp <94652654+00magikarp@users.noreply.github.com> Date: Sun, 15 Mar 2026 20:43:41 -0400 Subject: [PATCH] add logs for shooter torquecurrent --- .../kotlin/com/team4099/robot2026/Robot.kt | 1 - .../com/team4099/robot2026/RobotContainer.kt | 20 +++++----- .../superstructure/Superstructure.kt | 1 - .../superstructure/shooter/ShooterIO.kt | 38 +++++++++++-------- .../superstructure/shooter/ShooterIOSim.kt | 2 + .../superstructure/shooter/ShooterIOTalon.kt | 8 ++++ 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/com/team4099/robot2026/Robot.kt b/src/main/kotlin/com/team4099/robot2026/Robot.kt index 7adb2998..21192cab 100644 --- a/src/main/kotlin/com/team4099/robot2026/Robot.kt +++ b/src/main/kotlin/com/team4099/robot2026/Robot.kt @@ -43,7 +43,6 @@ import org.littletonrobotics.junction.wpilog.WPILOGWriter import org.team4099.lib.units.base.Time import org.team4099.lib.units.base.inMilliseconds import org.team4099.lib.units.base.seconds -import org.team4099.lib.units.derived.inDegrees object Robot : LoggedRobot() { val logFolderAlert = diff --git a/src/main/kotlin/com/team4099/robot2026/RobotContainer.kt b/src/main/kotlin/com/team4099/robot2026/RobotContainer.kt index 6386a6e0..d8fd6e59 100644 --- a/src/main/kotlin/com/team4099/robot2026/RobotContainer.kt +++ b/src/main/kotlin/com/team4099/robot2026/RobotContainer.kt @@ -259,16 +259,16 @@ object RobotContainer { setOf(superstructure)), WaitCommand(0.1)))) ControlBoard.forceIntakeFullDown.whileTrue( - RepeatCommand( - SequentialCommandGroup( - Commands.runOnce({ - intakeOverridingAngle = - max(IntakeConstants.PIVOT_MIN_ANGLE, intakeOverridingAngle - 10.degrees) - }), - Commands.defer( - { superstructure.requestForceIntakeCommand(intakeOverridingAngle) }, - setOf(superstructure)), - WaitCommand(0.1)))) + RepeatCommand( + SequentialCommandGroup( + Commands.runOnce({ + intakeOverridingAngle = + max(IntakeConstants.PIVOT_MIN_ANGLE, intakeOverridingAngle - 10.degrees) + }), + Commands.defer( + { superstructure.requestForceIntakeCommand(intakeOverridingAngle) }, + setOf(superstructure)), + WaitCommand(0.1)))) ControlBoard.rotateTrench.whileTrue( TargetAngleCommand( diff --git a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/Superstructure.kt b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/Superstructure.kt index a2ce2c9e..19dd9257 100644 --- a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/Superstructure.kt +++ b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/Superstructure.kt @@ -29,7 +29,6 @@ import org.team4099.lib.units.base.Length import org.team4099.lib.units.base.Time import org.team4099.lib.units.base.inMilliseconds import org.team4099.lib.units.derived.Angle -import org.team4099.lib.units.derived.inDegrees import org.team4099.lib.units.inMetersPerSecond import org.team4099.lib.units.max diff --git a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIO.kt b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIO.kt index 1c87f868..b937dcf0 100644 --- a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIO.kt +++ b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIO.kt @@ -32,6 +32,7 @@ interface ShooterIO { var shooterLeaderVoltage = 0.0.volts var shooterLeaderSupplyCurrent = 0.0.amps var shooterLeaderStatorCurrent = 0.0.amps + var shooterLeaderTorqueCurrent = 0.0.amps var shooterLeaderTemperature = 0.0.celsius var shooterLeaderVelocity = 0.0.rotations.perMinute var shooterLeaderAcceleration = 0.0.rotations.perMinute.perMinute @@ -40,33 +41,34 @@ interface ShooterIO { var shooterFollowerVoltage = 0.0.volts var shooterFollowerSupplyCurrent = 0.0.amps var shooterFollowerStatorCurrent = 0.0.amps + var shooterFollowerTorqueCurrent = 0.0.amps var shooterFollowerTemperature = 0.0.celsius var shooterFollowerVelocity = 0.0.rotations.perMinute var shooterFollowerAcceleration = 0.0.rotations.perMinute.perMinute - override fun toLog(table: LogTable?) { - + override fun toLog(table: LogTable) { // leader - table?.put("ShooterLeaderVoltage", shooterLeaderVoltage.inVolts) - table?.put("ShooterLeaderSupplyCurrent", shooterLeaderSupplyCurrent.inAmperes) - table?.put("ShooterLeaderStatorCurrent", shooterLeaderStatorCurrent.inAmperes) - table?.put("ShooterLeaderTemperature", shooterLeaderTemperature.inCelsius) - table?.put("ShooterLeaderVelocityRPM", shooterLeaderVelocity.inRotationsPerMinute) - table?.put( + table.put("ShooterLeaderVoltage", shooterLeaderVoltage.inVolts) + table.put("ShooterLeaderSupplyCurrent", shooterLeaderSupplyCurrent.inAmperes) + table.put("ShooterLeaderStatorCurrent", shooterLeaderStatorCurrent.inAmperes) + table.put("ShooterLeaderTorqueCurrent", shooterLeaderTorqueCurrent.inAmperes) + table.put("ShooterLeaderTemperature", shooterLeaderTemperature.inCelsius) + table.put("ShooterLeaderVelocityRPM", shooterLeaderVelocity.inRotationsPerMinute) + table.put( "ShooterLeaderAccelerationRPMPM", shooterLeaderAcceleration.inRotationsPerMinutePerMinute) // follower - table?.put("ShooterFollowerVoltage", shooterFollowerVoltage.inVolts) - table?.put("ShooterFollowerSupplyCurrent", shooterFollowerSupplyCurrent.inAmperes) - table?.put("ShooterFollowerStatorCurrent", shooterFollowerStatorCurrent.inAmperes) - table?.put("ShooterFollowerTemperature", shooterFollowerTemperature.inCelsius) - table?.put("ShooterFollowerVelocityRPM", shooterFollowerVelocity.inRotationsPerMinute) - table?.put( + table.put("ShooterFollowerVoltage", shooterFollowerVoltage.inVolts) + table.put("ShooterFollowerSupplyCurrent", shooterFollowerSupplyCurrent.inAmperes) + table.put("ShooterFollowerStatorCurrent", shooterFollowerStatorCurrent.inAmperes) + table.put("ShooterFollowerTorqueCurrent", shooterFollowerTorqueCurrent.inAmperes) + table.put("ShooterFollowerTemperature", shooterFollowerTemperature.inCelsius) + table.put("ShooterFollowerVelocityRPM", shooterFollowerVelocity.inRotationsPerMinute) + table.put( "ShooterFollowerAccelerationRPMPM", shooterFollowerAcceleration.inRotationsPerMinutePerMinute) } override fun fromLog(table: LogTable) { - // leader table.get("ShooterLeaderVoltage", shooterLeaderVoltage.inVolts).let { shooterLeaderVoltage = it.volts @@ -77,6 +79,9 @@ interface ShooterIO { table.get("ShooterLeaderStatorCurrent", shooterLeaderStatorCurrent.inAmperes).let { shooterLeaderStatorCurrent = it.amps } + table.get("ShooterLeaderTorqueCurrent", shooterLeaderTorqueCurrent.inAmperes).let { + shooterLeaderTorqueCurrent = it.amps + } table.get("ShooterLeaderTemperature", shooterLeaderTemperature.inCelsius).let { shooterLeaderTemperature = it.celsius } @@ -98,6 +103,9 @@ interface ShooterIO { table.get("ShooterFollowerStatorCurrent", shooterFollowerStatorCurrent.inAmperes).let { shooterFollowerStatorCurrent = it.amps } + table.get("ShooterFollowerTorqueCurrent", shooterFollowerTorqueCurrent.inAmperes).let { + shooterFollowerTorqueCurrent = it.amps + } table.get("ShooterFollowerTemperature", shooterFollowerTemperature.inCelsius).let { shooterFollowerTemperature = it.celsius } diff --git a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOSim.kt b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOSim.kt index 5e678a1f..69b832e1 100644 --- a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOSim.kt +++ b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOSim.kt @@ -55,6 +55,7 @@ object ShooterIOSim : ShooterIO { inputs.shooterLeaderVoltage = shooterSim.inputVoltage.volts inputs.shooterLeaderSupplyCurrent = 0.0.amps inputs.shooterLeaderStatorCurrent = shooterSim.currentDrawAmps.amps + inputs.shooterLeaderTorqueCurrent = shooterSim.currentDrawAmps.amps.absoluteValue inputs.shooterLeaderTemperature = 0.0.celsius inputs.shooterFollowerVelocity = shooterSim.angularVelocityRadPerSec.radians.perSecond @@ -63,6 +64,7 @@ object ShooterIOSim : ShooterIO { inputs.shooterFollowerVoltage = shooterSim.inputVoltage.volts inputs.shooterFollowerSupplyCurrent = 0.0.amps inputs.shooterFollowerStatorCurrent = shooterSim.currentDrawAmps.amps + inputs.shooterFollowerTorqueCurrent = shooterSim.currentDrawAmps.amps.absoluteValue inputs.shooterFollowerTemperature = 0.0.celsius } diff --git a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOTalon.kt b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOTalon.kt index b5531ff2..9ee16011 100644 --- a/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOTalon.kt +++ b/src/main/kotlin/com/team4099/robot2026/subsystems/superstructure/shooter/ShooterIOTalon.kt @@ -60,6 +60,7 @@ object ShooterIOTalon : ShooterIO { followerTalon, ShooterConstants.GEAR_RATIO, ShooterConstants.VOLTAGE_COMPENSATION) private var leaderStatorCurrentSignal: StatusSignal + private var leaderTorqueCurrentSignal: StatusSignal private var leaderSupplyCurrentSignal: StatusSignal private var leaderTempSignal: StatusSignal private var leaderVoltageSignal: StatusSignal @@ -67,6 +68,7 @@ object ShooterIOTalon : ShooterIO { private var leaderVelocitySignal: StatusSignal private var followerStatorCurrentSignal: StatusSignal + private var followerTorqueCurrentSignal: StatusSignal private var followerSupplyCurrentSignal: StatusSignal private var followerTempSignal: StatusSignal private var followerVoltageSignal: StatusSignal @@ -88,6 +90,7 @@ object ShooterIOTalon : ShooterIO { followerTalon.configurator.apply(configs) leaderSupplyCurrentSignal = leaderTalon.supplyCurrent + leaderTorqueCurrentSignal = leaderTalon.torqueCurrent leaderStatorCurrentSignal = leaderTalon.statorCurrent leaderVelocitySignal = leaderTalon.velocity leaderTempSignal = leaderTalon.deviceTemp @@ -95,6 +98,7 @@ object ShooterIOTalon : ShooterIO { leaderAccelSignal = leaderTalon.acceleration followerSupplyCurrentSignal = followerTalon.supplyCurrent + followerTorqueCurrentSignal = followerTalon.torqueCurrent followerStatorCurrentSignal = followerTalon.statorCurrent followerVelocitySignal = followerTalon.velocity followerTempSignal = followerTalon.deviceTemp @@ -109,11 +113,13 @@ object ShooterIOTalon : ShooterIO { BaseStatusSignal.refreshAll( leaderSupplyCurrentSignal, leaderStatorCurrentSignal, + leaderTorqueCurrentSignal, leaderVelocitySignal, leaderTempSignal, leaderVoltageSignal, leaderAccelSignal, followerStatorCurrentSignal, + followerTorqueCurrentSignal, followerSupplyCurrentSignal, followerVelocitySignal, followerTempSignal, @@ -141,11 +147,13 @@ object ShooterIOTalon : ShooterIO { inputs.shooterLeaderTemperature = leaderTempSignal.valueAsDouble.celsius inputs.shooterLeaderSupplyCurrent = leaderSupplyCurrentSignal.valueAsDouble.amps inputs.shooterLeaderStatorCurrent = leaderStatorCurrentSignal.valueAsDouble.amps + inputs.shooterLeaderTorqueCurrent = leaderTorqueCurrentSignal.valueAsDouble.amps inputs.shooterLeaderVoltage = leaderVoltageSignal.valueAsDouble.volts inputs.shooterFollowerTemperature = followerTempSignal.valueAsDouble.celsius inputs.shooterFollowerSupplyCurrent = followerSupplyCurrentSignal.valueAsDouble.amps inputs.shooterFollowerStatorCurrent = followerStatorCurrentSignal.valueAsDouble.amps + inputs.shooterFollowerStatorCurrent = followerTorqueCurrentSignal.valueAsDouble.amps inputs.shooterFollowerVoltage = followerVoltageSignal.valueAsDouble.volts }