Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Programming for CMUCam (http://www.chiefdelphi.com/forums/showthread.php?t=50702)

teh_pwnerer795 24-12-2006 16:32

Programming for CMUCam
 
Hey quick question..

To stop the Servo_Track(); from tracking.. could i just say Tracking_Initialized = 0; to stop it?

bear24rw 24-12-2006 16:56

Re: Programming for CMUCam
 
You can just not call the function..

if (track_enabled == 1)
{
Servo_Track();
}

chris31 24-12-2006 17:37

Re: Programming for CMUCam
 
Remember that the robot runs on a continuos loop. So instead of stopping it, you just need to not call in on they next loop if you dont want it to be running.

teh_pwnerer795 24-12-2006 18:47

Re: Programming for CMUCam
 
Quote:

Originally Posted by chris31 (Post 544966)
Remember that the robot runs on a continuos loop. So instead of stopping it, you just need to not call in on they next loop if you dont want it to be running.

How would i do that? ..

chris31 24-12-2006 18:51

Re: Programming for CMUCam
 
Dont call Servo_trace in you user_routine when you dont want it to run. Say you only want it to run when switch_1 is on then it would look like this

PHP Code:

if (switch_1 == 1)
{
Servo_Track();



JBotAlan 24-12-2006 19:01

Re: Programming for CMUCam
 
Quote:

Originally Posted by teh_pwnerer795 (Post 544981)
How would i do that? ..

In user_routines.c in Kevin Watson's "bells and whistles" version of his camera code (which you are probably using if you are calling Servo_Track()) there is this code:
Code:

        // This function reads data placed in the T_Packet_Data
        // structure by the Camera_Handler() function and if new
        // tracking data is available, attempts to keep the center
        // of the tracked object in the center of the camera's
        // image using two servos that drive a pan/tilt platform.
        // If the camera doesn't have the object within it's field
        // of view, this function will execute a search algorithm
        // in an attempt to find the object.
        if(tracking_menu_active == 0)
        {
                Servo_Track();
        }

You are looking at the last bit there. That code checks if the code in terminal.c (I think) has set the tracking_menu_active variable to 0; if it has, it calls Servo_Track(). What you want to do is modify the line two lines above Servo_Track(); to read something like:
Code:

if((tracking_menu_active == 0)&&(whatever condition you want here))
where "whatever condition you want here" is replaced by what you want your code to check to see if it should call Servo_Track(). You could have a variable, for instance, called jbotRulesTheWorld (hey, I just had to add that:D ) and you want your code to call Servo_Track() if jbotRulesTheWorld equals 1. You would write:
Code:

if((tracking_menu_active == 0)&&(jbotRulesTheWorld == 1))
in place of the original
Code:

if(tracking_menu_active == 0)
Good luck, and if you need more help don't hesitate to post back here.

JBot (rules the world...:) )

EDIT: Oh, well Chris31 beat me to it. I'll still leave this post here for clarity.

teh_pwnerer795 25-12-2006 00:23

Re: Programming for CMUCam
 
found an easier way .... i'll just declare Camera_Idle(); ... that'll stop everything that its trying to track.. but thxs alot for ur help:)


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

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