Upgrade maven deps to latest versions and fix new linter errors (#3772)

This also makes the Gradle build work with JDK 17.

The extra JVM args in gradle.properties works around a bug with spotless
and JDK 17: https://github.com/diffplug/spotless/issues/834

PMD.CloseResource was ignored because it's almost always a false
positive, and there are many of them.
This commit is contained in:
Tyler Veness
2021-12-09 12:20:08 -08:00
committed by GitHub
parent 441f2ed9b0
commit 7269a170fb
100 changed files with 306 additions and 338 deletions

View File

@@ -11,7 +11,7 @@ import org.ejml.simple.SimpleMatrix;
import org.junit.jupiter.api.Test;
@SuppressWarnings({"ParameterName", "LocalVariableName"})
public class DrakeTest {
class DrakeTest {
public static void assertMatrixEqual(SimpleMatrix A, SimpleMatrix B) {
for (int i = 0; i < A.numRows(); i++) {
for (int j = 0; j < A.numCols(); j++) {
@@ -49,7 +49,7 @@ public class DrakeTest {
}
@Test
public void testDiscreteAlgebraicRicattiEquation() {
void testDiscreteAlgebraicRicattiEquation() {
int n1 = 4;
int m1 = 1;

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.math.numbers.N4;
import org.ejml.data.SingularMatrixException;
import org.junit.jupiter.api.Test;
public class MatrixTest {
class MatrixTest {
@Test
void testMatrixMultiplication() {
var mat1 = Matrix.mat(Nat.N2(), Nat.N2()).fill(2.0, 1.0, 0.0, 1.0);

View File

@@ -18,9 +18,9 @@ import org.ejml.dense.row.MatrixFeatures_DDRM;
import org.ejml.simple.SimpleMatrix;
import org.junit.jupiter.api.Test;
public class StateSpaceUtilTest {
class StateSpaceUtilTest {
@Test
public void testCostArray() {
void testCostArray() {
var mat = StateSpaceUtil.makeCostMatrix(VecBuilder.fill(1.0, 2.0, 3.0));
assertEquals(1.0, mat.get(0, 0), 1e-3);
@@ -35,7 +35,7 @@ public class StateSpaceUtilTest {
}
@Test
public void testCovArray() {
void testCovArray() {
var mat = StateSpaceUtil.makeCovarianceMatrix(Nat.N3(), VecBuilder.fill(1.0, 2.0, 3.0));
assertEquals(1.0, mat.get(0, 0), 1e-3);
@@ -51,7 +51,7 @@ public class StateSpaceUtilTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testIsStabilizable() {
void testIsStabilizable() {
Matrix<N2, N2> A;
Matrix<N2, N1> B = VecBuilder.fill(0, 1);
@@ -78,7 +78,7 @@ public class StateSpaceUtilTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testIsDetectable() {
void testIsDetectable() {
Matrix<N2, N2> A;
Matrix<N1, N2> C = Matrix.mat(Nat.N1(), Nat.N2()).fill(0, 1);
@@ -104,7 +104,7 @@ public class StateSpaceUtilTest {
}
@Test
public void testMakeWhiteNoiseVector() {
void testMakeWhiteNoiseVector() {
var firstData = new ArrayList<Double>();
var secondData = new ArrayList<Double>();
for (int i = 0; i < 1000; i++) {
@@ -135,7 +135,7 @@ public class StateSpaceUtilTest {
}
@Test
public void testMatrixExp() {
void testMatrixExp() {
Matrix<N2, N2> wrappedMatrix = Matrix.eye(Nat.N2());
var wrappedResult = wrappedMatrix.exp();
@@ -152,7 +152,7 @@ public class StateSpaceUtilTest {
}
@Test
public void testSimpleMatrixExp() {
void testSimpleMatrixExp() {
SimpleMatrix matrix = SimpleMatrixUtils.eye(2);
var result = SimpleMatrixUtils.exp(matrix);
@@ -175,7 +175,7 @@ public class StateSpaceUtilTest {
}
@Test
public void testPoseToVector() {
void testPoseToVector() {
Pose2d pose = new Pose2d(1, 2, new Rotation2d(3));
var vector = StateSpaceUtil.poseToVector(pose);
assertEquals(pose.getTranslation().getX(), vector.get(0, 0), 1e-6);

View File

@@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class BangBangInputOutputTest {
class BangBangInputOutputTest {
private BangBangController m_controller;
@BeforeEach

View File

@@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class BangBangToleranceTest {
class BangBangToleranceTest {
private BangBangController m_controller;
@BeforeEach

View File

@@ -11,10 +11,10 @@ import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.math.system.plant.LinearSystemId;
import org.junit.jupiter.api.Test;
public class LinearQuadraticRegulatorTest {
class LinearQuadraticRegulatorTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testLQROnElevator() {
void testLQROnElevator() {
var motors = DCMotor.getVex775Pro(2);
var m = 5.0;
@@ -36,7 +36,7 @@ public class LinearQuadraticRegulatorTest {
}
@Test
public void testFourMotorElevator() {
void testFourMotorElevator() {
var dt = 0.020;
var plant =
@@ -52,7 +52,7 @@ public class LinearQuadraticRegulatorTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testLQROnArm() {
void testLQROnArm() {
var motors = DCMotor.getVex775Pro(2);
var m = 4.0;
@@ -74,7 +74,7 @@ public class LinearQuadraticRegulatorTest {
}
@Test
public void testLatencyCompensate() {
void testLatencyCompensate() {
var dt = 0.02;
var plant =

View File

@@ -21,8 +21,8 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile;
import java.util.Random;
import org.junit.jupiter.api.Test;
public class LinearSystemLoopTest {
public static final double kDt = 0.00505;
class LinearSystemLoopTest {
private static final double kDt = 0.00505;
private static final double kPositionStddev = 0.0001;
private static final Random random = new Random();
@@ -51,7 +51,7 @@ public class LinearSystemLoopTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testStateSpaceEnabled() {
void testStateSpaceEnabled() {
m_loop.reset(VecBuilder.fill(0, 0));
Matrix<N2, N1> references = VecBuilder.fill(2.0, 0.0);
var constraints = new TrapezoidProfile.Constraints(4, 3);
@@ -80,7 +80,7 @@ public class LinearSystemLoopTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testFlywheelEnabled() {
void testFlywheelEnabled() {
LinearSystem<N1, N1, N1> plant =
LinearSystemId.createFlywheelSystem(DCMotor.getNEO(2), 0.00289, 1.0);
KalmanFilter<N1, N1, N1> observer =

View File

@@ -11,9 +11,9 @@ import edu.wpi.first.math.Nat;
import edu.wpi.first.math.VecBuilder;
import org.junit.jupiter.api.Test;
public class AngleStatisticsTest {
class AngleStatisticsTest {
@Test
public void testMean() {
void testMean() {
// 3 states, 2 sigmas
var sigmas =
Matrix.mat(Nat.N3(), Nat.N2()).fill(1, 1.2, Math.toRadians(359), Math.toRadians(3), 1, 2);
@@ -27,7 +27,7 @@ public class AngleStatisticsTest {
}
@Test
public void testResidual() {
void testResidual() {
var first = VecBuilder.fill(1, Math.toRadians(1), 2);
var second = VecBuilder.fill(1, Math.toRadians(359), 1);
assertTrue(
@@ -36,7 +36,7 @@ public class AngleStatisticsTest {
}
@Test
public void testAdd() {
void testAdd() {
var first = VecBuilder.fill(1, Math.toRadians(1), 2);
var second = VecBuilder.fill(1, Math.toRadians(359), 1);
assertTrue(AngleStatistics.angleAdd(first, second, 1).isEqual(VecBuilder.fill(2, 0, 3), 1e-6));

View File

@@ -21,10 +21,10 @@ import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.Test;
public class DifferentialDrivePoseEstimatorTest {
class DifferentialDrivePoseEstimatorTest {
@SuppressWarnings("LocalVariableName")
@Test
public void testAccuracy() {
void testAccuracy() {
var estimator =
new DifferentialDrivePoseEstimator(
new Rotation2d(),

View File

@@ -27,8 +27,8 @@ import java.util.List;
import org.junit.jupiter.api.Test;
@SuppressWarnings("ParameterName")
public class ExtendedKalmanFilterTest {
public static Matrix<N5, N1> getDynamics(final Matrix<N5, N1> x, final Matrix<N2, N1> u) {
class ExtendedKalmanFilterTest {
private static Matrix<N5, N1> getDynamics(final Matrix<N5, N1> x, final Matrix<N2, N1> u) {
final var motors = DCMotor.getCIM(2);
final var gr = 7.08; // Gear ratio
@@ -58,17 +58,19 @@ public class ExtendedKalmanFilterTest {
return result;
}
public static Matrix<N3, N1> getLocalMeasurementModel(Matrix<N5, N1> x, Matrix<N2, N1> u) {
@SuppressWarnings("PMD.UnusedFormalParameter")
private static Matrix<N3, N1> getLocalMeasurementModel(Matrix<N5, N1> x, Matrix<N2, N1> u) {
return VecBuilder.fill(x.get(2, 0), x.get(3, 0), x.get(4, 0));
}
public static Matrix<N5, N1> getGlobalMeasurementModel(Matrix<N5, N1> x, Matrix<N2, N1> u) {
@SuppressWarnings("PMD.UnusedFormalParameter")
private static Matrix<N5, N1> getGlobalMeasurementModel(Matrix<N5, N1> x, Matrix<N2, N1> u) {
return VecBuilder.fill(x.get(0, 0), x.get(1, 0), x.get(2, 0), x.get(3, 0), x.get(4, 0));
}
@SuppressWarnings("LocalVariableName")
@Test
public void testInit() {
void testInit() {
double dtSeconds = 0.00505;
assertDoesNotThrow(
@@ -99,7 +101,7 @@ public class ExtendedKalmanFilterTest {
@SuppressWarnings("LocalVariableName")
@Test
public void testConvergence() {
void testConvergence() {
double dtSeconds = 0.00505;
double rbMeters = 0.8382 / 2.0; // Robot radius

View File

@@ -25,7 +25,7 @@ import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.Test;
public class KalmanFilterTest {
class KalmanFilterTest {
private static LinearSystem<N2, N1, N1> elevatorPlant;
private static final double kDt = 0.00505;
@@ -35,7 +35,7 @@ public class KalmanFilterTest {
}
@SuppressWarnings("LocalVariableName")
public static void createElevator() {
private static void createElevator() {
var motors = DCMotor.getVex775Pro(2);
var m = 5.0;
@@ -62,7 +62,7 @@ public class KalmanFilterTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testElevatorKalmanFilter() {
void testElevatorKalmanFilter() {
var Q = VecBuilder.fill(0.05, 1.0);
var R = VecBuilder.fill(0.0001);
@@ -70,7 +70,7 @@ public class KalmanFilterTest {
}
@Test
public void testSwerveKFStationary() {
void testSwerveKFStationary() {
var random = new Random();
var filter =
@@ -99,7 +99,7 @@ public class KalmanFilterTest {
}
@Test
public void testSwerveKFMovingWithoutAccelerating() {
void testSwerveKFMovingWithoutAccelerating() {
var random = new Random();
var filter =
@@ -137,7 +137,7 @@ public class KalmanFilterTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testSwerveKFMovingOverTrajectory() {
void testSwerveKFMovingOverTrajectory() {
var random = new Random();
var filter =

View File

@@ -18,10 +18,10 @@ import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.Test;
public class MecanumDrivePoseEstimatorTest {
class MecanumDrivePoseEstimatorTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testAccuracy() {
void testAccuracy() {
var kinematics =
new MecanumDriveKinematics(
new Translation2d(1, 1), new Translation2d(1, -1),

View File

@@ -11,9 +11,9 @@ import edu.wpi.first.math.Nat;
import edu.wpi.first.math.VecBuilder;
import org.junit.jupiter.api.Test;
public class MerweScaledSigmaPointsTest {
class MerweScaledSigmaPointsTest {
@Test
public void testZeroMeanPoints() {
void testZeroMeanPoints() {
var merweScaledSigmaPoints = new MerweScaledSigmaPoints<>(Nat.N2());
var points =
merweScaledSigmaPoints.sigmaPoints(
@@ -28,7 +28,7 @@ public class MerweScaledSigmaPointsTest {
}
@Test
public void testNonzeroMeanPoints() {
void testNonzeroMeanPoints() {
var merweScaledSigmaPoints = new MerweScaledSigmaPoints<>(Nat.N2());
var points =
merweScaledSigmaPoints.sigmaPoints(

View File

@@ -18,10 +18,10 @@ import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.Test;
public class SwerveDrivePoseEstimatorTest {
class SwerveDrivePoseEstimatorTest {
@Test
@SuppressWarnings("LocalVariableName")
public void testAccuracy() {
void testAccuracy() {
var kinematics =
new SwerveDriveKinematics(
new Translation2d(1, 1),

View File

@@ -29,9 +29,9 @@ import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
public class UnscentedKalmanFilterTest {
class UnscentedKalmanFilterTest {
@SuppressWarnings({"LocalVariableName", "ParameterName"})
public static Matrix<N6, N1> getDynamics(Matrix<N6, N1> x, Matrix<N2, N1> u) {
private static Matrix<N6, N1> getDynamics(Matrix<N6, N1> x, Matrix<N2, N1> u) {
var motors = DCMotor.getCIM(2);
var gHigh = 7.08;
@@ -69,19 +69,19 @@ public class UnscentedKalmanFilterTest {
k2 * ((C1 * vl) + (C2 * Vl)) + k1 * ((C1 * vr) + (C2 * Vr)));
}
@SuppressWarnings("ParameterName")
public static Matrix<N4, N1> getLocalMeasurementModel(Matrix<N6, N1> x, Matrix<N2, N1> u) {
@SuppressWarnings({"PMD.UnusedFormalParameter", "ParameterName"})
private static Matrix<N4, N1> getLocalMeasurementModel(Matrix<N6, N1> x, Matrix<N2, N1> u) {
return VecBuilder.fill(x.get(2, 0), x.get(3, 0), x.get(4, 0), x.get(5, 0));
}
@SuppressWarnings("ParameterName")
public static Matrix<N6, N1> getGlobalMeasurementModel(Matrix<N6, N1> x, Matrix<N2, N1> u) {
@SuppressWarnings({"PMD.UnusedFormalParameter", "ParameterName"})
private static Matrix<N6, N1> getGlobalMeasurementModel(Matrix<N6, N1> x, Matrix<N2, N1> u) {
return x.copy();
}
@Test
@SuppressWarnings("LocalVariableName")
public void testInit() {
void testInit() {
assertDoesNotThrow(
() -> {
UnscentedKalmanFilter<N6, N2, N4> observer =
@@ -104,7 +104,7 @@ public class UnscentedKalmanFilterTest {
@SuppressWarnings("LocalVariableName")
@Test
public void testConvergence() {
void testConvergence() {
double dtSeconds = 0.00505;
double rbMeters = 0.8382 / 2.0; // Robot radius
@@ -206,7 +206,7 @@ public class UnscentedKalmanFilterTest {
@Test
@SuppressWarnings({"LocalVariableName", "ParameterName"})
public void testLinearUKF() {
void testLinearUKF() {
var dt = 0.020;
var plant = LinearSystemId.identifyVelocitySystem(0.02, 0.006);
var observer =
@@ -236,7 +236,7 @@ public class UnscentedKalmanFilterTest {
}
@Test
public void testUnscentedTransform() {
void testUnscentedTransform() {
// From FilterPy
var ret =
UnscentedKalmanFilter.unscentedTransform(

View File

@@ -8,7 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class MedianFilterTest {
class MedianFilterTest {
@Test
void medianFilterNotFullTestEven() {
MedianFilter filter = new MedianFilter(10);

View File

@@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import edu.wpi.first.util.WPIUtilJNI;
import org.junit.jupiter.api.Test;
public class SlewRateLimiterTest {
class SlewRateLimiterTest {
@Test
void slewRateLimitTest() {
WPIUtilJNI.enableMockTime();

View File

@@ -53,6 +53,7 @@ class Pose2dTest {
assertNotEquals(one, two);
}
@Test
void testMinus() {
var initial = new Pose2d(0.0, 0.0, Rotation2d.fromDegrees(45.0));
var last = new Pose2d(5.0, 5.0, Rotation2d.fromDegrees(45.0));

View File

@@ -60,6 +60,7 @@ class Twist2dTest {
assertNotEquals(one, two);
}
@Test
void testPose2dLog() {
final var start = new Pose2d();
final var end = new Pose2d(5.0, 5.0, Rotation2d.fromDegrees(90.0));

View File

@@ -14,11 +14,11 @@ import edu.wpi.first.math.VecBuilder;
import edu.wpi.first.math.numbers.N2;
import org.junit.jupiter.api.Test;
public class DiscretizationTest {
class DiscretizationTest {
// Check that for a simple second-order system that we can easily analyze
// analytically,
@Test
public void testDiscretizeA() {
void testDiscretizeA() {
final var contA = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0, 1, 0, 0);
final var x0 = VecBuilder.fill(1, 1);
@@ -36,7 +36,7 @@ public class DiscretizationTest {
// Check that for a simple second-order system that we can easily analyze
// analytically,
@Test
public void testDiscretizeAB() {
void testDiscretizeAB() {
final var contA = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0, 1, 0, 0);
final var contB = new MatBuilder<>(Nat.N2(), Nat.N1()).fill(0, 1);
@@ -62,7 +62,7 @@ public class DiscretizationTest {
// Test that the discrete approximation of Q ≈ ∫ e^(Aτ) Q e^(Aᵀτ) dτ
// 0
@Test
public void testDiscretizeSlowModelAQ() {
void testDiscretizeSlowModelAQ() {
final var contA = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0, 1, 0, 0);
final var contQ = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(1, 0, 0, 1);
@@ -91,7 +91,7 @@ public class DiscretizationTest {
// Test that the discrete approximation of Q ≈ ∫ e^(Aτ) Q e^(Aᵀτ) dτ
// 0
@Test
public void testDiscretizeFastModelAQ() {
void testDiscretizeFastModelAQ() {
final var contA = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0, 1, 0, -1406.29);
final var contQ = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0.0025, 0, 0, 1);
@@ -118,7 +118,7 @@ public class DiscretizationTest {
// Test that the Taylor series discretization produces nearly identical results.
@Test
public void testDiscretizeSlowModelAQTaylor() {
void testDiscretizeSlowModelAQTaylor() {
final var contA = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0, 1, 0, 0);
final var contQ = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(1, 0, 0, 1);
@@ -161,7 +161,7 @@ public class DiscretizationTest {
// Test that the Taylor series discretization produces nearly identical results.
@Test
public void testDiscretizeFastModelAQTaylor() {
void testDiscretizeFastModelAQTaylor() {
final var contA = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0, 1, 0, -1500);
final var contQ = new MatBuilder<>(Nat.N2(), Nat.N2()).fill(0.0025, 0, 0, 1);
@@ -204,7 +204,7 @@ public class DiscretizationTest {
// Test that DiscretizeR() works
@Test
public void testDiscretizeR() {
void testDiscretizeR() {
var contR = Matrix.mat(Nat.N2(), Nat.N2()).fill(2.0, 0.0, 0.0, 1.0);
var discRTruth = Matrix.mat(Nat.N2(), Nat.N2()).fill(4.0, 0.0, 0.0, 2.0);

View File

@@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test;
class LinearSystemIDTest {
@Test
public void testDrivetrainVelocitySystem() {
void testDrivetrainVelocitySystem() {
var model =
LinearSystemId.createDrivetrainVelocitySystem(DCMotor.getNEO(4), 70, 0.05, 0.4, 6.0, 6);
assertTrue(
@@ -40,7 +40,7 @@ class LinearSystemIDTest {
}
@Test
public void testElevatorSystem() {
void testElevatorSystem() {
var model = LinearSystemId.createElevatorSystem(DCMotor.getNEO(2), 5, 0.05, 12);
assertTrue(
model.getA().isEqual(Matrix.mat(Nat.N2(), Nat.N2()).fill(0, 1, 0, -99.05473), 0.001));
@@ -53,7 +53,7 @@ class LinearSystemIDTest {
}
@Test
public void testFlywheelSystem() {
void testFlywheelSystem() {
var model = LinearSystemId.createFlywheelSystem(DCMotor.getNEO(2), 0.00032, 1.0);
assertTrue(model.getA().isEqual(VecBuilder.fill(-26.87032), 0.001));
@@ -65,7 +65,7 @@ class LinearSystemIDTest {
}
@Test
public void testIdentifyPositionSystem() {
void testIdentifyPositionSystem() {
// By controls engineering in frc,
// x-dot = [0 1 | 0 -kv/ka] x = [0 | 1/ka] u
var kv = 1.0;
@@ -77,7 +77,7 @@ class LinearSystemIDTest {
}
@Test
public void testIdentifyVelocitySystem() {
void testIdentifyVelocitySystem() {
// By controls engineering in frc,
// V = kv * velocity + ka * acceleration
// x-dot = -kv/ka * v + 1/ka \cdot V

View File

@@ -12,9 +12,9 @@ import edu.wpi.first.math.VecBuilder;
import edu.wpi.first.math.numbers.N1;
import org.junit.jupiter.api.Test;
public class NumericalIntegrationTest {
class NumericalIntegrationTest {
@Test
public void testExponential() {
void testExponential() {
Matrix<N1, N1> y0 = VecBuilder.fill(0.0);
var y1 =
@@ -31,7 +31,7 @@ public class NumericalIntegrationTest {
}
@Test
public void testExponentialRKF45() {
void testExponentialRKF45() {
Matrix<N1, N1> y0 = VecBuilder.fill(0.0);
var y1 =
@@ -49,7 +49,7 @@ public class NumericalIntegrationTest {
}
@Test
public void testExponentialRKDP() {
void testExponentialRKDP() {
Matrix<N1, N1> y0 = VecBuilder.fill(0.0);
var y1 =

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.math.Nat;
import edu.wpi.first.math.numbers.N1;
import org.junit.jupiter.api.Test;
public class RungeKuttaTimeVaryingTest {
class RungeKuttaTimeVaryingTest {
private static Matrix<N1, N1> rungeKuttaTimeVaryingSolution(double t) {
return new MatBuilder<>(Nat.N1(), Nat.N1())
.fill(12.0 * Math.exp(t) / (Math.pow(Math.exp(t) + 1.0, 2.0)));
@@ -26,7 +26,7 @@ public class RungeKuttaTimeVaryingTest {
//
// x(t) = 12 * e^t / ((e^t + 1)^2)
@Test
public void rungeKuttaTimeVaryingTest() {
void rungeKuttaTimeVaryingTest() {
final var y0 = rungeKuttaTimeVaryingSolution(5.0);
final var y1 =

View File

@@ -16,7 +16,7 @@ import edu.wpi.first.math.util.Units;
import java.util.List;
import org.junit.jupiter.api.Test;
public class EllipticalRegionConstraintTest {
class EllipticalRegionConstraintTest {
@Test
void testConstraint() {
// Create constraints

View File

@@ -16,7 +16,7 @@ import edu.wpi.first.math.util.Units;
import java.util.List;
import org.junit.jupiter.api.Test;
public class RectangularRegionConstraintTest {
class RectangularRegionConstraintTest {
@Test
void testConstraint() {
// Create constraints

View File

@@ -12,7 +12,7 @@ import edu.wpi.first.math.trajectory.constraint.DifferentialDriveKinematicsConst
import java.util.List;
import org.junit.jupiter.api.Test;
public class TrajectoryJsonTest {
class TrajectoryJsonTest {
@Test
void deserializeMatches() {
var config =

View File

@@ -201,7 +201,7 @@ class TrapezoidProfileTest {
for (int i = 0; i < 400; i++) {
profile = new TrapezoidProfile(constraints, goal, state);
state = profile.calculate(kDt);
if (!reachedGoal && (Math.abs(state.velocity - 1) < 10e-5)) {
if (!reachedGoal && Math.abs(state.velocity - 1) < 10e-5) {
assertNear(predictedTimeLeft, i / 100.0, 2e-2);
reachedGoal = true;
}
@@ -244,7 +244,7 @@ class TrapezoidProfileTest {
for (int i = 0; i < 400; i++) {
profile = new TrapezoidProfile(constraints, goal, state);
state = profile.calculate(kDt);
if (!reachedGoal && (Math.abs(state.velocity + 1) < 10e-5)) {
if (!reachedGoal && Math.abs(state.velocity + 1) < 10e-5) {
assertNear(predictedTimeLeft, i / 100.0, 2e-2);
reachedGoal = true;
}

View File

@@ -64,6 +64,7 @@ class UnitsTest extends UtilityClassTest<Units> {
assertEquals(1500, Units.secondsToMilliseconds(1.5), 1e-2);
}
@Test
void kilogramsToLbsTest() {
assertEquals(2.20462, Units.kilogramsToLbs(1), 1e-2);
}

View File

@@ -34,19 +34,20 @@ public abstract class UtilityClassTest<T> {
}
@Test
public void singleConstructorTest() {
void singleConstructorTest() {
assertEquals(1, m_clazz.getDeclaredConstructors().length, "More than one constructor defined");
}
@Test
public void constructorPrivateTest() {
void constructorPrivateTest() {
Constructor<?> constructor = m_clazz.getDeclaredConstructors()[0];
assertFalse(constructor.canAccess(null), "Constructor is not private");
}
@Test
public void constructorReflectionTest() {
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
void constructorReflectionTest() {
Constructor<?> constructor = m_clazz.getDeclaredConstructors()[0];
constructor.setAccessible(true);
assertThrows(InvocationTargetException.class, constructor::newInstance);