How to calculate distance with PhotonVision

Hey, so this is my first time implementing photonvision into a vision subsystem. I’ve had experience with limelight and the associated networktables, so I know the concept of what I want, just not how to apply it.

That said: (ridiculous question, but) does the photonvision image have a way to calculate distance built in? I’ve re-imaged a limelight 2 for my camera. What I’m trying to do is put the robot a position x on the field, and know exactly how far I am away from the central hub just using vision. If there isn’t a built-in target distance calculation, what would be some general steps to get started with this? I’ve never used the photonvision networktables before, so I don’t really know how to get all of those values and implement them into code.

Take a look at our documentation here, that talks about using the PhotonLib utility functions to estimate distance to a target.

1 Like

Thanks for the solution! This really helped.