Jump to content

Khepera III Toolbox/Examples/infrared proximity sensor response

From Wikibooks, open books for an open world

This example shows how to experimentally measure the response of the infrared sensors in proximity mode. The robot starts right in front of an obstacle and then moves backwards in small steps. After each step, a series of infrared proximity measurements are taken.

Setup

[edit | edit source]

Boot a Khepera III robot and make sure it is connected to your computer via WLAN. In the following explanation, we assume that you are working with robot 203. Put the robot in front of an obstacle and make sure that there is at least 50 cm space behind it.

Copy the motor_initialize, motor_stop and infrared_proximity programs onto the robot

cd Programs
k3put +203 motor_initialize motor_stop infrared_proximity

Log on to the robot

k3go +203

and type

cd your_username
./motor_initialize

to initialize the motors.

To check if everything is working, type

./infrared_proximity

If your robot touches the obstacle in front of it, you should get results like this:

$IRPROXIMITY,0,44038,41,11,405,3963,3965,827,3,61,34,3108,3010

The two highest values in the middle (3963 and 3965) belong to the front sensors and are those which we actually use in this experiment. These values may differ in your setup, since they are heavily influenced by the color and texture of your obstacle. Don't worry if you get values around 3000.

Running the Experiment

[edit | edit source]

Position the robot right in front of your obstacle (such that it touches the obstacle) and launch

./run.pl

The robot will now move backwards in small steps and take 10 infrared measurements which are stored in a file called run_results in the same folder. A complete run will take about 2 min, and the robot will stay at its place afterwards.

Parsing the Result File

[edit | edit source]

Type the following line to process the result file

./parse_results.pl 5 < run_results > matlab_run_results_5
./parse_results.pl 6 < run_results > matlab_run_results_6

Sensors 5 and 6 are the two front sensors. You could - in a similar fashion - take measurements with the other sensors as well.

Plotting the Result in Matlab

[edit | edit source]

Launch Matlab and type

plot_results

The resulting diagram will show a curve for both sensors. Each point is an average of 10 samples.

Notes

[edit | edit source]

The infrared proximity sensor values decrease exponentially with distance. Depending on the color and shape of your obstacle, however, the curve can be significantly shifted. This is especially true for very dark obstacles (limited reflection), or thin obstacles (limited reflection surface). Be aware that the floor will have an influence for distances above 5 cm as well, as part of the emitted IR light is reflected there. Furthermore, a significant amount of ambient IR light (e.g. daylight on a sunny day) will also impact on the results.

In the folder of this example, you will find the two files ir_proximity_reponse_blackfloor.txt and ir_proximity_reponse_blackfloor.eps. These are measurements taken on a dark (dark grey) floor (low reflection) in front of a white wall (high reflection) in a room with low ambient IR light.