安装

ros 安装

设置 sources.list:

1
sudo sh -c 'echo "deb <http://packages.ros.org/ros/ubuntu> $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

设置 keys:

1
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

安装:

1
2
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full

设置环境:

1
2
3
4
5
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
or
echo "source /opt/ros/kinetic/setup.zsh" >> ~/.zshrc
source ~/.zshrc

安装依赖:

1
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

初始化 rosdep:

1
2
3
sudo apt install python-rosdep
sudo rosdep init
rosdep update

编译安装 calibr

安装依赖:

1
2
3
sudo apt-get install python-setuptools python-rosinstall ipython libeigen3-dev libboost-all-dev doxygen libopencv-dev ros-indigo-vision-opencv ros-indigo-image-transport-plugins ros-indigo-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

sudo pip install python-igraph --upgrade

创建 catkin 工作空间:

1
2
3
4
5
6
7
mkdir -p ~/kalibr_workspace/src
cd ~/kalibr_workspace
source /opt/ros/kinect/setup.bash
catkin init
catkin config --extend /opt/ros/kinect
catkin config --merge-devel # Necessary for catkin_tools >= 0.4.
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release

clone 源码:

1
2
cd ~/kalibr_workspace/src
git clone <https://github.com/ethz-asl/Kalibr.git>

编译:

1
2
cd ~/kalibr_workspace
catkin build -DCMAKE_BUILD_TYPE=Release -j4

设置环境:

1
source ~/kalibr_workspace/devel/setup.bash

校准

多相机校准

准备数据集:在 dataset-dir 目录下创建 cam0、cam1... 目录,将每个摄像头的数据分别放到对应的目录下,执行如下命令:

1
kalibr_bagcreater --folder dataset-dir/ --output-bag output.bag

执行校准命令:

1
kalibr_calibrate_cameras --target april_6x6.yaml --bag output.bag --models pinhole-equi pinhole-equi --topics /cam0/image_raw /cam1/image_raw

相机-IMU 校准

准备数据集:在 dataset-dir 目录下创建 cam0、cam1... 目录,将每个摄像头的数据分别放到对应的目录下,准备 imu 数据以 csv 文件格式放入 dataset-dir 目录下以 imu0.csv 为文件名,执行如下命令:

1
kalibr_bagcreater --folder dataset-dir/ --output-bag output.bag

执行校准命令:

1
kalibr_calibrate_imu_camera --target april_6x6.yaml --cam camchain.yaml --imu imu_adis16448.yaml --bag output.bag --bag-from-to 5 45

https://github.com/ethz-asl/kalibr/wiki

💡
1、csv 文件里不能有空格,时间参数以 ns 为单位共 19 位数
2、相机录像不要有镜像,否则会检测不到角点

出错

💡 提示:“Spline Coefficient Buffer Exceeded. Set larger buffer margins ” 在标定命令最后添加 --timeoffset-padding 0.1