From 37a70ec9f7af552258ac25a600437aa314375c11 Mon Sep 17 00:00:00 2001 From: cuttestkittensrule Date: Mon, 17 Mar 2025 15:45:30 -0700 Subject: [PATCH 1/6] Add method to get the current of the motor --- .../main/java/com/team2813/lib2813/control/Motor.java | 11 +++++++++++ .../lib2813/control/motors/SparkMaxWrapper.java | 6 ++++++ .../lib2813/control/motors/TalonFXWrapper.java | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/lib/src/main/java/com/team2813/lib2813/control/Motor.java b/lib/src/main/java/com/team2813/lib2813/control/Motor.java index 23059f26..145b7ce8 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/Motor.java +++ b/lib/src/main/java/com/team2813/lib2813/control/Motor.java @@ -1,5 +1,7 @@ package com.team2813.lib2813.control; +import edu.wpi.first.units.measure.Current; + public interface Motor { // motor control @@ -19,4 +21,13 @@ public interface Motor { * @param feedForward The feedForward to apply to the motor */ void set(ControlMode mode, double demand, double feedForward); + + /** + * Gets the current that is being applied onto the motor + * + * @return The current applied current + * @throws UnsupportedOperationException if this kind of motor does not support getting the + * current + */ + Current getAppliedCurrent(); } diff --git a/lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java b/lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java index 57cda619..4ddc5b00 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java +++ b/lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java @@ -16,6 +16,7 @@ import edu.wpi.first.units.Units; import edu.wpi.first.units.measure.Angle; import edu.wpi.first.units.measure.AngularVelocity; +import edu.wpi.first.units.measure.Current; import java.util.ArrayList; import java.util.List; @@ -75,6 +76,11 @@ public Angle getPositionMeasure() { return Units.Rotations.of(encoder.getPosition()); } + @Override + public Current getAppliedCurrent() { + return Units.Amps.of(motor.getOutputCurrent()); + } + @Override public void setPosition(double position) { encoder.setPosition(position); diff --git a/lib/src/main/java/com/team2813/lib2813/control/motors/TalonFXWrapper.java b/lib/src/main/java/com/team2813/lib2813/control/motors/TalonFXWrapper.java index d459c32d..49f05a12 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/motors/TalonFXWrapper.java +++ b/lib/src/main/java/com/team2813/lib2813/control/motors/TalonFXWrapper.java @@ -17,6 +17,7 @@ import edu.wpi.first.units.Units; import edu.wpi.first.units.measure.Angle; import edu.wpi.first.units.measure.AngularVelocity; +import edu.wpi.first.units.measure.Current; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -132,6 +133,11 @@ public Angle getPositionMeasure() { return Units.Rotations.of(motor.getPosition().getValueAsDouble()); } + @Override + public Current getAppliedCurrent() { + return motor.getStatorCurrent().getValue(); + } + @Override public void setPosition(double position) { motor.setPosition(position); From 0f3e341ecd37480419732791b3a81701315dc7bf Mon Sep 17 00:00:00 2001 From: cuttestkittensrule Date: Sat, 26 Apr 2025 21:27:55 -0700 Subject: [PATCH 2/6] remove UnsupportedOperationException --- lib/src/main/java/com/team2813/lib2813/control/Motor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/main/java/com/team2813/lib2813/control/Motor.java b/lib/src/main/java/com/team2813/lib2813/control/Motor.java index 145b7ce8..ab80b055 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/Motor.java +++ b/lib/src/main/java/com/team2813/lib2813/control/Motor.java @@ -26,7 +26,6 @@ public interface Motor { * Gets the current that is being applied onto the motor * * @return The current applied current - * @throws UnsupportedOperationException if this kind of motor does not support getting the * current */ Current getAppliedCurrent(); From 4da792c728c12275b11716d55c17eb00bf28420d Mon Sep 17 00:00:00 2001 From: cuttestkittensrule Date: Sat, 26 Apr 2025 21:30:13 -0700 Subject: [PATCH 3/6] fix javadoc --- lib/src/main/java/com/team2813/lib2813/control/Motor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/main/java/com/team2813/lib2813/control/Motor.java b/lib/src/main/java/com/team2813/lib2813/control/Motor.java index ab80b055..a146e2aa 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/Motor.java +++ b/lib/src/main/java/com/team2813/lib2813/control/Motor.java @@ -26,7 +26,6 @@ public interface Motor { * Gets the current that is being applied onto the motor * * @return The current applied current - * current */ Current getAppliedCurrent(); } From 6f7909eaa904f63b86df5d98aad1c8a7bfaebc59 Mon Sep 17 00:00:00 2001 From: cuttestkittensrule Date: Mon, 30 Jun 2025 17:34:55 -0700 Subject: [PATCH 4/6] Documented that getAppliedCurrent will be there from 1.3.0 onwards --- lib/src/main/java/com/team2813/lib2813/control/Motor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/main/java/com/team2813/lib2813/control/Motor.java b/lib/src/main/java/com/team2813/lib2813/control/Motor.java index a146e2aa..60a7eb1a 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/Motor.java +++ b/lib/src/main/java/com/team2813/lib2813/control/Motor.java @@ -25,6 +25,7 @@ public interface Motor { /** * Gets the current that is being applied onto the motor * + * @since 1.3.0 * @return The current applied current */ Current getAppliedCurrent(); From 51b37d91458c3f750bc0fb2e69a09930c3a3ebdd Mon Sep 17 00:00:00 2001 From: cuttestkittensrule Date: Wed, 2 Jul 2025 18:53:01 -0700 Subject: [PATCH 5/6] bump the version to 2.0.0-alpha.1 --- lib/build.gradle | 2 +- lib/src/main/java/com/team2813/lib2813/control/Motor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/build.gradle b/lib/build.gradle index d145a155..900cef5b 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -25,7 +25,7 @@ tasks.withType(JavaCompile) { options.compilerArgs.add '-XDstringConcat=inline' } -version = '1.2.0' +version = '2.0.0-alpha.1' repositories { // Use Maven Central for resolving dependencies. diff --git a/lib/src/main/java/com/team2813/lib2813/control/Motor.java b/lib/src/main/java/com/team2813/lib2813/control/Motor.java index 60a7eb1a..6c92ed0b 100644 --- a/lib/src/main/java/com/team2813/lib2813/control/Motor.java +++ b/lib/src/main/java/com/team2813/lib2813/control/Motor.java @@ -25,7 +25,7 @@ public interface Motor { /** * Gets the current that is being applied onto the motor * - * @since 1.3.0 + * @since 2.0.0 * @return The current applied current */ Current getAppliedCurrent(); From c5c4fc241aab32b29af60ec7a0026b58469d740c Mon Sep 17 00:00:00 2001 From: cuttestkittensrule Date: Wed, 2 Jul 2025 18:58:00 -0700 Subject: [PATCH 6/6] update usages of since 1.3.0 to 2.0.0 --- .../team2813/lib2813/preferences/PersistedConfiguration.java | 2 +- .../com/team2813/lib2813/preferences/PreferencesInjector.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/main/java/com/team2813/lib2813/preferences/PersistedConfiguration.java b/lib/src/main/java/com/team2813/lib2813/preferences/PersistedConfiguration.java index 03ea7fbf..e7e6573f 100644 --- a/lib/src/main/java/com/team2813/lib2813/preferences/PersistedConfiguration.java +++ b/lib/src/main/java/com/team2813/lib2813/preferences/PersistedConfiguration.java @@ -92,7 +92,7 @@ * constructor; see Custom * Constructor in Java Records for details. * - * @since 1.3.0 + * @since 2.0.0 */ public final class PersistedConfiguration { // The below package-scope fields are for the self-tests. diff --git a/lib/src/main/java/com/team2813/lib2813/preferences/PreferencesInjector.java b/lib/src/main/java/com/team2813/lib2813/preferences/PreferencesInjector.java index 26c715f2..4132a11b 100644 --- a/lib/src/main/java/com/team2813/lib2813/preferences/PreferencesInjector.java +++ b/lib/src/main/java/com/team2813/lib2813/preferences/PreferencesInjector.java @@ -38,7 +38,7 @@ * * @deprecated Use {@link PersistedConfiguration} */ -@Deprecated(since = "1.3.0", forRemoval = true) +@Deprecated(since = "2.0.0", forRemoval = true) public class PreferencesInjector { private static final char PATH_SEPARATOR = '.';