|
Re: Advanced Vision Concept [help!]
The fundamental task isn't too complex.
Imagine your camera code is responsible for telling you where the square backboards are in the picture. It's capable of saying "The goal is way to the left" or "the goal is right in the middle of the picture" or "the goal is to the right just a little bit".
A slightly more accurate bit of camera code might respond with degrees from center: "The goal is -12 degrees from center" or "The goal is +0.4 degrees from center" or "The goal is +40 degrees from center"
Essentially, you feed this information to a new piece of code, code responsible for physically rotating the camera. Its goal is to try and make the goal "0 degrees from center"
If the camera code says the goal is to the left, you rotate the camera left until the camera code says the goal is at about 0. If the camera code says the goal is to the right, you rotate the camera right until the camera code says the goal is about zero. At all times, this piece of code is trying to keep that number 0.
For a first attempt, you don't need to get too complicated. if it's extremely important that the camera always remain dead center, and get there as quickly as possible, you can use various techniques to achieve that, such as:
-If the camera is way off, spin the motor faster. If the camera is only slightly off center, turn it more gently. (PID is one way to do this)
-Try and detect how the goal has been moving the last few times and make a guess as to where it is going to be in the future
But for the most part, you can usually get away with a very simple piece of code that just turns the motor in the correct direction at a fixed speed if the goal isn't in the center, and have a little "dead zone" that you consider to be "close enough" where the motor does not move.
|