Prepare the Aruco Board
This tutorial is referenced to the ardupilot.org
Remark
The example grid board assume you are flying a tiny drone. Otherwise, please create your own board by yourself.
Check the IDs You Need
Open the file
~/catkin_ws/src/aruco_gridboard/data/layout-my.yaml
and you will see the following configuration:
ids:
- 104
- 111
- 106
- 105
- 101
- 110
- 103
- 102
- 107
- 109
- 100
- 108
These 12 IDs represent the aruco tags that will be recognized by the system. Edit them if you want to work on a customized board.
Download the Board
The aruco board can be downloaded from here if you do not want to modify it.
Make Your Own Board
Go to
~/catkin_ws/src/aruco_gridboard/src
Compile the create_board.cpp
by
g++ -ggdb create_board.cpp -o createboard `pkg-config --cflags --libs opencv`
Then, run createboard
to generate the image file and content of yaml file.
./createboard
A message will list all neccessary input parameters.
Parameters | |
---|---|
w | number of markers in x direction |
h | number of markers in y direction |
l | length of marker (in pixel) |
s | space between markers (in pixel) |
d | type of marker |
f | ID of first marker (not available if you are not using my fork) |
Example input:
./create_board_wID board.jpg -w=10 -h=6 -l=700 -s=140 -d=16 -f=100
An image board.jpg
will be created. Copy the ouput from the terminal and create a yaml file. A yaml file layout_<markers in x direction>x<markers in y direction>_<markerLength>.yaml
will be automatically create if my fork was used.
Put the new yaml file to ~/catkin_ws/src/aruco_gridboard/data
Open detection_rpicam.launch
and change the parameter
<param name="board_path" value="$(find aruco_gridboard)/data/layout-my.yaml" />
to your new yaml file.
Print your image.
Remark
The size of your grid board determine the range of your aircraft. As mentioned before, the grid board act as mock GPS system. If the board is too small, it will easily lose its sight on markers. It is recommended to create the markers big enough for your aircraft too see at its altitude. At least 4 markers should be visible by the aircraft.
Camera Calibration
This tutorial is referenced to the ROS.org
Prepare the checkerboard
Download the checkerboard here
The checkerboard is already with known dimension, which are 108mm squares. To print it on a A4 size paper, open the printing option dialog before printing and adjust the percentage size. I diminished the checkerboard to 20% of its original size, so the squares became 21.6mm.
Calibration
Make sure raspicam_node has been installed in Raspberry Pi
launch the ROS node and enable raw image
roslaunch raspicam_node camerav2_1280x960_10fps.launch enable_raw:=true
Run the Calibration Program
rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.0216 image:=/raspicam_node/image camera:=/raspicam_node
or
rosrun camera_calibration cameracalibrator.py --size 8x6 --square <square size> image:=/raspicam_node/image camera:=/raspicam_node
if you have a customized checkerboard
Remark
if camera_calibration is not found, run:
sudo apt-get install ros-kinetic-image-pipelline
you will need to remake the raspicam_node after running the command.
A calibration window which highlight the checkerboard will pop up. Rotate, tite, and move the checkerboard slowly until the X
, Y
, and Size
bar are filled up. When Calibration
button lights, press it. The window will freeze but it is working. Wait for it patiently.
Something like this will be shown in the terminal:
D = [-0.33758562758914146, 0.11161239414304096, -0.00021819272592442094, -3.029195446330518e-05]
K = [430.21554970319971, 0.0, 306.6913434743704, 0.0, 430.53169252696676, 227.22480030078816, 0.0, 0.0, 1.0]
R = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0]
# oST version 5.0 parameters
[image]
width
640
height
480
[narrow_stereo/left]
camera matrix
430.215550 0.000000 306.691343
0.000000 430.531693 227.224800
0.000000 0.000000 1.000000
distortion
-0.337586 0.111612 -0.000218 -0.000030 0.0000
rectification
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
projection
1.000000 0.000000 0.000000 0.000000
0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 1.000000 0.000000
Switch back to the calibration window and click commit
to save the result.
Remark
If Segmentation fault
is shown after commit, check if this file exist:
~/.ros/camera_info/camerav2_1280x960.yam
ROS need to be re-launched to apply the calibration data.
Troubleshooting
If package not found
is shown, run:
sudo apt-get install ros-kinetic-rqt-reconfigure
If found no plugin matching
is shown, run:
rqt --force-discover
and select the reconfigure in the pop up window