From a90ff9ec09075df75cab45b24f442d08a1a995d2 Mon Sep 17 00:00:00 2001 From: Veselin Dikov Date: Sun, 12 Oct 2025 21:19:49 -0700 Subject: [PATCH] Mark ControlUtil.deadband deprecated. Turns out, there is an equivalent function in the edu.wpi.first libraries --- .../com/team2813/lib2813/util/ControlUtils.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/src/main/java/com/team2813/lib2813/util/ControlUtils.java b/lib/src/main/java/com/team2813/lib2813/util/ControlUtils.java index 4b0cb589..42ecabf5 100644 --- a/lib/src/main/java/com/team2813/lib2813/util/ControlUtils.java +++ b/lib/src/main/java/com/team2813/lib2813/util/ControlUtils.java @@ -1,5 +1,7 @@ package com.team2813.lib2813.util; +import edu.wpi.first.math.MathUtil; + /** Utility class for comon control-related utility functions. */ public class ControlUtils { private ControlUtils() { @@ -21,7 +23,9 @@ private ControlUtils() { * @param deadband The deadband range value, must be in [0.0, 1.0). * @return The deadbanded value. * @throws IllegalArgumentException If the value or deadband is out of bounds. + * @deprecated Use edu.wpi.first.math.MathUtil.applyDeadband instead. */ + @Deprecated(forRemoval = true) public static double deadband(double value, double deadband) { if (deadband < 0.0 || deadband >= 1.0) { throw new IllegalArgumentException( @@ -30,14 +34,6 @@ public static double deadband(double value, double deadband) { if (value < -1.0 || value > 1.0) { throw new IllegalArgumentException("Value must be in [-1.0, 1.0]. Instead, it was " + value); } - if (Math.abs(value) <= deadband) { - return 0.0; - } else { - if (value > 0.0) { - return (value - deadband) / (1.0 - deadband); - } else { - return (value + deadband) / (1.0 - deadband); - } - } + return MathUtil.applyDeadband(value, deadband); } }