While loops

6 replies [Last post]
TreeTreeTree
TreeTreeTree's picture
Title: NooBot
Joined: 05/20/2013
Posts:
BotPoints: 10
User offline. Last seen 9 years 49 weeks ago.

I know I'm cutting it close to competition here but I need to ask-
I'm using the function:
"while(get_object_count(color)>0)" to begin color tracking.
But even when the blob is directly in the line of sight of the camera, it regards the statement as false and promptly ends the loop. Can anyone help???

Marty Rand
Marty Rand's picture
Title: Botball Youth Advisory Council
Joined: 07/04/2009
Posts:
BotPoints: 253
User offline. Last seen 8 years 43 weeks ago.

Are you calling camera_update(); before the while loop? Also, is your color model set correctly?

-Marty Rand
{
Senior programmer at Norman Advanced Robotics

Former senior programmer at Whittier Middle School

Youth Advisory Council

All around nerd
}

TreeTreeTree
TreeTreeTree's picture
Title: NooBot
Joined: 05/20/2013
Posts:
BotPoints: 10
User offline. Last seen 9 years 49 weeks ago.

I thought the update might be an issue so I tried calling it before the while loop as well as in the while loop itself and it didn't clear up anything. I'm pretty sure the model is set up correctly as well... :(

Beta
Beta's picture
Title: The Magnificent
Joined: 02/24/2012
Posts:
BotPoints: 266
User offline. Last seen 9 years 17 weeks ago.

Hmmm... Try putting the camera_update(); back in the while loop and copy+paste your entire source file to the forum. Maybe there's something else going on.

Braden McDorman

Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.

Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.

Thatsillogical
Thatsillogical's picture
Title: NooBot
Joined: 04/19/2013
Posts:
BotPoints: 26
User offline. Last seen 9 years 11 weeks ago.

We find that the statement while(get_object_area(CHANNEL, 0) > 1000) works better. What this does is it tells if the blob of the largest size (0) of color channel CHANNEL is greater than 1000. Our team finds this better because tiny blobs can show up all the time and they can interfere with the blob count, even when looking at white space, and this checks that the blob is larger than 1000 pixels, and thus not one of those phantoms. TL;DR this method cuts out some of the camera noise.

:3

Thatsillogical
Thatsillogical's picture
Title: NooBot
Joined: 04/19/2013
Posts:
BotPoints: 26
User offline. Last seen 9 years 11 weeks ago.

Also, make sure that you executed camera_open(LOW_RES); before any of this, or else the camera will not be on. You could check if your camera is focused too.

:3

milanjoy
Title: NooBot
Joined: 06/13/2017
Posts:
BotPoints: 778
User offline. Last seen 21 hours 9 min ago.

Accidentally I have come across this website and good to see the details regarding the while loop described https://emeraldcutbezelring.com here. The usage of while in a programming language is specified here and it has a great impact. I am looking for more clarification regarding the topic and keep sharing more details here.