]> git.taranathan.com Git - FRC2026.git/commitdiff
Fix unit test.
authorArnav495 <arnieincyberland@gmail.com>
Thu, 5 Feb 2026 18:47:01 +0000 (10:47 -0800)
committerArnav495 <arnieincyberland@gmail.com>
Thu, 5 Feb 2026 18:47:01 +0000 (10:47 -0800)
src/test/java/frc/robot/util/ShooterPhysicsTest.java

index 50076cea3513769d538adfe814bdd0d752b1155d..8dd3a530ac7e1a6f960b9c3568c0ed0b450ad082 100644 (file)
@@ -82,21 +82,21 @@ class ShooterPhysicsTest {
 
        @Test
        public void yawTest() {
-               ShooterPhysics.TurretState state1 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state1 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(1, 0, 0), 1);
                // different for this one because it's close to 0, so the angle wraps and
                // assertEquals can't handle that
                assertTrue(Math.abs((state1.yaw()).getRadians()) <= epsilon, state1.toString());
 
-               ShooterPhysics.TurretState state2 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state2 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(0, 1, 0), 1);
                assertEquals(new Rotation2d(Math.PI / 2).getRadians(), state2.yaw().getRadians(), epsilon);
 
-               ShooterPhysics.TurretState state3 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state3 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(-1, 0, 0), 1);
                assertEquals(new Rotation2d(Math.PI).getRadians(), state3.yaw().getRadians(), epsilon);
 
-               ShooterPhysics.TurretState state4 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state4 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(0, -1, 0), 1);
                assertEquals(new Rotation2d(-Math.PI / 2).getRadians(), state4.yaw().getRadians(), epsilon);
        }
@@ -104,31 +104,29 @@ class ShooterPhysicsTest {
        @Test
        public void pitchTest() {
                // check random values are within range
-               ShooterPhysics.TurretState state1 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state1 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(1, 0, 0), 1);
                assertTrue(state1.pitch() >= 0 && state1.pitch() <= Math.PI / 2, state1.toString());
 
                ShooterPhysics.TurretState state2 = ShooterPhysics.getShotParams(new Translation2d(12.2, -1.3),
-                               new Translation2d(.2, 1.2),
-                               new Translation3d(1.1, 12, 11.1), 22.1);
+                               new Translation3d(1.1, 12, 11.1).minus(new Translation3d(.2, 1.2, 0)), 22.1);
                assertTrue(state2.pitch() >= 0 && state2.pitch() <= Math.PI / 2, state2.toString());
 
                ShooterPhysics.TurretState state3 = ShooterPhysics.getShotParams(new Translation2d(1.9, 9.1),
-                               new Translation2d(-.3, -8.4),
-                               new Translation3d(11.2, -13.1, 4.1), 5.6);
+                               new Translation3d(11.2, -13.1, 4.1).minus(new Translation3d(-.3, -8.4, 0)), 5.6);
                assertTrue(state3.pitch() >= 0 && state3.pitch() <= Math.PI / 2, state3.toString());
 
                // try a steep shot
-               ShooterPhysics.TurretState state4 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state4 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(1, 0, 99), 100);
                assertTrue(state4.pitch() >= Math.PI * 7 / 16 && state4.pitch() <= Math.PI / 2, state4.toString());
 
-               ShooterPhysics.TurretState state5 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state5 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(1, 0, 0), 100);
                assertTrue(state5.pitch() >= Math.PI * 7 / 16 && state5.pitch() <= Math.PI / 2, state5.toString());
 
                // try a shallow shot
-               ShooterPhysics.TurretState state6 = ShooterPhysics.getShotParams(Translation2d.kZero, Translation2d.kZero,
+               ShooterPhysics.TurretState state6 = ShooterPhysics.getShotParams(Translation2d.kZero,
                                new Translation3d(100, 50, 1), 2);
                assertTrue(state6.pitch() >= 0 && state6.pitch() <= Math.PI / 16, state6.toString());
        }