I would like to have some advice on how exactly to implement the detection of AprilTags using a Raspberry PI SnakeEyes using the PhotonVision pipeline library to a command-based java program. Our goal is to be able to locate and track an AprilTag so that we can drive our robot toward that target using a differential drive system. I have read the example from the WPILIB provided on AprilTagsVision. However, the AprilTag reading is done using the Roborio and does not give an example on how to use the readings and feed it to the robot’s drivetrain.
I understand there are other concepts needed namely, Pose2d, Rotation 2D, Pose Estimator, DifferentialDrivePoseEstimator and others.
We are using a Navx en CTRE MagSRX encoders to help us with navigation.
Would it be possible for anyone to provide a basic code that will help us understand the process of implementing target tracking (AprilTags & SnakesEyes with Photonvision)?
So, if the goal is to just point at the target, check out the aim-at-target example. While apriltags can afford a bunch of awesome pose-estimation features, it’s still possible try to use them like the old school retroreflective tape and just point toward them.
The old retroreflective caveats still apply:
You’ll want to run with as little latency as possible - this means low exposure, low resolution.
If you see multiple targets at once, you’ll need a strategy for only focusing on one. This is really easy with apriltags, just use result.getBestTarget().getFiducialId() to make sure you only react to the target of interest.
Latency between camera → RIO is the biggest limiting factor in the PID gains.
Of course, this isn’t an optimal strategy. But it’s simpler and requires a lot fewer things to be working properly to achieve aligning to a target.
As a side note, ignore Release_17 in the snakeyes repo for now - the team is still working out how to integrate settings files back into a photonvision release.
Thanks, Gerthworm for the suggestions of a simple code to begin with. I will take a look at the suggested code and try to build from there. I’ll keep you posted on my programmers’ progress.