From 794dc7ee325a13ea1fc5df921fc3feb464e4fbf1 Mon Sep 17 00:00:00 2001 From: Nitay4 Date: Thu, 11 Dec 2025 07:12:47 +0200 Subject: [PATCH 1/6] nitay - cooking --- src/main/java/frc/JoysticksBindings.java | 5 ++ src/main/java/frc/robot/IDs.java | 6 +++ src/main/java/frc/robot/Robot.java | 9 ++++ .../hardware/interfaces/InputSignal.java | 11 +++++ .../robot/hardware/rev/SparkMaxSignal.java | 28 +++++++++++ .../rev/motors/BrushlessSparkMAXMotor.java | 1 + src/main/java/frc/robot/subsystems/Test.java | 46 ++++++++++++++++++ .../frc/robot/subsystems/TestBuilder.java | 48 +++++++++++++++++++ 8 files changed, 154 insertions(+) create mode 100644 src/main/java/frc/robot/hardware/interfaces/InputSignal.java create mode 100644 src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java create mode 100644 src/main/java/frc/robot/subsystems/Test.java create mode 100644 src/main/java/frc/robot/subsystems/TestBuilder.java diff --git a/src/main/java/frc/JoysticksBindings.java b/src/main/java/frc/JoysticksBindings.java index 4764f1dc51..12cc48560f 100644 --- a/src/main/java/frc/JoysticksBindings.java +++ b/src/main/java/frc/JoysticksBindings.java @@ -1,5 +1,6 @@ package frc; +import edu.wpi.first.wpilibj2.command.RunCommand; import frc.joysticks.JoystickPorts; import frc.joysticks.SmartJoystick; import frc.robot.Robot; @@ -27,6 +28,10 @@ public static void configureBindings(Robot robot) { private static void mainJoystickButtons(Robot robot) { SmartJoystick usedJoystick = MAIN_JOYSTICK; + usedJoystick.A.onTrue(new RunCommand(() -> robot.test.getMotor().setPower(1), robot.getTest())); + usedJoystick.B.onTrue(new RunCommand(() -> robot.test.getMotor().setPower(0), robot.getTest())); + usedJoystick.X.onTrue(new RunCommand(() -> robot.test.getMotor().setPower(0.5), robot.getTest())); + // bindings... } diff --git a/src/main/java/frc/robot/IDs.java b/src/main/java/frc/robot/IDs.java index 8020584df2..3cf9a572dc 100644 --- a/src/main/java/frc/robot/IDs.java +++ b/src/main/java/frc/robot/IDs.java @@ -1,8 +1,14 @@ package frc.robot; +import frc.robot.hardware.phoenix6.BusChain; +import frc.robot.hardware.phoenix6.Phoenix6DeviceID; + public class IDs { public static class TalonFXIDs { + + public static final Phoenix6DeviceID test = new Phoenix6DeviceID(0, BusChain.ROBORIO); + } public static class CANCoderIDs { diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index fef3018de6..0949eb02bc 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -7,6 +7,8 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.RobotManager; import frc.robot.hardware.phoenix6.BusChain; +import frc.robot.subsystems.Test; +import frc.robot.subsystems.TestBuilder; import frc.utils.auto.PathPlannerAutoWrapper; import frc.utils.battery.BatteryUtil; @@ -18,9 +20,12 @@ public class Robot { public static final RobotType ROBOT_TYPE = RobotType.determineRobotType(false); + public final Test test; public Robot() { BatteryUtil.scheduleLimiter(); + this.test = TestBuilder.buildTest(); + test.getMotor().setPower(1); } public void periodic() { @@ -29,6 +34,10 @@ public void periodic() { CommandScheduler.getInstance().run(); // Should be last } + public Test getTest() { + return test; + } + public PathPlannerAutoWrapper getAutonomousCommand() { return new PathPlannerAutoWrapper(); } diff --git a/src/main/java/frc/robot/hardware/interfaces/InputSignal.java b/src/main/java/frc/robot/hardware/interfaces/InputSignal.java new file mode 100644 index 0000000000..6673d39ef2 --- /dev/null +++ b/src/main/java/frc/robot/hardware/interfaces/InputSignal.java @@ -0,0 +1,11 @@ +package frc.robot.hardware.interfaces; + +public interface InputSignal { + + T getLatestValue(); + + T getAndUpdateValue(); + + void updateValue(); + +} diff --git a/src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java b/src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java new file mode 100644 index 0000000000..532a7e2ec7 --- /dev/null +++ b/src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java @@ -0,0 +1,28 @@ +package frc.robot.hardware.rev; + +import frc.robot.hardware.interfaces.InputSignal; + +import java.util.function.Supplier; + +public class SparkMaxSignal implements InputSignal { + + Supplier valueSupplier; + + public SparkMaxSignal(Supplier valueSupplier) { + this.valueSupplier = valueSupplier; + } + + @Override + public T getLatestValue() { + return valueSupplier.get(); + } + + @Override + public T getAndUpdateValue() { + return null; + } + + @Override + public void updateValue() {} + +} diff --git a/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java b/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java index 29cf4a1c41..81423c756e 100644 --- a/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java +++ b/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java @@ -38,4 +38,5 @@ public void resetPosition(Rotation2d position) { motor.getEncoder().setPosition(position.getRotations()); } + } diff --git a/src/main/java/frc/robot/subsystems/Test.java b/src/main/java/frc/robot/subsystems/Test.java new file mode 100644 index 0000000000..c4336a4422 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Test.java @@ -0,0 +1,46 @@ +package frc.robot.subsystems; + +import edu.wpi.first.math.geometry.Rotation2d; +import frc.robot.hardware.interfaces.ControllableMotor; +import org.littletonrobotics.junction.Logger; + +import java.util.function.Supplier; + +public class Test extends GBSubsystem { + + ControllableMotor motor; + + Supplier velocitySignal; + Supplier voltageSignal; + Supplier currentSignal; + + public Test( + String logPath, + ControllableMotor motor, + Supplier velocitySignal, + Supplier voltageSignal, + Supplier currentSignal + ) { + super(logPath); + + this.motor = motor; + + this.voltageSignal = voltageSignal; + this.velocitySignal = velocitySignal; + this.currentSignal = currentSignal; + } + + public ControllableMotor getMotor() { + return motor; + } + + @Override + protected void subsystemPeriodic() { + motor.updateSimulation(); + + Logger.recordOutput(getLogPath() + "/Voltage", voltageSignal.get()); + Logger.recordOutput(getLogPath() + "/Velocity", velocitySignal.get()); + Logger.recordOutput(getLogPath() + "/Current", currentSignal.get()); + } + +} diff --git a/src/main/java/frc/robot/subsystems/TestBuilder.java b/src/main/java/frc/robot/subsystems/TestBuilder.java new file mode 100644 index 0000000000..8f30b78422 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/TestBuilder.java @@ -0,0 +1,48 @@ +package frc.robot.subsystems; + +import com.ctre.phoenix6.StatusSignal; +import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.math.system.plant.DCMotor; +import edu.wpi.first.math.system.plant.LinearSystemId; +import edu.wpi.first.units.measure.AngularVelocity; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Voltage; +import edu.wpi.first.wpilibj.simulation.DCMotorSim; +import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; +import frc.robot.IDs; +import frc.robot.RobotConstants; +import frc.robot.hardware.mechanisms.wpilib.SimpleMotorSimulation; +import frc.robot.hardware.phoenix6.motors.TalonFXMotor; + +import java.util.function.Supplier; + +public class TestBuilder { + + public static Test buildTest() { + String logPath = RobotConstants.SUBSYSTEM_LOGPATH_PREFIX + "/Test"; + + TalonFXMotor motor = new TalonFXMotor( + logPath + "/Motor", + IDs.TalonFXIDs.test, + new SysIdRoutine.Config(), + new SimpleMotorSimulation(new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getNEO(1), 0.0001, 1 / 1), DCMotor.getNEO(1))) + ); + + StatusSignal rawVelocitySignal = motor.getDevice().getVelocity(true); + StatusSignal rawVoltageSignal = motor.getDevice().getMotorVoltage(true); + StatusSignal rawCurrentSignal = motor.getDevice().getStatorCurrent(true); + + rawVelocitySignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + rawVoltageSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + rawCurrentSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + + Supplier velocitySignal = () -> Rotation2d.fromRotations(rawVelocitySignal.refresh().getValueAsDouble()); + Supplier voltageSignal = () -> rawVoltageSignal.refresh().getValueAsDouble(); + Supplier currentSignal = () -> rawCurrentSignal.refresh().getValueAsDouble(); + + motor.getDevice().optimizeBusUtilization(); + + return new Test(logPath, motor, velocitySignal, voltageSignal, currentSignal); + } + +} From 625988107f7aa3c1c4ff8c2d94d90a0b209fe944 Mon Sep 17 00:00:00 2001 From: Nitay4 Date: Thu, 11 Dec 2025 07:13:03 +0200 Subject: [PATCH 2/6] nitay - cooking --- src/main/java/frc/robot/subsystems/TestBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/TestBuilder.java b/src/main/java/frc/robot/subsystems/TestBuilder.java index 8f30b78422..93e8b4f7b8 100644 --- a/src/main/java/frc/robot/subsystems/TestBuilder.java +++ b/src/main/java/frc/robot/subsystems/TestBuilder.java @@ -36,8 +36,8 @@ public static Test buildTest() { rawVoltageSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); rawCurrentSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); - Supplier velocitySignal = () -> Rotation2d.fromRotations(rawVelocitySignal.refresh().getValueAsDouble()); - Supplier voltageSignal = () -> rawVoltageSignal.refresh().getValueAsDouble(); + Supplier velocitySignal = () -> Rotation2d.fromRotations(rawVelocitySignal.refresh().getValueAsDouble()); + Supplier voltageSignal = () -> rawVoltageSignal.refresh().getValueAsDouble(); Supplier currentSignal = () -> rawCurrentSignal.refresh().getValueAsDouble(); motor.getDevice().optimizeBusUtilization(); From dc4ec28d727c8187c25d385ffc5760fc8fc147ce Mon Sep 17 00:00:00 2001 From: Nitay4 Date: Sun, 14 Dec 2025 19:33:35 +0200 Subject: [PATCH 3/6] nitay - signals are poo poo anf im the goat --- src/main/java/frc/robot/IDs.java | 5 ++ src/main/java/frc/robot/Robot.java | 5 +- .../robot/subsystems/SparkMaxTestBuilder.java | 74 +++++++++++++++ .../robot/subsystems/TalonFXTestBuilder.java | 89 +++++++++++++++++++ src/main/java/frc/robot/subsystems/Test.java | 23 +++-- .../frc/robot/subsystems/TestBuilder.java | 48 ---------- 6 files changed, 184 insertions(+), 60 deletions(-) create mode 100644 src/main/java/frc/robot/subsystems/SparkMaxTestBuilder.java create mode 100644 src/main/java/frc/robot/subsystems/TalonFXTestBuilder.java delete mode 100644 src/main/java/frc/robot/subsystems/TestBuilder.java diff --git a/src/main/java/frc/robot/IDs.java b/src/main/java/frc/robot/IDs.java index 3cf9a572dc..e744b4f02b 100644 --- a/src/main/java/frc/robot/IDs.java +++ b/src/main/java/frc/robot/IDs.java @@ -1,7 +1,9 @@ package frc.robot; +import com.revrobotics.spark.SparkLowLevel; import frc.robot.hardware.phoenix6.BusChain; import frc.robot.hardware.phoenix6.Phoenix6DeviceID; +import frc.robot.hardware.rev.motors.SparkMaxDeviceID; public class IDs { @@ -21,6 +23,9 @@ public static class CANdleIDs { } public static class SparkMAXIDs { + + public static final SparkMaxDeviceID test = new SparkMaxDeviceID(0, SparkLowLevel.MotorType.kBrushless); + } public static class DigitalInputsIDs { diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 0949eb02bc..8bafe16f47 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -7,8 +7,8 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.RobotManager; import frc.robot.hardware.phoenix6.BusChain; +import frc.robot.subsystems.TalonFXTestBuilder; import frc.robot.subsystems.Test; -import frc.robot.subsystems.TestBuilder; import frc.utils.auto.PathPlannerAutoWrapper; import frc.utils.battery.BatteryUtil; @@ -24,8 +24,7 @@ public class Robot { public Robot() { BatteryUtil.scheduleLimiter(); - this.test = TestBuilder.buildTest(); - test.getMotor().setPower(1); + this.test = TalonFXTestBuilder.buildTest(); } public void periodic() { diff --git a/src/main/java/frc/robot/subsystems/SparkMaxTestBuilder.java b/src/main/java/frc/robot/subsystems/SparkMaxTestBuilder.java new file mode 100644 index 0000000000..2fa2ee3a2a --- /dev/null +++ b/src/main/java/frc/robot/subsystems/SparkMaxTestBuilder.java @@ -0,0 +1,74 @@ +package frc.robot.subsystems; + +import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.math.system.plant.DCMotor; +import edu.wpi.first.math.system.plant.LinearSystemId; +import edu.wpi.first.wpilibj.simulation.DCMotorSim; +import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; +import frc.robot.IDs; +import frc.robot.RobotConstants; +import frc.robot.hardware.mechanisms.wpilib.SimpleMotorSimulation; +import frc.robot.hardware.rev.motors.BrushlessSparkMAXMotor; +import frc.robot.hardware.rev.motors.SparkMaxWrapper; +import frc.utils.TimedValue; +import frc.utils.time.TimeUtil; + +import java.util.function.Supplier; + +public class SparkMaxTestBuilder { + + public static Test buildTest() { + String logPath = RobotConstants.SUBSYSTEM_LOGPATH_PREFIX + "/Test"; + + SparkMaxWrapper sparkMaxWrapper = new SparkMaxWrapper(IDs.SparkMAXIDs.test); + + BrushlessSparkMAXMotor motor = new BrushlessSparkMAXMotor( + logPath + "/Motor", + sparkMaxWrapper, + new SimpleMotorSimulation(new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getNEO(1), 0.0001, 1 / 1), DCMotor.getNEO(1))), + new SysIdRoutine.Config() + ); + + TimedValue positionTimedValue = new TimedValue<>( + Rotation2d.fromRotations(sparkMaxWrapper.getEncoder().getPosition()), + TimeUtil.getCurrentTimeSeconds() + ); + + TimedValue velocityTimedValue = new TimedValue<>( + sparkMaxWrapper.getVelocityAnglePerSecond(), + TimeUtil.getCurrentTimeSeconds() + ); + + TimedValue voltageTimedValue = new TimedValue<>(sparkMaxWrapper.getVoltage(), TimeUtil.getCurrentTimeSeconds()); + + TimedValue currentTimedValue = new TimedValue<>(sparkMaxWrapper.getOutputCurrent(), TimeUtil.getCurrentTimeSeconds()); + + + Supplier> positionSignal = () -> { + positionTimedValue.setValue(Rotation2d.fromRotations(sparkMaxWrapper.getEncoder().getPosition())); + positionTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return positionTimedValue; + }; + + Supplier> velocitySignal = () -> { + velocityTimedValue.setValue(sparkMaxWrapper.getVelocityAnglePerSecond()); + velocityTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return velocityTimedValue; + }; + + Supplier> voltageSignal = () -> { + voltageTimedValue.setValue(sparkMaxWrapper.getVoltage()); + voltageTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return voltageTimedValue; + }; + + Supplier> currentSignal = () -> { + currentTimedValue.setValue(sparkMaxWrapper.getOutputCurrent()); + currentTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return currentTimedValue; + }; + + return new Test(logPath, motor, positionSignal, velocitySignal, voltageSignal, currentSignal); + } + +} diff --git a/src/main/java/frc/robot/subsystems/TalonFXTestBuilder.java b/src/main/java/frc/robot/subsystems/TalonFXTestBuilder.java new file mode 100644 index 0000000000..c1f9f38fb9 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/TalonFXTestBuilder.java @@ -0,0 +1,89 @@ +package frc.robot.subsystems; + +import com.ctre.phoenix6.BaseStatusSignal; +import com.ctre.phoenix6.StatusSignal; +import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.math.system.plant.DCMotor; +import edu.wpi.first.math.system.plant.LinearSystemId; +import edu.wpi.first.units.measure.Angle; +import edu.wpi.first.units.measure.AngularVelocity; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Voltage; +import edu.wpi.first.wpilibj.simulation.DCMotorSim; +import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; +import frc.robot.IDs; +import frc.robot.RobotConstants; +import frc.robot.hardware.mechanisms.wpilib.SimpleMotorSimulation; +import frc.robot.hardware.phoenix6.motors.TalonFXMotor; +import frc.utils.TimedValue; +import frc.utils.time.TimeUtil; + +import java.util.function.Supplier; + +public class TalonFXTestBuilder { + + public static Test buildTest() { + String logPath = RobotConstants.SUBSYSTEM_LOGPATH_PREFIX + "/Test"; + + TalonFXMotor motor = new TalonFXMotor( + logPath + "/Motor", + IDs.TalonFXIDs.test, + new SysIdRoutine.Config(), + new SimpleMotorSimulation(new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getNEO(1), 0.0001, 1 / 1), DCMotor.getNEO(1))) + ); + + StatusSignal rawPositionSignal = motor.getDevice().getPosition(true); + StatusSignal rawVelocitySignal = motor.getDevice().getVelocity(true); + StatusSignal rawVoltageSignal = motor.getDevice().getMotorVoltage(true); + StatusSignal rawCurrentSignal = motor.getDevice().getStatorCurrent(true); + + rawPositionSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + rawVelocitySignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + rawVoltageSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + rawCurrentSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); + + TimedValue positionTimedValue = new TimedValue<>( + Rotation2d + .fromRotations(BaseStatusSignal.getLatencyCompensatedValueAsDouble(rawPositionSignal.refresh(), rawVelocitySignal.refresh())), + TimeUtil.getCurrentTimeSeconds() + ); + TimedValue velocityTimedValue = new TimedValue<>( + Rotation2d.fromRotations(rawVelocitySignal.refresh().getValueAsDouble()), + TimeUtil.getCurrentTimeSeconds() + ); + TimedValue voltageTimedValue = new TimedValue<>(rawVoltageSignal.refresh().getValueAsDouble(), TimeUtil.getCurrentTimeSeconds()); + TimedValue currentTimedValue = new TimedValue<>(rawCurrentSignal.refresh().getValueAsDouble(), TimeUtil.getCurrentTimeSeconds()); + + Supplier> positionSignal = () -> { + positionTimedValue.setValue( + Rotation2d + .fromRotations(BaseStatusSignal.getLatencyCompensatedValueAsDouble(rawPositionSignal.refresh(), rawVelocitySignal.refresh())) + ); + positionTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return positionTimedValue; + }; + + Supplier> velocitySignal = () -> { + velocityTimedValue.setValue(Rotation2d.fromRotations(rawVelocitySignal.refresh().getValueAsDouble())); + velocityTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return velocityTimedValue; + }; + + Supplier> voltageSignal = () -> { + voltageTimedValue.setValue(rawVoltageSignal.refresh().getValueAsDouble()); + voltageTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return voltageTimedValue; + }; + + Supplier> currentSignal = () -> { + currentTimedValue.setValue(rawCurrentSignal.refresh().getValueAsDouble()); + currentTimedValue.setTimestamp(TimeUtil.getCurrentTimeSeconds()); + return currentTimedValue; + }; + + motor.getDevice().optimizeBusUtilization(); + + return new Test(logPath, motor, positionSignal, velocitySignal, voltageSignal, currentSignal); + } + +} diff --git a/src/main/java/frc/robot/subsystems/Test.java b/src/main/java/frc/robot/subsystems/Test.java index c4336a4422..a1eab86373 100644 --- a/src/main/java/frc/robot/subsystems/Test.java +++ b/src/main/java/frc/robot/subsystems/Test.java @@ -2,6 +2,7 @@ import edu.wpi.first.math.geometry.Rotation2d; import frc.robot.hardware.interfaces.ControllableMotor; +import frc.utils.TimedValue; import org.littletonrobotics.junction.Logger; import java.util.function.Supplier; @@ -10,21 +11,24 @@ public class Test extends GBSubsystem { ControllableMotor motor; - Supplier velocitySignal; - Supplier voltageSignal; - Supplier currentSignal; + Supplier> positionSignal; + Supplier> velocitySignal; + Supplier> voltageSignal; + Supplier> currentSignal; public Test( String logPath, ControllableMotor motor, - Supplier velocitySignal, - Supplier voltageSignal, - Supplier currentSignal + Supplier> positionSignal, + Supplier> velocitySignal, + Supplier> voltageSignal, + Supplier> currentSignal ) { super(logPath); this.motor = motor; + this.positionSignal = positionSignal; this.voltageSignal = voltageSignal; this.velocitySignal = velocitySignal; this.currentSignal = currentSignal; @@ -38,9 +42,10 @@ public ControllableMotor getMotor() { protected void subsystemPeriodic() { motor.updateSimulation(); - Logger.recordOutput(getLogPath() + "/Voltage", voltageSignal.get()); - Logger.recordOutput(getLogPath() + "/Velocity", velocitySignal.get()); - Logger.recordOutput(getLogPath() + "/Current", currentSignal.get()); + Logger.recordOutput(getLogPath() + "/Position", positionSignal.get().getValue()); + Logger.recordOutput(getLogPath() + "/Velocity", velocitySignal.get().getValue()); + Logger.recordOutput(getLogPath() + "/Voltage", voltageSignal.get().getValue()); + Logger.recordOutput(getLogPath() + "/Current", currentSignal.get().getValue()); } } diff --git a/src/main/java/frc/robot/subsystems/TestBuilder.java b/src/main/java/frc/robot/subsystems/TestBuilder.java deleted file mode 100644 index 93e8b4f7b8..0000000000 --- a/src/main/java/frc/robot/subsystems/TestBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -package frc.robot.subsystems; - -import com.ctre.phoenix6.StatusSignal; -import edu.wpi.first.math.geometry.Rotation2d; -import edu.wpi.first.math.system.plant.DCMotor; -import edu.wpi.first.math.system.plant.LinearSystemId; -import edu.wpi.first.units.measure.AngularVelocity; -import edu.wpi.first.units.measure.Current; -import edu.wpi.first.units.measure.Voltage; -import edu.wpi.first.wpilibj.simulation.DCMotorSim; -import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine; -import frc.robot.IDs; -import frc.robot.RobotConstants; -import frc.robot.hardware.mechanisms.wpilib.SimpleMotorSimulation; -import frc.robot.hardware.phoenix6.motors.TalonFXMotor; - -import java.util.function.Supplier; - -public class TestBuilder { - - public static Test buildTest() { - String logPath = RobotConstants.SUBSYSTEM_LOGPATH_PREFIX + "/Test"; - - TalonFXMotor motor = new TalonFXMotor( - logPath + "/Motor", - IDs.TalonFXIDs.test, - new SysIdRoutine.Config(), - new SimpleMotorSimulation(new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getNEO(1), 0.0001, 1 / 1), DCMotor.getNEO(1))) - ); - - StatusSignal rawVelocitySignal = motor.getDevice().getVelocity(true); - StatusSignal rawVoltageSignal = motor.getDevice().getMotorVoltage(true); - StatusSignal rawCurrentSignal = motor.getDevice().getStatorCurrent(true); - - rawVelocitySignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); - rawVoltageSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); - rawCurrentSignal.setUpdateFrequency(RobotConstants.DEFAULT_SIGNALS_FREQUENCY_HERTZ); - - Supplier velocitySignal = () -> Rotation2d.fromRotations(rawVelocitySignal.refresh().getValueAsDouble()); - Supplier voltageSignal = () -> rawVoltageSignal.refresh().getValueAsDouble(); - Supplier currentSignal = () -> rawCurrentSignal.refresh().getValueAsDouble(); - - motor.getDevice().optimizeBusUtilization(); - - return new Test(logPath, motor, velocitySignal, voltageSignal, currentSignal); - } - -} From fbb74f76777215fb941809c3da51a2508dcf0f6a Mon Sep 17 00:00:00 2001 From: Nitay4 Date: Sun, 14 Dec 2025 19:35:09 +0200 Subject: [PATCH 4/6] nitay - signals are poo poo anf im the goat --- .../frc/robot/hardware/interfaces/InputSignal.java | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/main/java/frc/robot/hardware/interfaces/InputSignal.java diff --git a/src/main/java/frc/robot/hardware/interfaces/InputSignal.java b/src/main/java/frc/robot/hardware/interfaces/InputSignal.java deleted file mode 100644 index 6673d39ef2..0000000000 --- a/src/main/java/frc/robot/hardware/interfaces/InputSignal.java +++ /dev/null @@ -1,11 +0,0 @@ -package frc.robot.hardware.interfaces; - -public interface InputSignal { - - T getLatestValue(); - - T getAndUpdateValue(); - - void updateValue(); - -} From 8a600b251b3fd248cf5191ad09e8cb9521a89571 Mon Sep 17 00:00:00 2001 From: Nitay4 Date: Sun, 14 Dec 2025 19:35:40 +0200 Subject: [PATCH 5/6] nitay - signals are poo poo anf im the goat --- .../frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java b/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java index 81423c756e..29cf4a1c41 100644 --- a/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java +++ b/src/main/java/frc/robot/hardware/rev/motors/BrushlessSparkMAXMotor.java @@ -38,5 +38,4 @@ public void resetPosition(Rotation2d position) { motor.getEncoder().setPosition(position.getRotations()); } - } From e65d0da98051c2d91bf730bf0e8a4a9a3f73c773 Mon Sep 17 00:00:00 2001 From: Nitay4 Date: Sun, 14 Dec 2025 19:36:48 +0200 Subject: [PATCH 6/6] nitay - signals are poo poo anf im the goat --- .../robot/hardware/rev/SparkMaxSignal.java | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java diff --git a/src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java b/src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java deleted file mode 100644 index 532a7e2ec7..0000000000 --- a/src/main/java/frc/robot/hardware/rev/SparkMaxSignal.java +++ /dev/null @@ -1,28 +0,0 @@ -package frc.robot.hardware.rev; - -import frc.robot.hardware.interfaces.InputSignal; - -import java.util.function.Supplier; - -public class SparkMaxSignal implements InputSignal { - - Supplier valueSupplier; - - public SparkMaxSignal(Supplier valueSupplier) { - this.valueSupplier = valueSupplier; - } - - @Override - public T getLatestValue() { - return valueSupplier.get(); - } - - @Override - public T getAndUpdateValue() { - return null; - } - - @Override - public void updateValue() {} - -}