April tag pose estimation

Hey,
I’m currently working on April tags pose estimation with multiple tags in cpp on a coprocessor called beelink using an arducam,
Last year I achieved pose estimation only on the best detected tag I didn’t work so well,
how can I achieve pose estimation based on 2 or more april tags to get more accurate results.

I have heard on solvepnp but didn’t know much of it and I didn’t use it.

Thanks

1 Like

You will need to figure out using SolvePnP(), or you can switch to using PhotonVision.

Assuming you really want to do your own solution, take a look here:
https://docs.opencv.org/4.x/d5/d1f/calib3d_solvePnP.html

Basically, you need to build 2 arrays: one has the found corners of the AprilTags (in camera coordinates), the other has the real-world coordinates of those same tag corners. They must match up between the 2 arrays. Then pass them to SolvePnP, along with camera calibration, etc, and it gives you back the results.

Welllll, almost. Translating the returned “rvec” and “tvec” into useful values can be a bit mind-bending.

1 Like

Feel free to dig into Photon’s multi target PNP pipe on GitHub. It’s a good reference implementation, and should translate well into C++.

Camera calibration is really important. Make sure to calibrate your camera well, using something like CalibDB if you can.

I would recommend using Photonvision with your camera for pose estimation, it served us well last season for our auto-scoring. We occasionally would lose our pipeline though, so we re-uploaded it before every match just to be sure.

FRC 7028 pose estimator subsystem

Photonvision pose estimation docs

Hey, how can I install photonLib on a coprocessor (windows) it has errors when I run the jar of photon vision an I don’t know how can I download only photonLib and then include it

I reccomend starting here, and reading this page in its entirety: Installation & Setup - PhotonVision Docs. Specifically, read the windows installation section. Follow the steps there for a windows coprocessor. Please make note and be sure to read the following:

Please send the full error message so we can help out, a image of the stacktrace of a picture of the error in its entirety would be appreciated.

Please see here: Installing PhotonLib - PhotonVision Docs
and here
3rd Party Libraries — FIRST Robotics Competition documentation (wpilib.org)

2 Likes

OP could give this calibrator a try. It appears to me to be a twin of CALIBDB but better. I converted the CALIBDB author’s github version of pose calib to Java and it’s destined for PV integration. The standalone program works well for now.

1 Like

We had 3 cameras looking at different angles, using the python libraries, including opencv, apriltags, etc. Used multi-camera calliberation to get coordinates working together, like 3d coordinate transformation using 3x3 matrics. We wrote our custom python code running on a mini-pc as coprocessor. If you wanna look at our code, here’s a link to our github repo for visions

https://github.com/CRRobotics/2023Visions
Edit: Opps, sry, i think the repository is private, i’ll talk to the managers to make it public

Thanks

I managed to download and run it do i need to write code for the coprocessor, or do I have all the values in the network tables and then get them through there to my robot code?