Has anyone been able to get the camera to track and follow (or get close to) one of the vision tetras?
I had an idea about having the drive motors try and turn so that the pan servo on the camera returns to zero, but that doesn’t seem to be working.
I have something like this
if (cam.pan_servo < 127) // Camera is turned left
{
pwm01 = 70; // Left Drive Motor
pwm-2 = 200; // Right Drive Motor Forward
}
else
the code continues saying that if it is facing the other way, turn right.
Any ideas?
It doesn’t seem to be working, like…?
I think the default code is setup that the RC does tracking (which I think is a bad idea, since the camera is perfectly capable of it).
While that possibly can get the robot to drive towards the tetra, it probably won’t work well.
The best way to accomplish this is to do it with some form of a control loop. In a control loop, you take as input where you’d like to be. You then subtract out where you currently are. Then, you transform this value (through a variety of techniques the simplest of which being a proportional) and output it to the motor.
In short this is:
output = transform(current position - desired position )
If you’re using a proportional controller, it would be:
output = constant * (current position - desired position)
To get the robot to drive to the tetra, you want the pan position of the camera to center. That will give you the current position and the desired position. You can determine the constant through experimentation. There is a bit more to it given that for output, no movement is at 127 not 0. You also have to have a way to make sure it will still go forward when centered.
We used a very similiar technique last Saturday and the robot would reliably drive toward the tetra as long as the camera tracked it.
Matt
Okay, does anybody know what the variable for the camera pan servo is in user_routines_fast.c ??? Please help!
If you look at the source code you will find that the variable is cam.servo_pan, unless I am mistaken.
Edit:
It might be cam.pan_servo