mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Bootup sprint (#18)
* Did some stuff * Fix gradle, start implementing mjpeg frame consumer * Did some stuff * bade changes * rename camera config to USBCameraConfiguration, add name * unrename cameraconfiguration * Add pub/sub framework * Add setResolution to mjpeg frame consumer * add NTDataConsumer * Add some totally broken hsv hacks * Start refactoring UI data * Update index.js * Commit and push, he says * Fix up some errors * Fix input tab * Fix fps * Update index.js * Add pipeline field setting, update PipelineManager, fix nullpointers and USBCameraSettables * Change v-model to point to data() * update hsv to use mutations * Work on saving, fix hsv * Rename shouldErode/shouldDilate to erode and dilate * Hook all the tabs up to the Store * Change handleData to handlePipelineData * camera quirk redo, add ICCSub to SocketHandler * Fix some property names * Fixed tons of naming in UI, fix backend for multi-val PSCs, fix PSC enums * change pipeline type to an int in store * Fix mutation naming * Attempt threshold fix * Update SocketHandler.java * Add truthy data sending * Start adding logging support * [UI] Add delay to slider input boxes (#1) * [UI] [Backend] potentially fix camera settings, various logging tweaks * Don't release raw input mat * add setVideoModeIndex to vision settables * Implement pipeline index in socket handler, add framework for renaming/changing pipes * (ish) get pipeline change working * Create index.html * Cleanups, fix pipeline index bug, fix stream res for MJPG, add dashboard stream (unused) * Refactor UI to use mutatePipeline, send pipeline results * Update NetworkConfig.java * Change double to number * Run spotless * Fix reversal of large/small comparators * Fix left/right * Fix pitch/yaw calculation bug, fix area bug * Use Vue.set instead of assignment This fixes {{ }} * Update App.vue * run spotless * Actually add pipelines and reassign indecies * Delete old pipeline configs Fixes duplication on renaming pipeline * Start working on deleting pipes * Fix camera nickname change * run spotless * Fix some test stuff * Update VisionModuleManagerTest.java * vision source manager test is still broken * Fix VisionSourceManager test * Apply spotless 2 electric boogaloo Co-authored-by: Banks Troutman <btrout.dhrs@gmail.com> Co-authored-by: Declan Freeman-Gleason <declanfreemangleason@gmail.com> Co-authored-by: Aaryan Agrawal <54345060+13Ducks@users.noreply.github.com>
This commit is contained in:
@@ -32,8 +32,8 @@ import org.photonvision.vision.opencv.CVMat;
|
||||
import org.photonvision.vision.opencv.ContourGroupingMode;
|
||||
import org.photonvision.vision.opencv.ContourIntersectionDirection;
|
||||
import org.photonvision.vision.pipeline.CVPipeline;
|
||||
import org.photonvision.vision.pipeline.CVPipelineResult;
|
||||
import org.photonvision.vision.pipeline.ReflectivePipeline;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
|
||||
/** Various tests that check performance on long-running tasks (i.e. a pipeline) */
|
||||
public class BenchmarkTest {
|
||||
|
||||
@@ -90,7 +90,6 @@ public class ConfigTest {
|
||||
@Test
|
||||
@Order(2)
|
||||
public void deserializeConfig() {
|
||||
configMgr.load();
|
||||
|
||||
var reflectivePipelineSettings =
|
||||
configMgr.getConfig().getCameraConfigurations().get("TestCamera").pipelineSettings.get(0);
|
||||
|
||||
@@ -17,23 +17,33 @@
|
||||
|
||||
package org.photonvision.vision;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.vision.camera.CameraQuirks;
|
||||
import org.photonvision.vision.camera.CameraQuirk;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
|
||||
public class QuirkyCameraTest {
|
||||
@Test
|
||||
public void ps3EyeTest() {
|
||||
QuirkyCamera psEye = new QuirkyCamera(0x1415, 0x2000, "psEye");
|
||||
Assertions.assertEquals(psEye.quirks, List.of(CameraQuirks.Gain));
|
||||
HashMap<CameraQuirk, Boolean> ps3EyeQuirks = new HashMap<>();
|
||||
ps3EyeQuirks.put(CameraQuirk.Gain, true);
|
||||
for (var q : CameraQuirk.values()) {
|
||||
ps3EyeQuirks.putIfAbsent(q, false);
|
||||
}
|
||||
|
||||
QuirkyCamera psEye = QuirkyCamera.getQuirkyCamera(0x1415, 0x2000, "psEye");
|
||||
Assertions.assertEquals(psEye.quirks, ps3EyeQuirks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quirklessCameraTest() {
|
||||
QuirkyCamera noQuirk = new QuirkyCamera(1234, 888, "empty");
|
||||
Assertions.assertEquals(noQuirk.quirks, new ArrayList<>());
|
||||
HashMap<CameraQuirk, Boolean> noQuirks = new HashMap<>();
|
||||
for (var q : CameraQuirk.values()) {
|
||||
noQuirks.put(q, false);
|
||||
}
|
||||
|
||||
QuirkyCamera quirkless = QuirkyCamera.getQuirkyCamera(1234, 888, "empty");
|
||||
Assertions.assertEquals(quirkless.quirks, noQuirks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.photonvision.vision.opencv.CVMat;
|
||||
import org.photonvision.vision.opencv.ContourGroupingMode;
|
||||
import org.photonvision.vision.opencv.ContourIntersectionDirection;
|
||||
import org.photonvision.vision.opencv.ContourShape;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
import org.photonvision.vision.target.TargetModel;
|
||||
import org.photonvision.vision.target.TrackedTarget;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.photonvision.vision.frame.provider.FileFrameProvider;
|
||||
import org.photonvision.vision.opencv.ContourGroupingMode;
|
||||
import org.photonvision.vision.opencv.ContourIntersectionDirection;
|
||||
import org.photonvision.vision.opencv.ContourShape;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
|
||||
public class ColoredShapePipelineTest {
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.photonvision.vision.frame.provider.FileFrameProvider;
|
||||
import org.photonvision.vision.opencv.CVMat;
|
||||
import org.photonvision.vision.opencv.ContourGroupingMode;
|
||||
import org.photonvision.vision.opencv.ContourIntersectionDirection;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
|
||||
public class ReflectivePipelineTest {
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.photonvision.vision.frame.provider.FileFrameProvider;
|
||||
import org.photonvision.vision.opencv.CVMat;
|
||||
import org.photonvision.vision.opencv.ContourGroupingMode;
|
||||
import org.photonvision.vision.opencv.ContourIntersectionDirection;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
import org.photonvision.vision.target.TargetModel;
|
||||
import org.photonvision.vision.target.TrackedTarget;
|
||||
|
||||
|
||||
@@ -18,15 +18,17 @@
|
||||
package org.photonvision.vision.processes;
|
||||
|
||||
import edu.wpi.cscore.VideoMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.datatransfer.DataConsumer;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.frame.FrameProvider;
|
||||
import org.photonvision.vision.frame.FrameStaticProperties;
|
||||
import org.photonvision.vision.frame.provider.FileFrameProvider;
|
||||
import org.photonvision.vision.pipeline.CVPipelineResult;
|
||||
import org.photonvision.vision.pipeline.CVPipelineSettings;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
|
||||
public class VisionModuleManagerTest {
|
||||
|
||||
@@ -87,15 +89,19 @@ public class VisionModuleManagerTest {
|
||||
|
||||
@Override
|
||||
public VideoMode getCurrentVideoMode() {
|
||||
return null;
|
||||
return new VideoMode(0, 320, 240, 254);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentVideoMode(VideoMode videoMode) {}
|
||||
public void setCurrentVideoMode(VideoMode videoMode) {
|
||||
this.frameStaticProperties = new FrameStaticProperties(getCurrentVideoMode(), getFOV());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, VideoMode> getAllVideoModes() {
|
||||
return null;
|
||||
var ret = new HashMap<Integer, VideoMode>();
|
||||
ret.put(0, getCurrentVideoMode());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,19 +120,20 @@ public class VisionModuleManagerTest {
|
||||
|
||||
@Test
|
||||
public void setupManager() {
|
||||
var sources = new ArrayList<VisionSource>();
|
||||
sources.add(
|
||||
var sources = new HashMap<VisionSource, List<CVPipelineSettings>>();
|
||||
sources.put(
|
||||
new TestSource(
|
||||
new FileFrameProvider(
|
||||
TestUtils.getWPIImagePath(TestUtils.WPI2019Image.kCargoStraightDark72in_HighRes),
|
||||
TestUtils.WPI2019Image.FOV)));
|
||||
TestUtils.WPI2019Image.FOV)),
|
||||
List.of());
|
||||
|
||||
var moduleManager = new VisionModuleManager(sources);
|
||||
VisionModuleManager.getInstance().addSources(sources);
|
||||
var module0DataConsumer = new TestDataConsumer();
|
||||
|
||||
moduleManager.visionModules.get(0).addDataConsumer(module0DataConsumer);
|
||||
VisionModuleManager.getInstance().visionModules.get(0).addDataConsumer(module0DataConsumer);
|
||||
|
||||
moduleManager.startModules();
|
||||
VisionModuleManager.getInstance().startModules();
|
||||
|
||||
sleep(500);
|
||||
|
||||
|
||||
@@ -62,8 +62,7 @@ public class VisionSourceManagerTest {
|
||||
|
||||
@Test
|
||||
public void visionSourceTest() {
|
||||
VisionSourceManager visionSourceManager = new VisionSourceManager();
|
||||
List<VisionSource> i = visionSourceManager.LoadAllSources(camConfig, usbCameraInfos);
|
||||
List<VisionSource> i = VisionSourceManager.LoadAllSources(camConfig, usbCameraInfos);
|
||||
for (var source : i) {
|
||||
Assertions.assertEquals(source, usbCameraSources.get(i.indexOf(source)));
|
||||
}
|
||||
|
||||
@@ -19,17 +19,33 @@ package org.photonvision.vision.target;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opencv.core.*;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.common.util.numbers.DoubleCouple;
|
||||
import org.photonvision.vision.frame.FrameStaticProperties;
|
||||
|
||||
public class TargetCalculationsTest {
|
||||
|
||||
private static Size imageSize = new Size(800, 600);
|
||||
private static Point imageCenterPoint = new Point(imageSize.width / 2, imageSize.height / 2);
|
||||
private static double CameraHorizontalFocalLength = 61;
|
||||
private static double CameraVerticalFocalLength = 34.3;
|
||||
private static final double diagFOV = Math.toRadians(70.0);
|
||||
|
||||
private static final FrameStaticProperties props =
|
||||
new FrameStaticProperties((int) imageSize.width, (int) imageSize.height, diagFOV);
|
||||
private static final TrackedTarget.TargetCalculationParameters params =
|
||||
new TrackedTarget.TargetCalculationParameters(
|
||||
true,
|
||||
TargetOffsetPointEdge.Center,
|
||||
new Point(),
|
||||
imageCenterPoint,
|
||||
new DoubleCouple(1.0, 0.0),
|
||||
RobotOffsetPointMode.None,
|
||||
props.horizontalFocalLength,
|
||||
props.verticalFocalLength,
|
||||
imageSize.width * imageSize.height);
|
||||
|
||||
@BeforeEach
|
||||
public void Init() {
|
||||
@@ -41,11 +57,14 @@ public class TargetCalculationsTest {
|
||||
var targetPixelOffsetX = 100;
|
||||
var targetCenterPoint = new Point(imageCenterPoint.x + targetPixelOffsetX, imageCenterPoint.y);
|
||||
|
||||
var trueYaw =
|
||||
Math.atan((imageCenterPoint.x - targetCenterPoint.x) / params.horizontalFocalLength);
|
||||
|
||||
var yaw =
|
||||
TargetCalculations.calculateYaw(
|
||||
imageCenterPoint.x, targetCenterPoint.x, CameraHorizontalFocalLength);
|
||||
imageCenterPoint.x, targetCenterPoint.x, params.horizontalFocalLength);
|
||||
|
||||
assertEquals(-1.466, yaw, 0.025, "Yaw not as expected");
|
||||
assertEquals(FastMath.toDegrees(trueYaw), yaw, 0.025, "Yaw not as expected");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,11 +72,14 @@ public class TargetCalculationsTest {
|
||||
var targetPixelOffsetY = 100;
|
||||
var targetCenterPoint = new Point(imageCenterPoint.x, imageCenterPoint.y + targetPixelOffsetY);
|
||||
|
||||
var truePitch =
|
||||
Math.atan((imageCenterPoint.y - targetCenterPoint.y) / params.verticalFocalLength);
|
||||
|
||||
var pitch =
|
||||
TargetCalculations.calculatePitch(
|
||||
imageCenterPoint.y, targetCenterPoint.y, CameraVerticalFocalLength);
|
||||
imageCenterPoint.y, targetCenterPoint.y, params.verticalFocalLength);
|
||||
|
||||
assertEquals(2.607, pitch, 0.025, "Pitch not as expected");
|
||||
assertEquals(FastMath.toDegrees(truePitch) * -1, pitch, 0.025, "Pitch not as expected");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -65,7 +65,8 @@ public class TrackedTargetTest {
|
||||
imageSize.area());
|
||||
|
||||
var trackedTarget = new TrackedTarget(pTarget, setting);
|
||||
assertEquals(1.4, trackedTarget.getYaw(), 0.025, "Yaw was incorrect");
|
||||
assertEquals(0, trackedTarget.getPitch(), 0.025, "Pitch was incorrect");
|
||||
// TODO change these hardcoded values
|
||||
assertEquals(12.0, trackedTarget.getYaw(), 0.05, "Yaw was incorrect");
|
||||
assertEquals(0, trackedTarget.getPitch(), 0.05, "Pitch was incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user