mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-25 01:41:40 +00:00
Add version verification disable switch in photonlib (#437)
This commit is contained in:
@@ -45,6 +45,12 @@ public class PhotonCamera {
|
||||
|
||||
private final String path;
|
||||
|
||||
private static boolean VERSION_CHECK_ENABLED = true;
|
||||
|
||||
public static void setVersionCheckEnabled(boolean enabled) {
|
||||
VERSION_CHECK_ENABLED = enabled;
|
||||
}
|
||||
|
||||
Packet packet = new Packet(1);
|
||||
|
||||
/**
|
||||
@@ -199,6 +205,8 @@ public class PhotonCamera {
|
||||
}
|
||||
|
||||
private void verifyVersion() {
|
||||
if (!VERSION_CHECK_ENABLED) return;
|
||||
|
||||
String versionString = versionEntry.getString("");
|
||||
if (versionString.equals("")) {
|
||||
DriverStation.reportError(
|
||||
|
||||
@@ -100,6 +100,8 @@ void PhotonCamera::SetLEDMode(LEDMode mode) {
|
||||
}
|
||||
|
||||
void PhotonCamera::VerifyVersion() const {
|
||||
if (!PhotonCamera::VERSION_CHECK_ENABLED) return;
|
||||
|
||||
const std::string& versionString = versionEntry.GetString("");
|
||||
if (versionString.empty()) {
|
||||
std::string path_ = path;
|
||||
|
||||
@@ -138,6 +138,10 @@ class PhotonCamera {
|
||||
"This method should be replaced with PhotonPipelineResult::HasTargets()")
|
||||
bool HasTargets() const { return GetLatestResult().HasTargets(); }
|
||||
|
||||
inline static void SetVersionCheckEnabled(bool enabled) {
|
||||
PhotonCamera::VERSION_CHECK_ENABLED = enabled;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<nt::NetworkTable> mainTable;
|
||||
std::shared_ptr<nt::NetworkTable> rootTable;
|
||||
@@ -154,6 +158,8 @@ class PhotonCamera {
|
||||
mutable Packet packet;
|
||||
|
||||
private:
|
||||
inline static bool VERSION_CHECK_ENABLED = true;
|
||||
|
||||
void VerifyVersion() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ class SimVisionSystemTest {
|
||||
new SimVisionSystem("Test", 80.0, 0.0, new Transform2d(), 1, 99999, 640, 480, 0);
|
||||
sysUnderTest.addSimVisionTarget(new SimVisionTarget(targetPose, 1.0, 3.0, 3.0));
|
||||
|
||||
PhotonCamera.setVersionCheckEnabled(false);
|
||||
var robotPose = new Pose2d(new Translation2d(5, 0), Rotation2d.fromDegrees(5));
|
||||
sysUnderTest.processFrame(robotPose);
|
||||
assertTrue(sysUnderTest.cam.getLatestResult().hasTargets());
|
||||
|
||||
@@ -294,6 +294,7 @@ TEST_P(SimVisionSystemCameraPitchParamTest, CameraPitch) {
|
||||
frc::Transform2d(frc::Translation2d(), frc::Rotation2d()), 0.0_m,
|
||||
units::degree_t(testPitch));
|
||||
|
||||
photonlib::PhotonCamera::SetVersionCheckEnabled(false);
|
||||
sysUnderTest.ProcessFrame(robotPose);
|
||||
auto result = sysUnderTest.cam.GetLatestResult();
|
||||
ASSERT_TRUE(result.HasTargets());
|
||||
|
||||
Reference in New Issue
Block a user