Quote:
Originally Posted by Rflax40
Hello, our team (1124) is looking to implement an improved vision system, but is having trouble calculating the angle away from the center of the goal that our robot is pointing. If anyone could share how they accomplish that it would be great. The information we know is position of the center of our camera, and the position of the center of the goal.
|
We plan on doing this soon, so I'll just share how I expect we'll do it. We'll double check the horizontal field of view (in degrees) of our camera, then find an equation that maps the goal position to degrees. For example, if the camera is 90° horizontal FoV and the resolution is 640 horizontally, then a simple equation would be
angle = (goalx - 640/2) * 90/640
We plan on closing the loop with a gyro so we won't have to rely on a quick framerate to lock onto the goal.
If you don't know the viewing angle, or want to do it empirically to be more accurate, you could mark a piece of paper with several angles, put the camera flat on the paper and measure pixel distances at different angles.