This post was flagged by the community and is temporarily hidden.
we usually use the following formula:
(known distance)/(known height)=(distance to be found)/(given height)
find out more about this method here, but note that height is used here and not area.
please note 3 points:
- distance’s units are meters, and area’s units are pixles^2
- This method is, by far, the least accurate method to determine distance from a target. I recommend using Limelight’s 3D feature or Photonvision’s 3D features.
- If you use this method, ensure that your calibration(known distance/area ratio) is accurate. try to check yourself multiple times.
Given that the shape of the target is basically a shallow arc when you are far away and a much more circular arc when you are near, the length to width ratio of the rectangle around the target is not constant, therefore the area is not perfectly proportional to distance. Plus, given that the retroreflective targets are intermittently placed on the hoop, there will be some angles at the same distance that will produce different areas.
You may be better off using either the width of the target or the vertical position of the target in the field of view as these may be easier to correlate with distance and give more consistent distance determinations.
You can try using math (trig) to come up with an equation for either of these, but you may be better off just tuning it on an practice field area.
After exploring some of my team’s solution, you are absolutely right. Instead of the area, we tried using the target’s height(resistible for angle change) and the same formula. will update my answer. Thanks!
Because this year it’s common to not pick up the same number of targets in every vision solution as well as the shape of the target getting more arc shaped as you get closer we have found that using the ty angle of the limelight and building a linear interpolation table for every 15-20in was the best method.
We tried using trigonometry like previous years but it suffered when closer to the target because the vision targets are not on a flat plane.
One thing about that Lerp table that was really nice was to retune during field calibration was as simple as reading the limelight ty value, measuring with a tape measure and updating the points on the lerp table.
If you do choose to stick with interpolation, you should check out 254’s interpolation code.
Hey, I would like to clarify:
The method of finding distance by area(or height)-to-distance ratio in my opinion and knowledge, isn’t a good method and isn’t accurate.
My team and I used in our various projects(not only FRC-specific) multiple formulas and methods to determine the distance to a target. I would recommend using PhotonVision / Limelight’s 3D features, or trigonometry.
Using area is a bad idea. The error and jitter of the bounding box that the limelight draws around the target can be very erratic. Sometimes it can be a single pixel, but it can easily be more. For instance in Rapid React the limelight can alternate between seeing 3 or 4 targets. The center of the bounding box moves a little, but the area of the bounding box will change much more.
Using the area is multiplying the error and making it bigger. Any error in the height is multiplying by the width, and any error in the height is multiplied by the width. Increasing the overall magnitude of the error.
(H + Error_height) * (W + Error_width) = H * W + H * Error_width + W * Error_height + Error_width * Error_height
Where H * W is the actual Area, the rest is the result of the original measurement error.
vs just taking the center of the target, which is averaging the left and right sides, and averaging the top/bottom. A process that is reduces the impact of measurement error.