We need to figure out how to get our camera to center itself on rectangular objects.
Basically, we can get the camera to take a picture and recognize the rectangle as a target. But the rectangle in the image isn’t centered. We want the robot and camera to move until the rectangle is in the dead center of the camera and the image, that way we can aim correctly.
Thank you in advance for any assistance you might be able to offer us, we’re really looking forward to finally using vision targeting this year.
This still isn’t perfect, as most times the robot completely misses the vision target, a problem that I must face today, and this code likes to also track white light… no explanation needed:yikes: and in terms of the Y axis tracking, you may want to have a sensor that can tell you the angle of the shooter and have the shooter move until it is at the right angle.****
As for the rest, check out my code for automatic turret tracking. RobotMap.top[0] is the reported x coordinate of the center of the detected target. If you’re doing your own vision processing, just pass it that value as such. CameraXOffset is just 160, the x value of the center of the camera’s vision. HorizontalTurretAxis.rotate() is a method I added toHorizontalTurretAxis, but replace that with whatever you want the PID output to be of course.
If you need more explanation on how this works please ask.
TL;DR image processing sends x,y coordinates of detected target back to a command that runs a PID controller using that coordinate as input and your motors as output to align itself.