Log in

View Full Version : Programming for CMUCam


teh_pwnerer795
24-12-2006, 16:32
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
You can just not call the function..

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

chris31
24-12-2006, 17:37
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
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
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


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

JBotAlan
24-12-2006, 19:01
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:
// 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:
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:
if((tracking_menu_active == 0)&&(jbotRulesTheWorld == 1))
in place of the original
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
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:)