Interpreting PhotonVision results?

We’ve been fooling around with PhotonVision and TagTracker with AprilTags; the challenge to the students was “if you see a target, do you know where you are in relation to it?”

Want to make sure I am interpreting results from Photonlib correctly; it appears that calling getBestCameraToTarget() gives me the transform of the target relative to the camera, with the translation being the location of the center of the target relative to the camera (positive X component being away from the camera, positive Y component going to right left of camera, and positive Z component going up from the camera). The rotation of the pose is how “turned” the target is from the camera; if it were square to the camera, I would expect the rotation to have yaw(.getZ()), roll(.getX()), and pitch(.getY()) all work out to zero.

Do I have those right?

1 Like

Off the top of my head, yep! Actually angle about Z might be 180 – the tag is facing you, after all. Otherwise yep it’s North-West-Up for XYZ.

1 Like

…assuming you are facing north?

Yep that’s right. Some very crappy pictures here: Rotate all solvePNP-ed poses to be 180 about Z facing camera by mcm001 · Pull Request #500 · PhotonVision/photonvision · GitHub

NWU is sort of confusing here, but if you imagine looking top-down at a robot on a compass pointing North, you’d have X going North, Y going West, and Z up looking towards you.

In this picture, the coordinate system of the tag is visualized with the red/green/blue lines (red=x, green=y, blue=z). You can see this in this picture too – the tag is facing the camera, and it’s rotated 180 about Z (+x maps to -x, and +z maps to -z)

What’s the Rotation convention though? I’m not really understanding the yaw(.getZ()), roll(.getX()), and pitch(.getY()) stuffs

It’s rotations about a coordinate system with X away from the camera, Y left, and Z up. Those getX/y/z functions give you angles about each axis. So a tag facing the camera dead on is 180 about Z, and 0 about Z and Y. Note the red arrow and line coorosponds to X, green to Y and blue to Z

would you be willing to share your code for this? been trying to setup photonvision and I’m having a lot of trouble getting it to recognize the camera on our robot

I recommend creating a separate thread thoroughly detailing your issues and we’ll try our best to help.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.