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

5 replies [Last post]
Precision
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 11 years 11 weeks 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: 1168
User offline. Last seen 7 years 18 weeks 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-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

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

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

Precision
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 11 years 11 weeks 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: 1168
User offline. Last seen 7 years 18 weeks ago.

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

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Precision
Title: MiniBot
Joined: 06/21/2011
Posts:
BotPoints: 29
User offline. Last seen 11 years 11 weeks 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. :(