mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Always statically import JUnit Assertions
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
|
||||
package org.photonvision.common.configuration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -87,9 +90,9 @@ public class ConfigTest {
|
||||
Path.of(configMgr.configDirectoryFile.toString(), "cameras", "TestCamera")
|
||||
.toAbsolutePath()
|
||||
.toString());
|
||||
Assertions.assertTrue(camConfDir.exists(), "TestCamera config folder not found!");
|
||||
assertTrue(camConfDir.exists(), "TestCamera config folder not found!");
|
||||
|
||||
Assertions.assertTrue(
|
||||
assertTrue(
|
||||
Files.exists(Path.of(configMgr.configDirectoryFile.toString(), "networkSettings.json")),
|
||||
"networkSettings.json file not found!");
|
||||
}
|
||||
@@ -104,17 +107,17 @@ public class ConfigTest {
|
||||
var apriltagPipelineSettings =
|
||||
configMgr.getConfig().getCameraConfigurations().get("TestCamera").pipelineSettings.get(2);
|
||||
|
||||
Assertions.assertEquals(REFLECTIVE_PIPELINE_SETTINGS, reflectivePipelineSettings);
|
||||
Assertions.assertEquals(COLORED_SHAPE_PIPELINE_SETTINGS, coloredShapePipelineSettings);
|
||||
Assertions.assertEquals(APRIL_TAG_PIPELINE_SETTINGS, apriltagPipelineSettings);
|
||||
assertEquals(REFLECTIVE_PIPELINE_SETTINGS, reflectivePipelineSettings);
|
||||
assertEquals(COLORED_SHAPE_PIPELINE_SETTINGS, coloredShapePipelineSettings);
|
||||
assertEquals(APRIL_TAG_PIPELINE_SETTINGS, apriltagPipelineSettings);
|
||||
|
||||
Assertions.assertTrue(
|
||||
assertTrue(
|
||||
reflectivePipelineSettings instanceof ReflectivePipelineSettings,
|
||||
"Config loaded pipeline settings for index 0 not of expected type ReflectivePipelineSettings!");
|
||||
Assertions.assertTrue(
|
||||
assertTrue(
|
||||
coloredShapePipelineSettings instanceof ColoredShapePipelineSettings,
|
||||
"Config loaded pipeline settings for index 1 not of expected type ColoredShapePipelineSettings!");
|
||||
Assertions.assertTrue(
|
||||
assertTrue(
|
||||
apriltagPipelineSettings instanceof AprilTagPipelineSettings,
|
||||
"Config loaded pipeline settings for index 2 not of expected type AprilTagPipelineSettings!");
|
||||
}
|
||||
@@ -184,7 +187,7 @@ public class ConfigTest {
|
||||
AprilTagPipelineSettings settings =
|
||||
(AprilTagPipelineSettings)
|
||||
JacksonUtils.deserialize(tempFile.toPath(), CVPipelineSettings.class);
|
||||
Assertions.assertEquals(TargetModel.kAprilTag6in_16h5, settings.targetModel);
|
||||
assertEquals(TargetModel.kAprilTag6in_16h5, settings.targetModel);
|
||||
|
||||
tempFile.delete();
|
||||
}
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
|
||||
package org.photonvision.common.configuration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class NetworkConfigTest {
|
||||
@@ -30,7 +32,7 @@ public class NetworkConfigTest {
|
||||
var mapper = new ObjectMapper();
|
||||
var path = Path.of("netTest.json");
|
||||
mapper.writeValue(path.toFile(), new NetworkConfig());
|
||||
Assertions.assertDoesNotThrow(() -> mapper.readValue(path.toFile(), NetworkConfig.class));
|
||||
assertDoesNotThrow(() -> mapper.readValue(path.toFile(), NetworkConfig.class));
|
||||
new File("netTest.json").delete();
|
||||
}
|
||||
|
||||
@@ -40,13 +42,13 @@ public class NetworkConfigTest {
|
||||
var folder = Path.of("test-resources/network-old-team-number");
|
||||
var configMgr = new ConfigManager(folder, new LegacyConfigProvider(folder));
|
||||
configMgr.load();
|
||||
Assertions.assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress);
|
||||
assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress);
|
||||
}
|
||||
{
|
||||
var folder = Path.of("test-resources/network-new-team-number");
|
||||
var configMgr = new ConfigManager(folder, new LegacyConfigProvider(folder));
|
||||
configMgr.load();
|
||||
Assertions.assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress);
|
||||
assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
package org.photonvision.common.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -26,7 +31,6 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
@@ -39,7 +43,7 @@ public class LogFileManagementTest {
|
||||
|
||||
String testDir = ConfigManager.getInstance().getLogsDir().toString() + "/test";
|
||||
|
||||
Assertions.assertDoesNotThrow(() -> Files.createDirectories(Path.of(testDir)));
|
||||
assertDoesNotThrow(() -> Files.createDirectories(Path.of(testDir)));
|
||||
|
||||
// Create a bunch of log files with dummy contents.
|
||||
for (int fileIdx = 0; fileIdx < Logger.MAX_LOGS_TO_KEEP + 5; fileIdx++) {
|
||||
@@ -52,20 +56,19 @@ public class LogFileManagementTest {
|
||||
testLogWriter.write("Test log contents created for testing purposes only");
|
||||
testLogWriter.close();
|
||||
} catch (IOException e) {
|
||||
Assertions.fail("Could not create test files");
|
||||
fail("Could not create test files");
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm new log files were created
|
||||
Assertions.assertTrue(
|
||||
assertTrue(
|
||||
Logger.MAX_LOGS_TO_KEEP + 5 <= countLogFiles(testDir), "Not enough log files discovered");
|
||||
|
||||
// Run the log cleanup routine
|
||||
Logger.cleanLogs(Path.of(testDir));
|
||||
|
||||
// Confirm we deleted log files
|
||||
Assertions.assertEquals(
|
||||
Logger.MAX_LOGS_TO_KEEP, countLogFiles(testDir), "Not enough log files deleted");
|
||||
assertEquals(Logger.MAX_LOGS_TO_KEEP, countLogFiles(testDir), "Not enough log files deleted");
|
||||
|
||||
// Clean uptest directory
|
||||
org.photonvision.common.util.file.FileUtils.deleteDirectory(Path.of(testDir));
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package org.photonvision.common.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TimedTaskManagerTest {
|
||||
@@ -27,6 +28,6 @@ public class TimedTaskManagerTest {
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
TimedTaskManager.getInstance().addTask("TaskManagerTest", i::getAndIncrement, 2);
|
||||
Thread.sleep(400);
|
||||
Assertions.assertEquals(200, i.get(), 15);
|
||||
assertEquals(200, i.get(), 15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
package org.photonvision.hardware;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.configuration.HardwareConfig;
|
||||
import org.photonvision.common.hardware.GPIO.CustomGPIO;
|
||||
@@ -37,8 +37,7 @@ public class HardwareConfigTest {
|
||||
assertEquals(config.deviceName(), "PhotonVision");
|
||||
assertEquals(config.deviceLogoPath(), "photonvision.png");
|
||||
assertEquals(config.supportURL(), "https://support.photonvision.com");
|
||||
Assertions.assertArrayEquals(
|
||||
config.ledPins().stream().mapToInt(i -> i).toArray(), new int[] {2, 13});
|
||||
assertArrayEquals(config.ledPins().stream().mapToInt(i -> i).toArray(), new int[] {2, 13});
|
||||
CustomGPIO.setConfig(config);
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package org.photonvision.vision;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.vision.camera.CameraQuirk;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
@@ -35,7 +36,7 @@ public class QuirkyCameraTest {
|
||||
}
|
||||
|
||||
QuirkyCamera psEye = QuirkyCamera.getQuirkyCamera(0x1415, 0x2000);
|
||||
Assertions.assertEquals(psEye.quirks, ps3EyeQuirks);
|
||||
assertEquals(psEye.quirks, ps3EyeQuirks);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -46,6 +47,6 @@ public class QuirkyCameraTest {
|
||||
}
|
||||
|
||||
QuirkyCamera quirkless = QuirkyCamera.getQuirkyCamera(1234, 8888);
|
||||
Assertions.assertEquals(quirkless.quirks, noQuirks);
|
||||
assertEquals(quirkless.quirks, noQuirks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package org.photonvision.vision.pipeline;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
@@ -72,33 +73,31 @@ public class AprilTagTest {
|
||||
|
||||
// Test corner order
|
||||
var corners = target.getTargetCorners();
|
||||
Assertions.assertEquals(260, corners.get(0).x, 10);
|
||||
Assertions.assertEquals(245, corners.get(0).y, 10);
|
||||
Assertions.assertEquals(315, corners.get(1).x, 10);
|
||||
Assertions.assertEquals(245, corners.get(1).y, 10);
|
||||
Assertions.assertEquals(315, corners.get(2).x, 10);
|
||||
Assertions.assertEquals(190, corners.get(2).y, 10);
|
||||
Assertions.assertEquals(260, corners.get(3).x, 10);
|
||||
Assertions.assertEquals(190, corners.get(3).y, 10);
|
||||
assertEquals(260, corners.get(0).x, 10);
|
||||
assertEquals(245, corners.get(0).y, 10);
|
||||
assertEquals(315, corners.get(1).x, 10);
|
||||
assertEquals(245, corners.get(1).y, 10);
|
||||
assertEquals(315, corners.get(2).x, 10);
|
||||
assertEquals(190, corners.get(2).y, 10);
|
||||
assertEquals(260, corners.get(3).x, 10);
|
||||
assertEquals(190, corners.get(3).y, 10);
|
||||
|
||||
var pose = target.getBestCameraToTarget3d();
|
||||
// Test pose estimate translation
|
||||
Assertions.assertEquals(2, pose.getTranslation().getX(), 0.2);
|
||||
Assertions.assertEquals(0.1, pose.getTranslation().getY(), 0.2);
|
||||
Assertions.assertEquals(0.0, pose.getTranslation().getZ(), 0.2);
|
||||
assertEquals(2, pose.getTranslation().getX(), 0.2);
|
||||
assertEquals(0.1, pose.getTranslation().getY(), 0.2);
|
||||
assertEquals(0.0, pose.getTranslation().getZ(), 0.2);
|
||||
|
||||
// Test pose estimate rotation
|
||||
// We expect the object axes to be in NWU, with the x-axis coming out of the tag
|
||||
// This visible tag is facing the camera almost parallel, so in world space:
|
||||
|
||||
// The object's X axis should be (-1, 0, 0)
|
||||
Assertions.assertEquals(
|
||||
-1, new Translation3d(1, 0, 0).rotateBy(pose.getRotation()).getX(), 0.1);
|
||||
assertEquals(-1, new Translation3d(1, 0, 0).rotateBy(pose.getRotation()).getX(), 0.1);
|
||||
// The object's Y axis should be (0, -1, 0)
|
||||
Assertions.assertEquals(
|
||||
-1, new Translation3d(0, 1, 0).rotateBy(pose.getRotation()).getY(), 0.1);
|
||||
assertEquals(-1, new Translation3d(0, 1, 0).rotateBy(pose.getRotation()).getY(), 0.1);
|
||||
// The object's Z axis should be (0, 0, 1)
|
||||
Assertions.assertEquals(1, new Translation3d(0, 0, 1).rotateBy(pose.getRotation()).getZ(), 0.1);
|
||||
assertEquals(1, new Translation3d(0, 0, 1).rotateBy(pose.getRotation()).getZ(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,8 +133,8 @@ public class AprilTagTest {
|
||||
|
||||
// these numbers are not *accurate*, but they are known and expected
|
||||
var pose = pipelineResult.targets.get(0).getBestCameraToTarget3d();
|
||||
Assertions.assertEquals(4.14, pose.getTranslation().getX(), 0.2);
|
||||
Assertions.assertEquals(2, pose.getTranslation().getY(), 0.2);
|
||||
Assertions.assertEquals(0.0, pose.getTranslation().getZ(), 0.2);
|
||||
assertEquals(4.14, pose.getTranslation().getX(), 0.2);
|
||||
assertEquals(2, pose.getTranslation().getY(), 0.2);
|
||||
assertEquals(0.0, pose.getTranslation().getZ(), 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package org.photonvision.vision.pipeline;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
@@ -72,32 +73,30 @@ public class ArucoPipelineTest {
|
||||
|
||||
// Test corner order
|
||||
var corners = target.getTargetCorners();
|
||||
Assertions.assertEquals(260, corners.get(0).x, 10);
|
||||
Assertions.assertEquals(245, corners.get(0).y, 10);
|
||||
Assertions.assertEquals(315, corners.get(1).x, 10);
|
||||
Assertions.assertEquals(245, corners.get(1).y, 10);
|
||||
Assertions.assertEquals(315, corners.get(2).x, 10);
|
||||
Assertions.assertEquals(190, corners.get(2).y, 10);
|
||||
Assertions.assertEquals(260, corners.get(3).x, 10);
|
||||
Assertions.assertEquals(190, corners.get(3).y, 10);
|
||||
assertEquals(260, corners.get(0).x, 10);
|
||||
assertEquals(245, corners.get(0).y, 10);
|
||||
assertEquals(315, corners.get(1).x, 10);
|
||||
assertEquals(245, corners.get(1).y, 10);
|
||||
assertEquals(315, corners.get(2).x, 10);
|
||||
assertEquals(190, corners.get(2).y, 10);
|
||||
assertEquals(260, corners.get(3).x, 10);
|
||||
assertEquals(190, corners.get(3).y, 10);
|
||||
|
||||
var pose = target.getBestCameraToTarget3d();
|
||||
// Test pose estimate translation
|
||||
Assertions.assertEquals(2, pose.getTranslation().getX(), 0.2);
|
||||
Assertions.assertEquals(0.1, pose.getTranslation().getY(), 0.2);
|
||||
Assertions.assertEquals(0.0, pose.getTranslation().getZ(), 0.2);
|
||||
assertEquals(2, pose.getTranslation().getX(), 0.2);
|
||||
assertEquals(0.1, pose.getTranslation().getY(), 0.2);
|
||||
assertEquals(0.0, pose.getTranslation().getZ(), 0.2);
|
||||
|
||||
// Test pose estimate rotation
|
||||
// We expect the object axes to be in NWU, with the x-axis coming out of the tag
|
||||
// This visible tag is facing the camera almost parallel, so in world space:
|
||||
|
||||
// The object's X axis should be (-1, 0, 0)
|
||||
Assertions.assertEquals(
|
||||
-1, new Translation3d(1, 0, 0).rotateBy(pose.getRotation()).getX(), 0.1);
|
||||
assertEquals(-1, new Translation3d(1, 0, 0).rotateBy(pose.getRotation()).getX(), 0.1);
|
||||
// The object's Y axis should be (0, -1, 0)
|
||||
Assertions.assertEquals(
|
||||
-1, new Translation3d(0, 1, 0).rotateBy(pose.getRotation()).getY(), 0.1);
|
||||
assertEquals(-1, new Translation3d(0, 1, 0).rotateBy(pose.getRotation()).getY(), 0.1);
|
||||
// The object's Z axis should be (0, 0, 1)
|
||||
Assertions.assertEquals(1, new Translation3d(0, 0, 1).rotateBy(pose.getRotation()).getZ(), 0.1);
|
||||
assertEquals(1, new Translation3d(0, 0, 1).rotateBy(pose.getRotation()).getZ(), 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junitpioneer.jupiter.cartesian.CartesianTest;
|
||||
@@ -324,14 +323,11 @@ public class CalibrationRotationPipeTest {
|
||||
System.out.println("Base: " + pose_base);
|
||||
System.out.println("rot-unrot: " + pose_unrotated);
|
||||
|
||||
Assertions.assertEquals(pose_base.getX(), pose_unrotated.getX(), 0.01);
|
||||
Assertions.assertEquals(pose_base.getY(), pose_unrotated.getY(), 0.01);
|
||||
Assertions.assertEquals(pose_base.getZ(), pose_unrotated.getZ(), 0.01);
|
||||
Assertions.assertEquals(
|
||||
pose_base.getRotation().getX(), pose_unrotated.getRotation().getX(), 0.01);
|
||||
Assertions.assertEquals(
|
||||
pose_base.getRotation().getY(), pose_unrotated.getRotation().getY(), 0.01);
|
||||
Assertions.assertEquals(
|
||||
pose_base.getRotation().getZ(), pose_unrotated.getRotation().getZ(), 0.01);
|
||||
assertEquals(pose_base.getX(), pose_unrotated.getX(), 0.01);
|
||||
assertEquals(pose_base.getY(), pose_unrotated.getY(), 0.01);
|
||||
assertEquals(pose_base.getZ(), pose_unrotated.getZ(), 0.01);
|
||||
assertEquals(pose_base.getRotation().getX(), pose_unrotated.getRotation().getX(), 0.01);
|
||||
assertEquals(pose_base.getRotation().getY(), pose_unrotated.getRotation().getY(), 0.01);
|
||||
assertEquals(pose_base.getRotation().getZ(), pose_unrotated.getRotation().getZ(), 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
package org.photonvision.vision.pipeline;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PipelineProfilerTest {
|
||||
@@ -35,7 +37,7 @@ public class PipelineProfilerTest {
|
||||
|
||||
System.out.println(validResult);
|
||||
|
||||
Assertions.assertEquals("Invalid data", invalidResult);
|
||||
Assertions.assertTrue(validResult.contains("Total: 45.0ms"));
|
||||
assertEquals("Invalid data", invalidResult);
|
||||
assertTrue(validResult.contains("Total: 45.0ms"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
package org.photonvision.vision.pipeline;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
@@ -62,8 +64,8 @@ public class ReflectivePipelineTest {
|
||||
pipelineResult = pipeline.run(frameProvider.get(), QuirkyCamera.DefaultCamera);
|
||||
TestUtils.printTestResults(pipelineResult);
|
||||
|
||||
Assertions.assertTrue(pipelineResult.hasTargets());
|
||||
Assertions.assertEquals(2, pipelineResult.targets.size(), "Target count wrong!");
|
||||
assertTrue(pipelineResult.hasTargets());
|
||||
assertEquals(2, pipelineResult.targets.size(), "Target count wrong!");
|
||||
|
||||
TestUtils.showImage(pipelineResult.inputAndOutputFrame.colorImage.getMat(), "Pipeline output");
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
|
||||
package org.photonvision.vision.processes;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
@@ -62,7 +63,7 @@ public class PipelineManagerTest {
|
||||
for (int i = 2; i < 15; i++) {
|
||||
expected.add("Another (" + i + ")");
|
||||
}
|
||||
Assertions.assertEquals(expected, nicks);
|
||||
assertEquals(expected, nicks);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.photonvision.vision.processes;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@@ -25,7 +26,6 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
@@ -188,7 +188,7 @@ public class VisionModuleManagerTest {
|
||||
|
||||
sleep(1500);
|
||||
|
||||
Assertions.assertNotNull(module0DataConsumer.result);
|
||||
assertNotNull(module0DataConsumer.result);
|
||||
TestUtils.printTestResults(module0DataConsumer.result);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import edu.wpi.first.math.geometry.Rotation3d;
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
@@ -316,9 +315,9 @@ public class TargetCalculationsTest {
|
||||
Point crosshairPointOutside =
|
||||
TargetCalculations.calculateDualOffsetCrosshair(dualOffsetValues, 1);
|
||||
|
||||
Assertions.assertEquals(expectedHalfway.x, crosshairPointHalfway.x);
|
||||
Assertions.assertEquals(expectedHalfway.y, crosshairPointHalfway.y);
|
||||
Assertions.assertEquals(expectedOutside.x, crosshairPointOutside.x);
|
||||
Assertions.assertEquals(expectedOutside.y, crosshairPointOutside.y);
|
||||
assertEquals(expectedHalfway.x, crosshairPointHalfway.x);
|
||||
assertEquals(expectedHalfway.y, crosshairPointHalfway.y);
|
||||
assertEquals(expectedOutside.x, crosshairPointOutside.x);
|
||||
assertEquals(expectedOutside.y, crosshairPointOutside.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -95,7 +94,7 @@ class PhotonCameraTest {
|
||||
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
Assertions.assertDoesNotThrow(
|
||||
assertDoesNotThrow(
|
||||
() -> {
|
||||
var packet = new Packet(1);
|
||||
var ret = new PhotonPipelineResult();
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
|
||||
package org.photonvision;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import edu.wpi.first.math.geometry.*;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class PhotonUtilTest {
|
||||
@@ -40,7 +41,7 @@ class PhotonUtilTest {
|
||||
var dist =
|
||||
PhotonUtils.calculateDistanceToTargetMeters(camHeight, targetHeight, camPitch, targetPitch);
|
||||
|
||||
Assertions.assertEquals(3.464, dist, 0.01);
|
||||
assertEquals(3.464, dist, 0.01);
|
||||
|
||||
camHeight = 1;
|
||||
targetHeight = 2;
|
||||
@@ -49,7 +50,7 @@ class PhotonUtilTest {
|
||||
|
||||
dist =
|
||||
PhotonUtils.calculateDistanceToTargetMeters(camHeight, targetHeight, camPitch, targetPitch);
|
||||
Assertions.assertEquals(5.671, dist, 0.01);
|
||||
assertEquals(5.671, dist, 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,9 +76,9 @@ class PhotonUtilTest {
|
||||
fieldToTarget,
|
||||
cameraToRobot);
|
||||
|
||||
Assertions.assertEquals(-3.464, fieldToRobot.getX(), 0.1);
|
||||
Assertions.assertEquals(0, fieldToRobot.getY(), 0.1);
|
||||
Assertions.assertEquals(0, fieldToRobot.getRotation().getDegrees(), 0.1);
|
||||
assertEquals(-3.464, fieldToRobot.getX(), 0.1);
|
||||
assertEquals(0, fieldToRobot.getY(), 0.1);
|
||||
assertEquals(0, fieldToRobot.getRotation().getDegrees(), 0.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,8 +95,8 @@ class PhotonUtilTest {
|
||||
new Translation2d(Units.inchesToMeters(324), Units.inchesToMeters(162)),
|
||||
new Rotation2d());
|
||||
var currentPose = new Pose2d(0, 0, Rotation2d.fromDegrees(0));
|
||||
Assertions.assertEquals(4.0, fieldToRobot.getX());
|
||||
Assertions.assertEquals(
|
||||
assertEquals(4.0, fieldToRobot.getX());
|
||||
assertEquals(
|
||||
Math.toDegrees(Math.atan2((Units.inchesToMeters(162)), (Units.inchesToMeters(324)))),
|
||||
PhotonUtils.getYawToPose(currentPose, targetPose).getDegrees());
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
package org.photonvision;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PhotonVersionTest {
|
||||
@@ -52,11 +53,11 @@ public class PhotonVersionTest {
|
||||
|
||||
@Test
|
||||
public void testVersion() {
|
||||
Assertions.assertTrue(versionMatches("v2021.1.6", "v2021.1.6"));
|
||||
Assertions.assertTrue(versionMatches("dev-v2021.1.6", "v2021.1.6"));
|
||||
Assertions.assertTrue(versionMatches("dev-v2021.1.6-5-gca49ea50", "v2021.1.6"));
|
||||
Assertions.assertFalse(versionMatches("", "v2021.1.6"));
|
||||
Assertions.assertFalse(versionMatches("v2021.1.6", ""));
|
||||
assertTrue(versionMatches("v2021.1.6", "v2021.1.6"));
|
||||
assertTrue(versionMatches("dev-v2021.1.6", "v2021.1.6"));
|
||||
assertTrue(versionMatches("dev-v2021.1.6-5-gca49ea50", "v2021.1.6"));
|
||||
assertFalse(versionMatches("", "v2021.1.6"));
|
||||
assertFalse(versionMatches("v2021.1.6", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package org.photonvision;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@@ -50,7 +51,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -111,7 +111,7 @@ class VisionSystemSimTest {
|
||||
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
Assertions.assertDoesNotThrow(
|
||||
assertDoesNotThrow(
|
||||
() -> {
|
||||
var sysUnderTest = new VisionSystemSim("Test");
|
||||
sysUnderTest.addVisionTargets(
|
||||
|
||||
Reference in New Issue
Block a user