So we have a frustrating issue that’s messing up some good portion of our shots–when we read the tx value from the network table, we expect it to be zero when the target is centered (or within a calibrated center); but maybe once every 5-6 times we shoot, the limelight will either
(A) see the target and arbitrarily assign a tx value of zero even though we’re off by 3, 5, even 15 degrees. [See picture below. The robot immediately moved to the next step in our “Shoot Command Group” because according to the Limelight, this was tx = 0.0, when it clearly was not.]
or (B) we can be targeting and the error (which is just a print of the tx value) suddenly drops to zero. [See chart below. Our value goes from -6.andchange to 0.0 without the robot having moved a whisker.]
Right now we have our targeting command on an IsFinished() that returns Math.abs(tx) <= Constants.deadband (currently set at two pixels), so the moment this happens, our robot shoots, even though we’re not properly aimed.
I believe our code is fine such as it is, in that it works ~80% of the time; it’s the network value that suddenly drops to (or starts at) 0.0 for unknown reasons that is causing this behavior. Our LEDs aren’t going off, lighting conditions aren’t changing, etc.
So, two questions:
- Is there a hardware fix that can keep this from happening?
- If the answer to 1. is “no,” then is there an easy software fix to, say, grab an average (or even better, average-drop-the-lowest) tx value over several loops to see if we can jump past it?
Thank you very much!