I don’t see any sleeps (like Timer.delay(0.025)
in your autonomous while loop. This will cause your autonomous loop to chew up a lot of your CPU time that could be used for vision processing and there isn’t much point in executing the same code thousands of times between frame updates.
It might also be helpful to put the following counts out to the dashboard during autonomous:
- Number of frames processed.
- Number of times two targets were found (resulting in power to the drive train).
- Number of times less than two targets were found (stopping the drive train).
- Number of times more than two targets were found (stopping the drive train).
Finally, it looks like if your vision filter picks up more than two targets, it will stop the robot. Instead, would it be worth looking for the two best targets should the filter pick up some noise ?
Good luck,
Paul