14.11.2012 Views

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

B.1. Microprocessor Code 89<br />

#ifdef NO_DEBUG<br />

Print_Int(speed[0],"b1 motor send:");<br />

Print_Int(speed[1],"b2 motor send:");<br />

Print_Int(speed[2],"b3 motor send:");<br />

#endif<br />

} else { //control hit else<br />

#ifdef NO_DEBUG<br />

Print_Int(control_hit,"hit?");<br />

#endif<br />

Blob_Search();<br />

#ifdef NO_DEBUG<br />

Print_Int(BlobCount ," blobs found...\n");<br />

#endif<br />

TPoint n_point;<br />

u8 k;<br />

s8 myBlob;<br />

s16 maxArea;<br />

maxArea = 0;<br />

myBlob = -1;<br />

/*<br />

* among <strong>the</strong> available blob <strong>the</strong> blob with <strong>the</strong><br />

* biggest size is selected as <strong>the</strong> blob<br />

*/<br />

for (k = 0; k < BlobCount; k++) {<br />

if (Blobs[k].ColorSetID == color) {<br />

if (maxArea < Blobs[k].Area) {<br />

maxArea = Blobs[k].Area;<br />

myBlob = k;<br />

}<br />

}<br />

}<br />

//if(BlobCount == 0){<br />

if (myBlob < 0) {<br />

//random search<br />

#ifdef NO_DEBUG<br />

USB_WriteString("Searching for a blob...\n");<br />

#endif<br />

/* in order to prevent continue turning to search for blob<br />

* counter introduced.<br />

*/<br />

if (blob_found == TRUE) {<br />

counter++;<br />

} else if (counter > 3 || blob_found<br />

== FALSE) {<br />

/*search_direction changes <strong>the</strong> turning side to left to<br />

* right or vice versa

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!