How do I convert value of apriltag.x_translation() to "cm"

the API say
“Returns the translation in unknown units from the camera in the X direction.
This method is useful for determining the apriltag’s location away from the camera. However, the size of the apriltag, the lens you are using, etc. all come into play as to actually determining what the X units are in. For ease of use we recommend you use a lookup table to convert the output of this method to something useful for your application.”

But I don’t understand,so could you give a sample or tell me how do I to Implement it.

Hi, the units are scaled by whatever tag size the tag was printed out at. You need to manually measure the distance the tag is away from the camera and look at what the method returns in tag distance. Build a lookup table of these values and then use them in your application. If you look at he Mavlink AprilTag example I show some code for doing this based on the tag size() however, it’s not that accurate. For lots of accuracy you need to manually measure the distance the tag is away from the camera compared to what the method reports.

Thanks and yes I need that code

Please see “Examples → MavLink → AprilTag MavLink”