Our Robots Shooter has elevation control which allows us to adjust the angle. it is a feedback of the vision system.
Sometimes I see some noise out of our vision system that causes a little bit of turret angle variance. Not a ton but perhaps a distance value not entirely settling.
Any recommendations on how I can smooth my input to the turret aim function? Perhaps keep a rolling average of the last 3 requested angles to cut down on the oscillation?
The “proper” solution involves doing full pose estimation with odometry fused with the vision measurements, and tuning the variance values of both so that faulty vision measurements don’t impact the estimated pose by a lot.
However, I suspect that if 99% of the angles produced by your system are correct, then taking a rolling average or median of the last N results will smooth it enough for what you need.
You can apply the low pass filter to the vision data to smooth out the noise at the cost of distorting the desired signal by adding latency. Because of this tradeoff, you can’t filter the data too much as there’s a tradeoff between noise and latency, which either extreme being uncontrollable.
The pose estimator in wpilib allows you to pass in “standard deviations” for vision measurements.
The higher these are, the less it will factor in the vision measurement versus the odometry.
If in testing you’re finding that vision is unreliable at long ranges, then you can model this by calculating that standard deviations are high if the robot is far away from the speaker, or you can reject the measurements out-right at a certain range.
Your odometry should still be able to estimate your position very accurately for a while: the farther you travel without a “good” vision estimate to correct, the more your odometry’s estimated position will drift from your actual position.