Camera program, robot stops when it's called on.

5 replies [Last post]
Precision
Precision's picture
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 44 weeks 3 hours ago.

When we call on getbox(0); our bot just stops. and does nothing, as it stares at the Red blocks on the table, we have the camera set to dark red for 0.

void getbox(int channel)//find boxes//
{
int x, xMax = 160;

while(2)
{
track_update();

if(track_count(channel) < 0)
{
x = track_x(channel,0);
MoveFwd(300,50L);
}
else{
ao();
}

Any helps is appreciated.

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 841
User offline. Last seen 14 min 42 sec ago.

Two points here.

First, your if statement will only evaluate to True if there are less than 0 blobs seen by the camera for that channel. Since 0 is the minimum number of blobs seen, the if statement will always evaluate to false. As a result, your code is simply looping the ao(); command.

Second, I'm not exactly sure why your while condition is 2. Nonzero integers such as 2 are always considered to be True for the purposes of while loop conditions, so your while loop will loop forever. What behavior are you trying to achieve with the while loop?

-Jeremy Rand
Senior Programmer, Team SNARC (2012), Norman Advanced Robotics (2010-2011), Norman High (2008-2009), Norman North (2005-2007), Whittier Middle School (2003-2004)
2012 VP of Comm, 2011 President, Botball Youth Advisory Council (2009-2012)

Precision
Precision's picture
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 44 weeks 3 hours ago.

so what do i do to make the robot move toward a red block really slowly?

Precision
Precision's picture
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 44 weeks 3 hours ago.

we're very very short on time, any help please someone >.<

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 841
User offline. Last seen 14 min 42 sec ago.

Make your if condition use > (greater than) rather than < (less than). That should improve the behavior.

-Jeremy Rand
Senior Programmer, Team SNARC (2012), Norman Advanced Robotics (2010-2011), Norman High (2008-2009), Norman North (2005-2007), Whittier Middle School (2003-2004)
2012 VP of Comm, 2011 President, Botball Youth Advisory Council (2009-2012)

Precision
Precision's picture
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 44 weeks 3 hours ago.

we're just gonna forget about the camera, too much trouble, not enough time, not enough raw information for us to understand to make it happen. :(