From 4db733107f666032b1a58ba20e98b3bfd90b27a8 Mon Sep 17 00:00:00 2001 From: Matt Morley Date: Sat, 21 Sep 2024 10:01:10 -0700 Subject: [PATCH] Regenerate hashcode/equals/tostring --- .github/workflows/lint-format.yml | 2 +- .../targeting/PhotonTrackedTarget.java | 24 +++++++++++++++---- .../proto/MultiTargetPNPResultProto.cpp | 2 ++ .../src/test/native/cpp/PacketTest.cpp | 1 + .../aimattarget/src/main/cpp/Robot.cpp | 4 ---- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint-format.yml b/.github/workflows/lint-format.yml index fb97eb77af..09f86fc6c6 100644 --- a/.github/workflows/lint-format.yml +++ b/.github/workflows/lint-format.yml @@ -37,7 +37,7 @@ jobs: with: python-version: 3.11 - name: Install wpiformat - run: pip3 install wpiformat==2024.37 + run: pip3 install wpiformat==2024.41 - name: Run run: wpiformat - name: Check output diff --git a/photon-targeting/src/main/java/org/photonvision/targeting/PhotonTrackedTarget.java b/photon-targeting/src/main/java/org/photonvision/targeting/PhotonTrackedTarget.java index 4ae34afa7b..4ddb042b34 100644 --- a/photon-targeting/src/main/java/org/photonvision/targeting/PhotonTrackedTarget.java +++ b/photon-targeting/src/main/java/org/photonvision/targeting/PhotonTrackedTarget.java @@ -182,6 +182,8 @@ public int hashCode() { temp = Double.doubleToLongBits(skew); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + fiducialId; + result = prime * result + objDetectId; + result = prime * result + Float.floatToIntBits(objDetectConf); result = prime * result + ((bestCameraToTarget == null) ? 0 : bestCameraToTarget.hashCode()); result = prime * result + ((altCameraToTarget == null) ? 0 : altCameraToTarget.hashCode()); temp = Double.doubleToLongBits(poseAmbiguity); @@ -202,6 +204,9 @@ public boolean equals(Object obj) { if (Double.doubleToLongBits(area) != Double.doubleToLongBits(other.area)) return false; if (Double.doubleToLongBits(skew) != Double.doubleToLongBits(other.skew)) return false; if (fiducialId != other.fiducialId) return false; + if (objDetectId != other.objDetectId) return false; + if (Float.floatToIntBits(objDetectConf) != Float.floatToIntBits(other.objDetectConf)) + return false; if (bestCameraToTarget == null) { if (other.bestCameraToTarget != null) return false; } else if (!bestCameraToTarget.equals(other.bestCameraToTarget)) return false; @@ -221,8 +226,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return "PhotonTrackedTarget{" - + "yaw=" + return "PhotonTrackedTarget [yaw=" + yaw + ", pitch=" + pitch @@ -232,11 +236,21 @@ public String toString() { + skew + ", fiducialId=" + fiducialId - + ", cameraToTarget=" + + ", objDetectId=" + + objDetectId + + ", objDetectConf=" + + objDetectConf + + ", bestCameraToTarget=" + bestCameraToTarget - + ", targetCorners=" + + ", altCameraToTarget=" + + altCameraToTarget + + ", poseAmbiguity=" + + poseAmbiguity + + ", minAreaRectCorners=" + minAreaRectCorners - + '}'; + + ", detectedCorners=" + + detectedCorners + + "]"; } public static final PhotonTrackedTargetProto proto = new PhotonTrackedTargetProto(); diff --git a/photon-targeting/src/main/native/cpp/photon/targeting/proto/MultiTargetPNPResultProto.cpp b/photon-targeting/src/main/native/cpp/photon/targeting/proto/MultiTargetPNPResultProto.cpp index 0bd08c1cee..cc67ec213f 100644 --- a/photon-targeting/src/main/native/cpp/photon/targeting/proto/MultiTargetPNPResultProto.cpp +++ b/photon-targeting/src/main/native/cpp/photon/targeting/proto/MultiTargetPNPResultProto.cpp @@ -17,6 +17,8 @@ #include "photon/targeting/proto/MultiTargetPNPResultProto.h" +#include + #include "photon.pb.h" #include "photon/targeting/proto/PNPResultProto.h" diff --git a/photon-targeting/src/test/native/cpp/PacketTest.cpp b/photon-targeting/src/test/native/cpp/PacketTest.cpp index 0fb5697029..5398fae4c1 100644 --- a/photon-targeting/src/test/native/cpp/PacketTest.cpp +++ b/photon-targeting/src/test/native/cpp/PacketTest.cpp @@ -16,6 +16,7 @@ */ #include +#include #include diff --git a/photonlib-cpp-examples/aimattarget/src/main/cpp/Robot.cpp b/photonlib-cpp-examples/aimattarget/src/main/cpp/Robot.cpp index 830fe147c0..8f323d0bcf 100644 --- a/photonlib-cpp-examples/aimattarget/src/main/cpp/Robot.cpp +++ b/photonlib-cpp-examples/aimattarget/src/main/cpp/Robot.cpp @@ -36,10 +36,6 @@ void Robot::RobotPeriodic() { auto start = frc::Timer::GetFPGATimestamp(); photon::PhotonPipelineResult result = camera.GetLatestResult(); auto end = frc::Timer::GetFPGATimestamp(); - - std::printf("DT is %.2f uS for %i targets\n", - units::microsecond_t(end - start).to(), - result.GetTargets().size()); } void Robot::TeleopPeriodic() {