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.

• Initialize sensors<br />

• Initialize <strong>the</strong> blob search and color parameters<br />

In order to initialize <strong>the</strong> camera, <strong>the</strong> RGB Cubewhich contains <strong>the</strong> color<br />

information and BlobSearch are initialized. We also set <strong>the</strong> automatic white<br />

balance to <strong>of</strong>f and exposure control to direct manual mode. The appropriate<br />

parameters for <strong>the</strong> image format, frame rate, sensor mode and clock are set<br />

for <strong>the</strong> blob search at this point.<br />

Thesecondstepisinitialization <strong>of</strong><strong>the</strong>motors. Thecorrespondingpinsin<br />

<strong>the</strong> microcontroller for <strong>the</strong> motors are set to control <strong>the</strong> direction <strong>of</strong> motors<br />

and PWM generation. The PWM generation is made by using <strong>the</strong> timers<br />

were available in <strong>the</strong> microcontroller. Output compare mode <strong>of</strong> <strong>the</strong> timers<br />

usedinordertocreate <strong>the</strong>PWMneededtorun<strong>the</strong>motors. Outputcompare<br />

function is used to control <strong>the</strong> output waveform and indicate when a period<br />

<strong>of</strong> time has elapsed. When a match is found between <strong>the</strong> output compare<br />

register and <strong>the</strong> counter, <strong>the</strong> output compare function:<br />

• Assigns a value to pins<br />

• Sets a flag in <strong>the</strong> status register<br />

• Generates an interrupt<br />

Using <strong>the</strong> described output comparison, we created <strong>the</strong> desired PWM<br />

wave to run <strong>the</strong> motors and camera servo.<br />

The sensors, which are <strong>the</strong> bumpers for <strong>the</strong> current state <strong>of</strong> <strong>the</strong> robot,<br />

are initialized by setting <strong>the</strong> corresponding pins in <strong>the</strong> microcontroller.<br />

As a final step in <strong>the</strong> initialization, <strong>the</strong> blob search and color parameters<br />

are set. The blob search parameters, which are grid size, top, bottom,<br />

left and right borders <strong>of</strong> <strong>the</strong> image are defined. Similarly <strong>the</strong> blob search<br />

geometry options are defined, which are <strong>the</strong> color id, minimum-maximum<br />

area <strong>of</strong> <strong>the</strong> blob, minimum-maximum circularity <strong>of</strong> <strong>the</strong> blob and minimummaximum<br />

perimeter <strong>of</strong> <strong>the</strong> blob. For each color, <strong>the</strong> blob search geometry<br />

options should be defined separately with <strong>the</strong> proper coding.<br />

Lastly, <strong>the</strong> color information should be defined for each color we are<br />

searching. The color information is calculated ei<strong>the</strong>r by <strong>the</strong> ST color picker<br />

69

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

Saved successfully!

Ooh no, something went wrong!