This is an old revision of the document!
To program a robot and test out algorithms, robotists will run their designed algorithm on a simulator and fine tune the result from there, before transferring to the real robot and inputting the offset values.
This is to reduce physical damage and wear and tear on the robot if the tests of algorithms were carried out on the robot.
I will be using “Webots” program on Windows 7 to do simulations.
In DASL we have the USB dongle to give us the license to use the program. Basic tutorials for Webots are here[http://www.cyberbotics.com/dvd/common/doc/webots/guide/chapter7.html].
A more comprehensive tutorial that gives focus on the programming aspects of the controllers in the simulator is found here[http://en.wikibooks.org/wiki/Cyberbotics%27_Robot_Curriculum].
Take this section as a side quest.
For those who have difficulty understand the codes of the tutorials in the 2nd link, I will use the
'intermediate_line_following' example to decipher the code based on my understanding.
My code together with some brief explanation of each part can be found here[https://github.com/mr1789/darwindasl/blob/master/lineFollowingEPuck.cpp].
This section looks into the source code of the sample program in Webots to visually track object according to colour.
'Webots→projects→robots→darwin-op→worlds and open
visual_tracking“ in Webots.
In the text editor page of Webots, open 'Webots→projects→robots→darwin-op→controllers→visual_tracking→VisualTracking.cpp
Here[https://github.com/mr1789/darwindasl/blob/master/VisualTracking1.cpp], in VisualTracking1.cpp
, is a modified code of VisualTracking.cpp which includes:
*my explanation of each aspect of the code in the Webots context
*additional functions to output the values of coordinates of the center of the ball in the camera screen.
': Program will prompt you to copy the relevant files to another location where you can edit. The original files cannot be edited.
====Tracking 2 balls of different colours====
This section teaches you how to dictate the colour of the ball to track.
To track blue ball, get the hue value of blue. The value should be around 230.
It need not be accurate because of the hue tolerance. Read up on computer vision to know more.
Next edit this line in 'visual_tracking.cpp
mVisionManager = new DARwInOPVisionManager(mCamera→getWidth(), mCamera→getHeight(), 230, 15, 60, 15, 0.1, 30);
from the original:
mVisionManager = new DARwInOPVisionManager(mCamera→getWidth(), mCamera→getHeight(), 355, 15, 60, 15, 0.1, 30);
Here are the results. Notice that the Y values are different. Hence by tweaking the HSV values of the object that you want Darwin to track in the DARwInOPVisionManager
====Tracking 2 balls of same colour====
Being able to make Darwin differentiate between 2 items of the same colour is relevant to my project as I will need Darwin to grab the correct rung of the ladder in order to ascend the ladder.
Create another ball.
Place each ball at the extreme corners of the camera.
I disable the head of Darwin to follow the ball.
The program states the value of the center of the ball it recognises as the average of the true center of two balls.
As seen from the picture, the resultant X and Y value when there are 2 balls point to the centre of the 360×240 pixels camera.
Compare it with when there is only one ball.
Using Darwin's in-built codes to differentiate the balls of the same colour would mean rewriting the whole code of Darwin, be it the real robot or in Webots.
This requires vast experience in programming which I do not have. I have to outsource the processing of the capture frames from the camera to other programs.
If doing on Webots, I will need a 32-bit Matlab linked to Webots.
On the real Darwin, I will be using OpenCV.
===Installing OpenCV to Webots NOT SUCCESSFUL===
This section is a guide to installing OpenCV to Webots.
I will be using tutorial programs which uses the Epuck robot as a guide through this installation guide.
Go here[http://sourceforge.net/projects/opencvlibrary/?source=dlp] to download OpenCV2.1.
I will be using version 2.1 since DASL's very own Darwin will be using OpenCV2.1.
According to the instructions here[http://www.cyberbotics.com/guide/section5.4.php], add these lines to Makefile:
LIBRARIES=-LC:\OpenCV2.1\lib -lcv210 -lcvaux210 -lcxcore210 -lcxts210 -lhighgui210 -lml210 -lopencv_ffmpeg210
#LIBRARIES=-LC:\OpenCV2.1\lib -lcv210d -lcvaux210d -lcxcore210d -lhighgui210d -lml210d -lopencv_ffmpeg210d
': I installed my OpenCV to the 'C:
' drive directly and not into the 'Program Files'''. In addition comment out the 2nd line of libraries for the moment. I am not quite sure of its purpose, but anyway, not doing so will cause the program to fail to run.
Since it going to be a remote connection from local Windows 7 machine to a Ubuntu one, I use PuTTy to carry out SSH to Darwin.
Download the program here[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html]. To transfer files, here[http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html] provides a good run through on how.