Our team is trying to get our robot to follow a vision target. We used the Two Color Servo Example VI to track the target with the camera. Now we want to make the robot itself follow the target, but we have absolutely no idea how to do this. Any examples or help will be greatly appreciated.
For starters we’ll assume your camera is pointed straight ahead. So the first thing you’ll want to know is if the target is to the left or right of center. The target coordinates come out of the Two Color Servo Example VI and give you X and Y in the image. The X will be the target’s horizontal position and the Y will be the vertical position. Note that the origin in most image processing applications is at the top left of the image so the positive Y direction is downward.
You will then need to know the size (resolution) of the image that you are using. Let’s assume your image size is 640x480 (I think this is the full size image that the camera can return, but you can specify smaller ones for faster frame rates). If the X value of target position is 320, then the target is straight ahead. If the X is less than 320, then the target is to the left. If the X is greater than 320, then the target is the right.
If you are using arcade steering in the Basic Robot Main.vi (I believe this is the out of the box default), then the X Axis Value of the Arcade Drive.vi will tell the robot whether to head left or right. So a simplistic approach might be to wire a 1 into the X Axis Value of the Arcade Drive.vi to go right and a -1 to go left. However, this will likely be too chaotic and you should reduce the magnitude of the X Axis Value as the target gets closer to center.
The camera has a 54 degree horizontal field of view. You can use this to get an angle offset. It your camera can move independantly of the chassis, you can use an encoder or potentiometer to get an additional angle.
That, combined with stadiometric rangefinding, can allow you to setup a polar coordinate system. If you keep track of previous ranges and angles, you can get relative velocity and acceleration.
Can someone post example code of how to use the arcade drive or tank drive to follow the color? i’m very lost. i’m a visual learner