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.

If <strong>the</strong> camera is set to SERVO MID, <strong>the</strong> position <strong>of</strong> <strong>the</strong> target is calculated<br />

with ’CalculatePositionGround’ function. The motor contributions<br />

are calculated using ’Triskar’ function, and <strong>the</strong> motor speeds from ’Triskar’<br />

are set with multiplier CLOSE. If <strong>the</strong> distance <strong>of</strong> <strong>the</strong> robot to target is less<br />

than 300 mm, <strong>the</strong> target is marked as acquired by setting ’color done =<br />

TRUE’.<br />

The detection <strong>of</strong> target acquired and game-over is done by controlling<br />

’color done’ on every loop. When <strong>the</strong> ’color done’ is set as ’TRUE’, <strong>the</strong><br />

camera head position is set to SERVO TOP, ’color done’ and ’blob found’<br />

are flagged as ’FALSE’, and color is incremented by 1. Since <strong>the</strong> current<br />

configuration is working with 2 colors, <strong>the</strong> case where ’color > 2’ is controlled<br />

for <strong>the</strong> game-over case. For that case, we introduced a variable as<br />

’reply counter’, which sets <strong>the</strong> number <strong>of</strong> replies/rounds to end <strong>the</strong> game.<br />

In <strong>the</strong> code, this variable is set as 5, that made <strong>the</strong> game to find and go to<br />

<strong>the</strong> targets 5 times, in <strong>the</strong> same color order defined. The work flow in <strong>the</strong><br />

main loop is shown in Appendix A.2.<br />

The class diagram that is showing <strong>the</strong> relation between <strong>the</strong> modules<br />

is reported in Appendix A A.1. We increased <strong>the</strong> modularity <strong>of</strong> <strong>the</strong> program<br />

by separating <strong>the</strong> code to improve reuse; breaking a large system into<br />

modules, makes <strong>the</strong> system easier to understand. By understanding <strong>the</strong> behaviors<br />

contained within a module, and <strong>the</strong> dependencies that exist between<br />

modules, it’s easier to identify and assess <strong>the</strong> ramification <strong>of</strong> change. We<br />

used <strong>the</strong> naming convention Init for initialization classes, functions. The<br />

algorithm are implemented inside <strong>the</strong> Motion and Vision classes. The motion<br />

algorithm is implemented by porting <strong>the</strong> s<strong>of</strong>tware simulator previously<br />

written to <strong>the</strong> microcontroller. The vision algorithms are also implemented<br />

in a similar manner. The camera calibration calculating <strong>the</strong> position <strong>of</strong> <strong>the</strong><br />

object was previously implemented in a Matlab script. Later, <strong>the</strong> script has<br />

been ported to <strong>the</strong> microcontroller.<br />

The rest <strong>of</strong> <strong>the</strong> implementation not mentioned above, focuses on pin<br />

assignments (in Appendix D.3), definitions <strong>of</strong> <strong>the</strong> constants, creation <strong>of</strong> <strong>the</strong><br />

header files.<br />

71

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

Saved successfully!

Ooh no, something went wrong!