Distance calculation using limelight not being accurate at all

Hey, so I’ve been stuck with this problem for a long time. I’m trying to get the shooter to work on variable power by getting the limelight Y angle and then introducing it to the formula: limelightHeight - targetHeight / tan(LLYangle - starting angle).
After getting the value I introduce it to a function that outputs the required RPM which I got by measuring it from different known distances. The function is a quadratic one btw.
Problem is, that although I’ve sent all three variables: angle, distance calc, and output calc, and though the angle doesn’t really chance much, the distance and output calc just start overshooting to the point where it literally says infinity.
What could it be?

Here’s my code: https://github.com/bsanchez15/Rhinos2020
All of the calcs are in the Shooter subsystem and the ShootRange command

return h1-h2/(Math.tan(a2+a1));

probably (h1 - h2) would fix this.
from limelight doc: d = (h2-h1) / tan(a1+a2)

Xing’s correction fixes part of it. Your constants are also all set to zero instead of real values, so you’ll want check those too.

Yeah, that’s what I’m using, I was only writing that by memory. As for the constants, I do give them real values in the Constants class

We struggled with the same issue. The problem is the formula shown in the limelight documentation is a very crude estimate. The exact calculation needs to take in to account the fov of the camera and a lot more trigonometry. We ended up just correlating ty from limelight with measured distance from target.

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