Is there anything that you can call to figure out what the position of the servo is? What method would I call?
—Thankx
There isn’t a function or method to tell you the position of a servo.
This is an overview of how the servo works:
The software tells the robot controller to send the servo a position (0-254). Then the servo will try with all it’s might to get to and stay at that position. There is never any feedback to the robot controller from the servo.
How do we know the orientation of the camera then?
The camera is what is driving your servos, and it tells the RC where it thinks the servo is at. The actual variable used to relay this is described in the documentation for the camera. You can also find it in the source code of the default camera tracking code, particularly where it echoes the information back through the serial port by a printf.
I’m assuming you have the servos hooked up directly to the camera and are using the tracking feedback loop in the camera. In the default code in user_camera.c : camera_track_update() the RC gets some data back from the camera. Among this data is the pan & tilt positions (cam.pan_servo & cam.tilt_servo) of the servos. The pan position is used in user_routines.c : Camera_Processing() to make the robot turn left / right, and with a few more lines of code you can make the robot drive forward / backward based on the tilt.