参考:Ubuntu下ZED2 SDK使用及开发环境配置\
cuda 10.2下载
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
修改一下./bashrc文件
sudo gedit ./bashrc
在最后添加
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64
更新
source ./bashrc
SDK
请安装的时候注意一下SDK和cuda的版本对应问题,以及如果SDK版本是旧的,而ros wrapper是新的,可能在ros wrapper编译的时候会报错。
cd ~/下载
chmod +x ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run
./ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run
报错1:缺少某些依赖未安装
解决方法:直接安装依赖就可以
报错2:Python API 安装失败
解决方法:确认自己的python默认版本是不是python3
确认版本
update-alternatives --list python
如果报错:update-alternatives: error: no alternatives for python
则更新一下,我是ubuntu18.04的系统,python3.6 自己注意一下自己的python版本
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
列出python版本
update-alternatives --list python
修改python默认版本
sudo update-alternatives --config python
sudo wget -qO- https://cdn.jsdelivr.net/gh/OAKChina/depthai-docs-website@develop/source/_static/install_dependencies.sh | bash
然后在安装SDK。
测试运行zed2.
cd /usr/local/zed/tools
./ZED_Depth_Viewer
这里我没有报错,但是打开的界面是黑的,相机没有任何显示,用zed自带的程序检测,只说检测不到我的处理器。折腾了一会儿没解决该问题,但是在ROS下还是打开了zed2相机。也就是以下方法:
cd ~/catkin_ws/src
git clone https://github.com/stereolabs/zed-ros-examples.git
cd ../
rosdep install --from-paths src --ignore-src -r -y
catkin_make -DCMAKE_BUILD_TYPE=Release
source ./devel/setup.bash
运行
roslaunch zed_display_rviz display_zed.launch
现在就能在rviz下看到结果了。
cd ~/zed_calibra_ws/src
git clone https://github.com/stereolabs/zed-ros-wrapper.git
cd ..
rosdep install --from-paths src --ignore-src -r -y
catkin_make -DCMAKE_BUILD_TYPE=Release
source ./devel/setup.bash
运行zed2
roslaunch zed_wrapper zed2.launch
报错
[ INFO] [1619503452.320965252]: Initializing nodelet with 4 worker threads.
[ERROR] [1619503452.339945481]: Failed to load nodelet [/zed2/zed_node] of type [zed_nodelets/ZEDWrapperNodelet] even after refreshing the cache: Failed to load library /home/willingham/zed_calibra_ws/devel/lib//libZEDNodelets.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = libturbojpeg.so.0: cannot open shared object file: No such file or directory)
[ERROR] [1619503452.339982271]: The error before refreshing the cache was: Failed to load library /home/willingham/zed_calibra_ws/devel/lib//libZEDNodelets.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = libturbojpeg.so.0: cannot open shared object file: No such file or directory)
解决方法:查了半天,没解决,重新安装的时候发现是SDK那里的warning我忽略了,就离谱。重新安装了python api,成功安装SDK,也成功运行了zed2。
安装kalibr
安装依赖
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 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
其中有三个是需要注意版本,我是修改后的melodic,还有一个是python-software-properties,说是18.04已经不用了
这一步也不是太恶心,就是缺少依赖,我一个没注意想降级软件包,结果好像是删除了588个包,包括ROS melodic等等。直接炸裂。
sudo pip install python-igraph --upgrade
报错的话一般就是因为python版本问题,自己切换一下。
这里安装失败会影响后面计算相机参数,我的python3.6一直安装不上,2.7是这样安装的:
sudo add-apt-repository ppa:igraph/ppa
sudo apt-get update #虽然这步更新的时候显示错误但是下面还是安装成功了,具体原因我也不清楚,但是总算安上了
sudo apt-get install python-igraph
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
cd src
git clone https://github.com/ethz-asl/Kalibr.git
编译
cd ..
catkin build -DCMAKE_BUILD_TYPE=Release -j4
编译报错:suitesparse报错,可以看一下这个issue
source一下
source ~/zed_ws/devel/setup.bash
启动zed2相机
roslaunch zed_wrapper zed2.launch
启动左右摄像头可视化功能,但是有一个问题,网上的所有都是这句代码,我也问了师兄,都没报错,但是我的就显示节点名称重复。所以我改了节点名称
原:
rosrun image_view image_view image:=/zed2/zed_node/left/image_rect_color & rosrun image_view image_view image:=/zed2/zed_node/right/image_rect_color
改:
rosrun image_view image_view __ns:=view1 image:=/zed2/zed_node/left/image_rect_color & rosrun image_view image_view __ns:=view2 image:=/zed2/zed_node/right/image_rect_color
kalibr对录制频率有要求,降低到20Hz
rosrun topic_tools throttle messages /zed2/zed_node/left/image_rect_color 20 /zed2/zed_node/left/image_rect_color2
rosrun topic_tools throttle messages /zed2/zed_node/right/image_rect_color 20 /zed2/zed_node/right/image_rect_color2
录制数据包
rosbag record -O Kalibr_data.bag /zed2/zed_node/imu/data_raw /zed2/zed_node/left/image_rect_color /zed2/zed_node/right/image_rect_color
查看记录的数据
rosbag info Kalibr_data.bag
获取相机参数
kalibr_calibrate_cameras --bag Kalibr_data.bag --topics /zed2/zed_node/left/image_rect_color /zed2/zed_node/right/image_rect_color --models pinhole-radtan pinhole-radtan --target april_6x6_50x50cm.yaml
上面的april_6x6_50x50cm.yaml中我的参数是
target_type: 'aprilgrid' #gridtype
tagCols: 6 #number of apriltags
tagRows: 6 #number of apriltags
tagSize: 0.035 #size of apriltag, edge to edge [m]
tagSpacing: 0.285714 #ratio of space between tags to tagSize