Limelight - Java Distance Estimation

Hi all!

My team recently was able to acquire a Limelight2, and we currently use Java Command Based.

We are able to import the Network Table values, and have even written commands for the robot to seek its target.

Does anyone have some insight on how to estimate distances to drive up on a target? I am trying to work with my Programming team to come up with the necessary trig calculations, but am not having a lot of luck.

Appreciate any help you could offer.

Limelight docs has a good tutorial on how to do this: http://docs.limelightvision.io/en/latest/cs_estimating_distance.html

I found this in a post from like a couple years ago and it worked really well for us(accurate to like 2 in):

(Edit) area is in percent

dist=k/Math.sqrt(area);

k is a constant that can be solved for.

Put the cam 4ft from the target and record the area given back to you.

then solve for k: k = 4*Math.sqrt(area)

plug it back in and Viola!

To simplify… I believe the limelight gives the target area (bounding rect) in terms of percentage. You can use this as a simple (not very accurate) method of determining your target proximity.