Utility Class: Common Calculations¶
PhotonUtils class with helpful common calculations is included within
PhotonLib to aid teams. This class contains two methods,
EstimateTargetTranslation() (Java and C++ respectively).
Calculating Distance to Target¶
If your camera is at a fixed height on your robot and the height of the target is fixed, you can calculate the distance to the target based on your camera’s pitch and the pitch to the target.
The C++ version of PhotonLib uses the Units library. For more information, see here.
Estimating Translation to Target¶
You can get a translation to the target based on the distance to the target (calculated above) and angle to the target (yaw).
We are negating the yaw from the camera from CV (computer vision) conventions to standard mathematical conventions. In standard mathematical conventions, as you turn counter-clockwise, angles become more positive.