From f26adc556d646caf0950dd5631d0f26cec5da649 Mon Sep 17 00:00:00 2001 From: HarryXChen <51322624+HarryXChen3@users.noreply.github.com> Date: Sun, 21 Apr 2024 23:21:48 -0400 Subject: [PATCH] [examples] Fix memory over-allocation in Apriltag examples (#6517) Change hamming distance to 1, add comment about memory usage. --- .../src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp | 7 +++++-- .../wpi/first/wpilibj/examples/apriltagsvision/Robot.java | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp index 8df29339fa6..9f23be34075 100644 --- a/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/AprilTagsVision/cpp/Robot.cpp @@ -37,8 +37,11 @@ class Robot : public frc::TimedRobot { private: static void VisionThread() { frc::AprilTagDetector detector; - // look for tag36h11, correct 3 error bits - detector.AddFamily("tag36h11", 3); + // look for tag36h11, correct 1 error bit + // hamming 1 allocates 781KB, 2 allocates 27.4 MB, 3 allocates 932 MB + // max of 1 recommended for RoboRIO 1, while hamming 2 is feasible on the + // RoboRIO 2 + detector.AddFamily("tag36h11", 1); // Set up Pose Estimator - parameters are for a Microsoft Lifecam HD-3000 // (https://www.chiefdelphi.com/t/wpilib-apriltagdetector-sample-code/421411/21) diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java index 27ae30f32f7..8609cf7e47c 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/apriltagsvision/Robot.java @@ -39,8 +39,10 @@ public void robotInit() { void apriltagVisionThreadProc() { var detector = new AprilTagDetector(); - // look for tag36h11, correct 3 error bits - detector.addFamily("tag36h11", 3); + // look for tag36h11, correct 1 error bit (hamming distance 1) + // hamming 1 allocates 781KB, 2 allocates 27.4 MB, 3 allocates 932 MB + // max of 1 recommended for RoboRIO 1, while hamming 2 is feasible on the RoboRIO 2 + detector.addFamily("tag36h11", 1); // Set up Pose Estimator - parameters are for a Microsoft Lifecam HD-3000 // (https://www.chiefdelphi.com/t/wpilib-apriltagdetector-sample-code/421411/21)