Positioning of Robot using fiducial markers

What I am trying to do is detecting relative position in metric units of a fiducial marker (apriltag in this case) of a known size as well as the normal of that fiducial marker. Looking at the documentation of apriltags, it looks to me like x_,y_, and z_translation as well as rotation are the methods that I need. However, I am unsure about how to go past this. I have a hunch that I might need two of the markers to position myself, but other than that I am completely lost. I have thought about various geometric ways of doing it, but the distortion of the lens seems to me to be pretty difficult to compensate for. I found other libraries online that seem to do exactly what I’m looking for, but the code is highly optimized and totally unreadable to me.

I’ve included a picture below in case my explanation was confusing. In the picture, I am looking for x, y, and theta.

In the documentation, it says that “The units of the translation are determined by fx, fy, cx, and cy which are the focal lengths and center points of the image in the X and Y directions respectively.” This sounds great, but what are those units? Or rather, how do I find what units they are in based on the size of my apriltag?

I’m sorry if this is a basic question, but I’m fairly new to cv in general having only dabbled in it here and there. I appreciate your understanding.

The units of the distance are related to the size of the tag. If you look at the MAVLink AprilTag example in the examples folder you’ll see some code I wrote that tells you the distance to a tag that is of a user defined size.

Um, once you have the distance units simple trigonometry applies. If you want to account for lens distortion use the len_corr() method.