mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Add aliases, allow v2024.3.1 setting import (#1487)
Was easy enough to add annotations. Ongoing work to remove these hacks post 2025 is tracked in https://github.com/PhotonVision/photonvision/pull/1487
This commit is contained in:
@@ -194,4 +194,19 @@ public class PhotonConfiguration {
|
||||
public double minWhiteBalanceTemp;
|
||||
public double maxWhiteBalanceTemp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PhotonConfiguration [\n hardwareConfig="
|
||||
+ hardwareConfig
|
||||
+ "\n hardwareSettings="
|
||||
+ hardwareSettings
|
||||
+ "\n networkConfig="
|
||||
+ networkConfig
|
||||
+ "\n atfl="
|
||||
+ atfl
|
||||
+ "\n cameraConfigurations="
|
||||
+ cameraConfigurations
|
||||
+ "\n]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,4 +428,8 @@ public class TestUtils {
|
||||
.resolve("testimages")
|
||||
.resolve(WPI2022Image.kTerminal22ft6in.path);
|
||||
}
|
||||
|
||||
public static Path getConfigDirectoriesPath(boolean testMode) {
|
||||
return getResourcesFolderPath(testMode).resolve("old_configs");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public class JacksonUtils {
|
||||
JsonMapper.builder()
|
||||
.configure(JsonReadFeature.ALLOW_JAVA_COMMENTS, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)
|
||||
.activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.wpi.first.math.geometry.Pose3d;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Point3;
|
||||
|
||||
@@ -53,6 +54,7 @@ public final class BoardObservation implements Cloneable {
|
||||
public String snapshotName;
|
||||
|
||||
@JsonProperty("snapshotDataLocation")
|
||||
@Nullable
|
||||
public Path snapshotDataLocation;
|
||||
|
||||
@JsonCreator
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package org.photonvision.vision.camera;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
|
||||
public enum CameraQuirk {
|
||||
/** Camera settable for controllable image gain */
|
||||
Gain,
|
||||
@@ -27,6 +29,7 @@ public enum CameraQuirk {
|
||||
/** Cap at 100FPS for high-bandwidth cameras */
|
||||
FPSCap100,
|
||||
/** Separate red/blue gain controls available */
|
||||
@JsonAlias("AWBGain") // remove after https://github.com/PhotonVision/photonvision/issues/1488
|
||||
AwbRedBlueGain,
|
||||
/** Will not work with photonvision - Logitec C270 at least */
|
||||
CompletelyBroken,
|
||||
@@ -40,8 +43,11 @@ public enum CameraQuirk {
|
||||
* Camera is an arducam USB ov9281 which has a funky exposure issue where it is defined in v4l as
|
||||
* 1-5000 instead of 1-75
|
||||
*/
|
||||
@JsonAlias("ArduOV9281") // remove after https://github.com/PhotonVision/photonvision/issues/1488
|
||||
ArduOV9281Controls,
|
||||
/** Dummy quirk to tell OV2311 from OV9281 */
|
||||
// from 2024.3.1
|
||||
@JsonAlias("ArduOV2311") // remove after https://github.com/PhotonVision/photonvision/issues/1488
|
||||
ArduOV2311Controls,
|
||||
ArduOV9782Controls,
|
||||
/**
|
||||
|
||||
@@ -154,9 +154,13 @@ public class QuirkyCamera {
|
||||
this.displayName = displayName;
|
||||
|
||||
this.quirks = new HashMap<>();
|
||||
|
||||
// (1) Fill quirk map with the supplied Quirk list
|
||||
for (var q : quirks) {
|
||||
this.quirks.put(q, true);
|
||||
}
|
||||
|
||||
// (2) for all other quirks in CameraQuirks (in this version of Photon), defalut to false
|
||||
for (var q : CameraQuirk.values()) {
|
||||
this.quirks.putIfAbsent(q, false);
|
||||
}
|
||||
@@ -176,8 +180,14 @@ public class QuirkyCamera {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this camera
|
||||
*
|
||||
* @param quirk
|
||||
* @return
|
||||
*/
|
||||
public boolean hasQuirk(CameraQuirk quirk) {
|
||||
return quirks.get(quirk);
|
||||
return quirks.getOrDefault(quirk, false);
|
||||
}
|
||||
|
||||
public static QuirkyCamera getQuirkyCamera(int usbVid, int usbPid) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.photonvision.common.configuration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
@@ -30,6 +31,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.camera.CameraQuirk;
|
||||
import org.photonvision.vision.camera.CameraType;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
import org.photonvision.vision.pipeline.AprilTagPipelineSettings;
|
||||
@@ -102,4 +104,26 @@ public class SQLConfigTest {
|
||||
|
||||
assertEquals(cfgLoader.getConfig().getNetworkConfig().ntServerAddress, "5940");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoad2024_3_1() {
|
||||
var cfgLoader =
|
||||
new SqlConfigProvider(
|
||||
TestUtils.getConfigDirectoriesPath(false)
|
||||
.resolve("photonvision_config_from_v2024.3.1"));
|
||||
|
||||
assertDoesNotThrow(cfgLoader::load);
|
||||
|
||||
System.out.println(cfgLoader.getConfig());
|
||||
for (var c : CameraQuirk.values()) {
|
||||
assertDoesNotThrow(
|
||||
() ->
|
||||
cfgLoader
|
||||
.config
|
||||
.getCameraConfigurations()
|
||||
.get("Microsoft_LifeCam_HD-3000")
|
||||
.cameraQuirks
|
||||
.hasQuirk(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
note
|
||||
Binary file not shown.
Reference in New Issue
Block a user