Artificial Life - Robotics Tutorials
Artificial Life - Robotics Tutorials
11. Programming the ePuck for obstacle avoidance using potential fields
12. Adding ‘colour’taxis using potential fields
13. Combining potential fields
Getting Started – Objective: Familarity with Webots (User Guide Chapters 1-4½)
D:/ProgramFiles/Webots
4 windows appear:
• Copy the myBot world from webots to your world directory and rename it
(including the ‘textures’ directory).
• Edit the new world and change the controller entry to your controller.
• Open your world in Webots and make sure that your controller is active.
Artificial Life – Robotics Tutorials
EXERCISE 2:
Edit the program and type in some ‘printf’ messages at key points in the execution.
Compile, link and execute the code and check the results in the DOS console.
Example printf: printf(“In reset function….\n”);
A robot controller – can use C,C++,Python or Java -> controls one robot
A supervisor controller – can use C or C++ –> controls the world and one or more robots
Artificial Life – Robotics Tutorials
And finally
Differential Wheels
wb_distance_sensor_enable(ir0, TIME_STEP);
wb_distance_sensor_enable(ir1, TIME_STEP);
Artificial Life – Robotics Tutorials
EXERCISE 4:
• Modify the sensor reading/actuator setting code to create a robot which avoids
obstacles.
EXERCISE 5:
• Modify the sensor reading/actuator setting code to create a robot which
follows obstacles but otherwise stays still.
• Use the devC++ development system to do this
c:\Program Files\Webots\projects\samples\devices\worlds
EXERCISE 6:
• Play with the simulation and study the controller code (and the webots documentation).
1. Create a controller program template in C++ from the saved controller
i.e. copy webotsTemplate.cpp to joesEpuck.cpp
EXERCISE 8.
Create an simple obstacle avoidance behaviour for the Epuck
EXERCISE 9.
Create some simple ‘taxis’ behaviour for the Epuck
e.g. this could an attraction to the red block and and repulsion from the green
block
EXERCISE 10.
Combine your behaviours using simple priority based arbitration.
Use either an ‘if –then’ construct or (more advanced) a mechanism which yields
control to the particular behaviour (hint: create each behaviour as a class
which if its ‘releasers’ are met becomes available for execution, keep the
classes in an array, highest first and loop through the array).
Artificial Life – Robotics Tutorials
Adding vectors:
CVector sumV;
CVector anotherVector(200,67);
70 110
140
40
0 180
Sensor
300 240
angles
// create a set of 2 element vectors
CVector lv[8];
// fill with light sensor values and physical angle of sensor on robot
lv[0].setValues(ds_value[0],110);
lv[1].setValues(ds_value[1],140);
lv[2].setValues(ds_value[2],180);
lv[3].setValues(ds_value[3],240);
lv[4].setValues(ds_value[4],300);
lv[5].setValues(ds_value[5],0);
lv[6].setValues(ds_value[6],40);
lv[7].setValues(ds_value[7],70);
CVector res;
EXERCISE 12:
Implement and test the EpuckVector.wbt world.
Artificial Life – Robotics Tutorials
These are returned as arrays of pixels – the array size depends on how the
camera is configured.
You can get the width and height using the following webots functions:
width = camera_get_width(camera);
height = camera_get_height(camera);
image = camera_get_image(camera);
(See EpuckBlob.wbt)
Artificial Life – Robotics Tutorials
For more ‘redness’ the first integer would have a higher value.
For more ‘blueness’ the second integer would have a higher value.
For more ‘greenness’ the third integer would have a higher value.
Black is 255,255,255 and white is 0,0,0
To get the RGB values do the following:
To check for a red blob simply count the number of pixels in the
image that have more redness and compare that to the number of
pixels that have greeness or blueness.
If there is more redness then the camera can probably see something
red.
EXERCISE 13:
Implement and review the EpuckBlob.wbt world and try to understand how
the RGB system works.
Artificial Life – Robotics Tutorials
On/Off
Reset
Position 0
Switch
EXERCISE 14:
Check out the other rotation positions for each internal program
Artificial Life – Robotics Tutorials
EXERCISE 15:
Play with the EPuck functions and camera options using the EPuck
monitor
Artificial Life – Robotics Tutorials
EXERCISE 16:
Experiment with the real Epuck to see why it doesn’t work exactly as the
simulated version.
EXERCISE 17:
Implement a proportional controller on the simulated Epuck e.g. the nearer
the obstacle the faster the Epuck rotates. Transfer to the real Epuck and
see if you experience thrashing, hysterisis and dead zones. Code to
‘solve’ these issues.
Artificial Life – Robotics Tutorials
EXERCISE 18: TRASHCAN COMPETITION
• You should now have enought code samples and Webots experience to attempt a
competition.
• The competition is based on the subsumption architecture outlined in Robin Murphy's
book (Introduction to AI robotics) for the Trashcan competition.
• Here we will use the following: A world containing 1 red block, 1 green block and 2 yellow
blocks (as myEpuckBlob.wbt).
Rules
• Epuck starts at green block.
• Epuck searches for yellow blocks. When very close to a yellow block all led's are set on
(indicating that a yellow block has been found).
• Epuck searches for red block. When very near the red block all leds turned off (indicating
that trashcan has been found). <Yellow block removed manually>
• Repeat above for second yellow block.
• When finished return to green block.
Approach
• Ideally some for of arbitration architecture between behaviours should be implemented.
However, this could be simply a set of if-then statements.
• You can work individually or in groups.
• The potential fields approach and the blob tracking code samples may be useful,
pick and choose (or use a simpler solution) as you wish.