Camera Tracking

4 replies [Last post]
champt10's picture
Title: NooBot
Joined: 04/20/2010
BotPoints: 3
User offline. Last seen 10 years 51 weeks ago.

Can someone please help me with this code? When I try testing, the robot will not exit the loop.

Any help is appreciated!

Title: NooBot+
Joined: 07/21/2010
BotPoints: 22
User offline. Last seen 9 years 48 weeks ago.


Sorry I didn't have much time to look at this but my guess is track_count(cube) on line 10 is never 0. I couldn't tell if at some point you turn away from the cubes but even if you do, there will probably still be some random splotch that matches the cube color model. You could instead try something like while(track_size(cube, 0) > 50) to filter out tiny blobs that tend to show up in shadowy places if you're using a dark model; however, this wouldn't work if you're always going to be facing the cube.

Let me know if that fixes anything.

Good luck!

-Evan Wilson
Hampton High School

RDoherty's picture
Title: NooBot+
Joined: 05/18/2011
BotPoints: 9
User offline. Last seen 11 years 18 weeks ago.

I'll give it a try, but, if I may comment, this code looks like you're adapting it from some other task. I suggest overall that you start over with the outer loop only [while (camcheck == 0)]. Move the bot by hand watching the video screen on track mode and see if it exits. You'll have to put in that loop the test that makes camcheck increment, but you might be able to see what the numbers look like with some printfs.

Second, the previous commenter is correct: in order to exit the inner while, track_count would have to be zero. With blobs as big as the blocks are, the track_size will be in the high hundreds at most times. So, "while( track_count(cube) > 0 && track_size(cube, 0) > 1000 )" will let you out of the inner loop so you can check the camcheck value and exit the loop.

It is not clear what move(75, 75) does, but I will assume you either sleep of block until the move is done.

A note on form: your call to track_update() once outside the inner loop is typical just to get things going, but you should look into the following fragment:

track_update();//get latest video info
//Other stuff
}while(track_count(cube) > 0);

This is just easier to follow. Also, look into if(...) else if(...) else if(...) to do only one of three things. Note that you call track_update() again within the inner loop, so the data may have changed.

Sorry I'm late with this, but there's always next year. Hope some of it helps. It's frustrating not having the ability to indent in this comment!

If a robot is misbehaving, it's doing EXACTLY what you told it to do.

Title: MiniBot
Joined: 06/21/2011
BotPoints: 29
User offline. Last seen 11 years 11 weeks ago.

can someone delete this spambot's post? ^^^^^^

wmyers's picture
Title: Advisor
Joined: 02/24/2011
BotPoints: 54
User offline. Last seen 8 years 28 weeks ago.

At GCER we didn't have access to the internet too often. Thus quite a few spam posts. Trying our best!

Wesley Myers
YAC Advisor
Botball International Champion 2007 and 2008

Carnegie Mellon University 2012
Electrical and Computer Engineering
Computer Science and Robotics