The purpose of this practical is to:

- Make yourself more familiar with functionality and control of the Khepera robot
- Maintain a reliable estimate of the position of the robot
- Make the robot circumvent an obstacle
- If there is time, try use information from a camera image for the control of the robot. At least you should get an idea about other things to do with a robot, for more ideas please read the V. Braitenberg's book on Vehicles

Note that if you did not download the IVR software to your own filespace, you will need to do so to be able to communicate with webots or the robot. The Matlab code is available here: http://www.inf.ed.ac.uk/teaching/courses/ivr/IVR_software_2008.tar.z and here is the Webots code (if needed at all): http://www.inf.ed.ac.uk/teaching/courses/ivr/kheperam-Webots6.2.tar.gz.

In this practical we will just try using a simple script to control the robot and to give it an ability to adjust its parameters.

The angle can be calculated based on the movements of the robot by a simple formula, but it it may be better to use a complete odometry (x-coordinate, y-coordinate and angle) in order to keep track of the robot's position.

What ever the robot does, it is effective only if the robot's wheels are turning. The wheel revolutions can be sensed from the wheel encoders. From these readings the robot can update its position where we assume that it started at the point (x=0, y=0, φ=0). The general idea is that the average of the speeds of the two wheels gives a good estimate of the distance travelled whereas the difference between the speeds tells how the bearing angle of the robot changes. Some geometric considerations lead to these formula for the x-coordinate, y-coordinate and bearing angle φ:

x ← x + Δx =x + 0.5*(v

y ← y + Δy =y + 0.5*(v

φ ← φ + Δφ = φ - 0.5*(v

The formula contains, in addition to the wheel speeds (taken as counter values) , the parameter R that denotes the radius of the robot (or rather half the distance between its wheels). The parameter (about 4cm) can be determined by measurement, but it may not be sufficiently precise.

In order to calibrate the odometric formula you can make the robot turn (s. first practical) while calculating the angle. If the robot has turned exactly once (or a number of times for better precision) the angle estimate can be checked and the "parameter" can be tuned until the measurement is sufficiently correct.

- you may need to add "/opt/matlab/toolbox/shared/instrument" to your matlab path

- set_counts for initialisation of the counters
- read_counts to obtain information for the odometry
- set_speeds to operate the robot
- open_robot to initialise and
- close_robot to terminate the communication

One way of reading the sensor values is:

s2=regexp(sensor, '\,', 'split')

for i=1:8

sr(i)=str2num(s2{1,i+1});

end;

The first step is the extraction of the robot from the scene. For this purpose you can use background subtraction. It leaves you with a more or less round spot. The center of mass of the spot can be used as an approximation of the position of the robot. You may consider using instead the center of the smallest circle that encloses all of the robot pixels.

Place now two of the wood-bots near each other such that your palm fits conveniently in between them. Now, you may in the same way (or by using code from your assignment) extract the position of the wood-bots.

Now try to use visual servoing in order to move the Khepera right in between the wood-bots. If the wood-bots were placed appropriately (correct if necessary) this task can be achieved also using the IR-sensors on the left and right sides of the Khepera.

If vision is not sufficiently precise due to lighting conditions or computational problems, the IR sensors will provide you with more precise local information. On the other hand, if the Khepera starts in a distant corner of the box, vision might be preferable.

Clearly, if the robot does not receive any noteworthy IR inputs it should rely on vision. Vision is also needed in order to disambiguate the wood-bots from e.g. a starting position in a corner. As soon however the robot is near the wood-bots and receives above-threshold input from both left and right IR sensors. If the robot had more time to repeat the task it could make use of a Bayesian decision scheme.

You may not have had the time to work yourself down here. Nevertheless, please try to consider all the tasks and discuss them with your tutor, because they will be part of the second assignment.