The present example shows how to calibrate your setup in an automatic fashion by taking pictures of a marker that is moving around in your arena. Note that this requires that you have a mechanism to move a marker to precisely known positions in the arena. We have previously tested that with
- a well-calibrated mobile robot moving around and keeping track of its position using odometry
- a calibrated 2-axis traversing system
In the remainder of this chapter, we describe the procedure with a Khepera III mobile robot. Adapting this to another mobile robot (or other system) should be fairly straightforward.
Setup your experimental arena as if you would run an experiment. Make sure that the camera is mounted properly at its final position. It is furthermore advisable to run this procedure under the same light conditions and with the same markers as the final experiment. If you do not have makers in the final experiments, put a circular marker that can be well distinguished from the background on top of the Khepera III robot.
From the Khepera III Toolbox, copy the odometry_goto program onto the robot. This program tracks the position of the robot using the rotation of the wheels (odometry). In addition, a simple control algorithm moves the robot to any given position. Make sure that you properly calibrated the odometry of your Khepera III robot - carrying out the procedure with a badly calibrated odometry will result in huge errors. An a flat surface, a well-calibrated Khepera III robot will accumulate an error of about 10 cm after 10 m.
Also copy the motor_initialize program onto the robot and execute it to initialize the motors.
Preparing the Position File
In the folder Examples/Calibration/AutomaticSequential, you will find a file called positions with a series of target points. The points describe a 5-by-5 grid with a spacing of 50 cm between grid points. At each grid point, the robot will stop for 3 seconds, letting SwisTrack take several pictures. At the end, the robot goes back to the origin (0, 0) to allow for verification of the odometry error.
Adapt this file to the size and shape of your arena. You may also use the create_position_file_grid.pl script to generate such a file.
Once your position file is ready, copy it onto the robot.
Run SwisTrack and load the configuration file you use for the experiment. You may disable the calibration component, if you are using any. Add the Output particles via TCP component to your processing pipeline.
Make sure that your marker is detected reliably over the whole arena and that no other spot is detected. Removing points manually at a later step is tedious and error-prone.
Note that SwisTrack must be in manual mode (i.e. the Run button must not be pressed).
Running the Calibration
Carefully place the robot at the (0, 0) position in the arena. Pay attention to the orientation - the robot must point towards the (1, 0) point.
Adapt the scripts run_calibration.pl and trigger_swistrack_at_target_positions.pl. You will find instructions in these files, but you mainly have to provide the IP addresses of the robot and the computer running SwisTrack. Launch
./run_calibration.pl | tee calibration_output
The robot will start moving to the first target point and wait there for 3 seconds. During this time, SwisTrack will takes images and send the image position of the robot. These positions appear both in your terminal and in the file calibration_output.
Writing the XML Calibration File
To parse the calibration_output file, type
./parse_calibration_points.pl < calibration_output > matlab_calibration_output
To plot these points, launch Matlab and type
data = load('matlab_calibration_output') plot(data(:, 1), data(:, 2), 'bo');
Finally, the XML file can be created with
./write_xml_file.pl < matlab_calibration_output > calibration_points.xml
Calibrating a Multi-Camera Setup