Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   AUTO TRACKING!!!!!!:( (http://www.chiefdelphi.com/forums/showthread.php?t=33850)

Code\\Pilot 15-02-2005 19:27

Re: AUTO TRACKING!!!!!!:(
 
Quote:

Originally Posted by devicenull
I had this same problem. Rather then spend a long time fixing it, I just control the servos right off of the RC.

It's working fine, and is legal (I had thought it wasn't at one point, but there is a question in the Q&A thing that says otherwise, ID 1480)

Here's the code that we are using.. it should be easily changed to other configurations
Code:

//Pan and tilt servos
#define cam_pan pwm01
#define cam_tilt pwm02
//Internal posistion variables
unsigned char cam_p=128;
unsigned char cam_t=128;

if (cam.x == 0 && cam.y == 0) {
                //cam_pan and cam_tilt control the servo's on the mount
                //cam_p and cam_t are our local variables
                cam_pan = cam_p;
                cam_tilt = cam_t;
                //Tell the camera where the servos are,
                //so we get useful values when it finds a target
                camera_set_servos(cam_pan,cam_tilt);
                //What color do we want to track?
                camera_find_color(GREEN);
                //This does all the panning
                cam_p += 10;                //X pan
                if (cam_p > 210) { //if we hit the x limit
                        cam_p = 46;                //start over
                        cam_t += 10;        //but change the tilt
                }
                //if we've tilted too much
                if (cam_t > 117) cam_t = 97;
        }
        else {
                //sometimes we get nonsense packets, this fixes them
                if (cam_pan > 0 && cam_tilt > 0) {
                        //update the servo and our var with new servo values
                        cam_p = cam_pan = cam.pan_servo;
                        //update the tilt servo with new tilt value
                        cam_tilt = cam.tilt_servo;
                }
        }

The trick here is we fool the servo into thinking the servos are connected to it. We do that with the camera_set_servo command. After it finds a target, we update the servos with where the camera thinks it is. The only thing I wanted to do with this code is get rid of the internal variables that hold the servo posistions.

when do you tell it to stop and go for the tetra??


All times are GMT -5. The time now is 19:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi