Copyright statement: Davidwang's original article is strictly prohibited from being used in any commercial way and may be reproduced only with authorization.
Compiling and installing kalibr seems simple, but in fact it is extremely dangerous. If you are not careful, it can easily take a week. After going through many difficulties and dangers, the process is now recorded as follows:
Prerequisite: ubuntu 18.04, ros melodic has been installed correctly
(1), first edition
1. Install dependencies
sudo apt-get install python-setuptools python-rosinstall ipython libeigen3-dev libboost-all-dev doxygen libopencv-dev ros-melodic-vision-opencv ros-melodic-image-transport-plugins ros-melodic-cmake-modules python-software-properties software-properties-common libpoco-dev python-matplotlib python-scipy python-git python-pip ipython libtbb-dev libblas-dev liblapack-dev python-catkin-tools libv4l-dev
2. Install python-igraph
sudo pip install python-igraph --upgrade
本步骤如果不成功,则可以直接安装:
sudo apt-get install python-igraph
3. Set up the workspace
mkdir -p ~/kalibr_workspace/src
cd ~/kalibr_workspace
source /opt/ros/melodic/setup.bash
catkin init
catkin config --extend /opt/ros/melodic
catkin config --merge-devel # Necessary for catkin_tools >= 0.4.
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
4. Clone the Kalibr project
cd ~/kalibr_workspace/src
git clone https://github.com/ethz-asl/Kalibr.git
5. Modify the file and
open the src/Kalibr/aslam_cv/aslam_imgproc/include/aslam/implementation/aslamcv_helper.hpp file
and change all "CvSize" to "cv::Size", a total of 3 places.
6. Compilation and debugging:
Use the following command to compile:
cd ~/kalibr_workspace
catkin build -DCMAKE_BUILD_TYPE=Release -j4
7. After successful compilation, restore the workspace
source ~/kalibr_workspace/devel/setup.bash
If the installation of the first version does not solve the problem, please see the second version.
(2), second edition
1. Install dependencies
sudo apt-get install python-setuptools python-rosinstall ipython libeigen3-dev libboost-all-dev doxygen libopencv-dev ros-melodic-vision-opencv ros-melodic-image-transport-plugins ros-melodic-cmake-modules python-software-properties software-properties-common libpoco-dev python-matplotlib python-scipy python-git python-pip ipython libtbb-dev libblas-dev liblapack-dev python-catkin-tools libv4l-dev
2. Install python-igraph
sudo pip install python-igraph --upgrade
本步骤如果不成功,则可以直接安装:
sudo apt-get install python-igraph
3. Set up the workspace
mkdir -p ~/kalibr_workspace/src
cd ~/kalibr_workspace
source /opt/ros/melodic/setup.bash
catkin init
catkin config --extend /opt/ros/melodic
catkin config --merge-devel # Necessary for catkin_tools >= 0.4.
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
4. Clone the Kalibr project
cd ~/kalibr_workspace/src
git clone https://github.com/ethz-asl/Kalibr.git
5. Replace the Opencv and Catkin files used by Kalibr
(1) Go to the Kalibr folder and delete the opencv2_catkin and catkin_simple folders
cd ~/kalibr_workspace/src/Kalibr
rm -r opencv2_catkin
rm -r catkin_simple
(2) Re-download the opencv2_catkin and catkini_simple files
opencv2_catkin下载地址:https://github.com/ethz-asl/opencv2_catkin
catkini_simple下载地址:https://github.com/catkin/catkin_simple
You can clone it directly to the Kalibr folder (in short, put the two folders opencv2_catkin and catkin_simple into the Kalibr folder)
6. Compilation and troubleshooting
Use the following commands to compile:
cd ~/kalibr_workspace
catkin build -DCMAKE_BUILD_TYPE=Release -j4
Error 1:
CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:89 (math):
math cannot parse the expression: "*100 + ": syntax error, unexpected
exp_TIMES, expecting exp_PLUS or exp_MINUS or exp_OPENPARENT or exp_NUMBER (1)
Liberation solution:
original OpenCVDetectCXXCompiler.cmake There is an error in the file. The path where the file is located:
kalibr_workspace\build\opencv2_catkin\opencv2_src-prefix\src\opencv2_src\cmake
Replace with the file of the same name. Download address: https://pan.baidu.com/s/1Fss8hFIymkkAlS-kAtomZA
Error 2:
modules/contrib/src/chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
if (&annotate_img!=NULL) {
^
modules/contrib/src/chamfermatching.cpp:1016:34: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
if (&annotate_img!=NULL) {
解决方案:
打开文件:kalibr_workspace/build/opencv2_catkin/opencv2_src-prefix/src/opencv2_src/modules/contrib/CMakeFiles/opencv_contrib.dir/flags.make
(kalibr_workspace/build/opencv2_catkin/opencv2_src-prefix/src/opencv2_src/modules/contrib/CMakeFiles/opencv_contrib.dir/src/flags.make)
删除 -Werror=address,保存
Error 3:
error: 'CODEC_ID_H264' was not declared in this scope
'CODEC_FLAG_GLOBAL_HEADER' was not declared in this scope
Solution:
Open the file: kalibr_workspace/src/Kalibr/opencv2_catkin/CMakeLists.txt
Add -D WITH_FFMPEG=OFF, save
最后,再使用catkin build -DCMAKE_BUILD_TYPE=Release -j4 编译
7. After successful compilation, restore the workspace
source ~/kalibr_workspace/devel/setup.bash
Little secret:
When cloning open source files on github.com, adding cnpmjs.org will greatly speed up the process, such as:
git clone https://github.com.cnpmjs.org/ethz-asl/Kalibr.git