Changing the search pattern

Hey, I wanted to tell a problem that I’ve had with the CMU Cam, and hopefully want to hear a way to fix it, if anyone can help, thanks!

I’ll try to explain it best as I can, bear with me…

When the search pattern for the camera starts, it is in the lower left position, and it goes across that level in a certain number of intervals, which can be set to whatever I’d like. However, when moving up to the next level, it goes from the bottom right position to the middle left, and the problem is, if the camera sees the light (red light turns on) in the process of moving from the bottom right to the middle left, it loses it by the time it actually sweeps all the way to the middle left position, so it then starts the search pattern from the bottom left position again.

As you can see, this is an endless loop, that can be a problem at times. Does anyone know how to change the search pattern so that instead of moving from the bottom right position to the middle left, it moves to the middle right? That would solve the problem. I’ve looked through the code a bit, mostly in tracking.c, but didn’t really see much, though I’m still looking. Just wanted to know if anyone has already had this problem and solved it.

I had a similar problem aswell. Go to tracking.h and put this code right under where it says

  ///////////////////
//                     //
//  search code  //
//                   //
///////////////////

The old values are commented out. What this does is it ensures that even if the camera sees a glimpse of the light, and loses it, it will stay at it’s current value and keep searching if it loses it. But once it finds it, it functions normally and tracks the light. It’s a nice quick fix :). Enjoy!

new_search = 0;
//temp_pan_servo = 0;
temp_pan_servo = (int)PAN_SERVO;
//temp_tilt_servo = TILT_CENTER_PWM_DEFAULT;
temp_tilt_servo = (int)TILT_SERVO;

Hmm, seems like that would work. I’ll definately try that once I get to work on the thing again in Atlanta. Just let me make sure if I understand correctly, if the camera sweeps up and catches it, but then loses it, instead of restarting the loop, it’ll just keep searching where it left off? If so, that’s a great help. Thanks a lot.

Yeah, basically, the camera wont ever go to the restart position when searching, even when it finds it for a second and loses it. It will go to the start position if it reaches the end of the search pattern. We used this in our code and it hasn’t let us down, so I’m gunna go ahead and say it works perfectly.

Don’t u mean in tracking.c??? i dont beleive there is search code within tracking.h…am i right in saying this or am i a complete idiot??

Actually, it is in tracking.c There is no tracking code in tracking.h (though there are values used for the tracking code there).

This fix works extremely well for this tracking error, our team employed it as well for the camera searching.

Yeah, that’s what I meant sorry. lol but atleast u got the idea.

tracking.c