Calculating Angle to Target
So after getting some rudimentary rectangle detection working, I've found some big drawbacks in the "simple" way of turning one direction or the other until facing the center of the target rectangle. The big problem is (at least for our test robot) it takes a significant amount of power to the motors to start moving, and once you get moving, your moving quite fast and tend to overshoot the target; leading to the robot swinging wildly back and forth.
So what I'd like to do is determine the angle the robot needs to turn from the each image, and monitor a gyroscope to determine when to slow down and stop (using periodic, low framerate, images to update the angle to target).
To do this, we'll need to no the angle between our current and desired facing; eventually I came up with an idea I'd like to field here:
The camera has a fixed field of view; regardless of your distance from the target, the left edge of the image is a fixed number of degrees from the center, so it should be possible to determine the needed rotation by:
[r](deg_delta) = [x](pixel_delta) * [a](pixels/deg)
I do understand the edges of the image are a bit fish-eyed (or perhaps the whole thing) so it may not be quite this simple, but should be easy enough to measure.
What does CD think... is this a good approach, or is there a better way of doing this that I'm overlooking?
|