This example shows how to experimentally measure the real speed of the robot using the floor sensors. A sheet of paper is put on the floor, which the robot traverses at the speed to be measured. Using the floor sensors, the robot detect when it enters and leaves the sheet, and records both times. Since the length of the sheet is known, the real speed can be calculated.
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. Stick a white sheet of paper on a dark floor, and place the robot in front of the paper.
Copy the motor_initialize, motor_stop and infrared_proximity programs onto the robot
cd Programs k3put +203 motor_initialize motor_stop infrared_proximity
Then, copy the measure_real_speed program from the examples folder onto the robot
cd ../Examples/measure_real_speed k3put +203 measure_real_speed
Log on to the robot
cd your_username ./motor_initialize
to initialize the motors.
Before taking speed measurements, we need to configure the floor thresholds when entering and leaving the sheet of paper, as well as the size of the paper.
To find out the floor thresholds, type
once with the robot on the white sheet of paper and once with the robot on the dark floor. You will get results like this:
# On the dark floor
# On the white sheet of paper
where the two last numbers in each measurement belong to the floor sensors. The threshold used when entering the paper (--floor-threshold-on) should be just slightly below the value measured on the white sheet of paper, i.e. 3900 in our case. The threshold used when leaving the paper (--floor-threshold-off) should be a bit higher than the measurement on the dark floor, i.e. 3200 here.
To test if the thresholds work, place the robot about 5 cm in front of the sheet and launch
./measure_real_speed --speed 10000 --floor-threshold-on 3900 --floor-threshold-off 3200
The robot should report when it enters and leaves the paper, and stop about 5 cm after the sheet. If the result is not satisfying, adjust the thresholds and test again. The motor_stop program may be helpful to stop the robot in case the measure_real_speed program does not detect the edges of the paper.
Running the Experiment edit
Open run.pl with a text editor and adjust the floor thresholds. Also adjust the paper size in case you are not using an A4 sheet (long-wise).
Position the robot in front of your sheet of paper, and launch
The robot will now cross the sheet of paper in forward and backward direction many times with different speeds, and the results are stored in a file called run_results in the same folder.
Parsing the Result File edit
Type the following line to process the result file
./parse_results.pl < run_results > matlab_run_results
Plotting the Result in Matlab edit
Launch Matlab and type
In addition to plotting the real speed for various speed setpoints, this will also calculate and plot a speed factor, i.e. the ratio between real speed and speed setpoint.
The resulting speed factor will be about 7.1e-6 m/(s * unit), which means that a speed setpoint of 10000 corresponds to 7.1 cm/s.