本文包括内容:
首先,安装OpenCV所要求的依赖包:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
然后在进行编译及安装:
cd ~/opencv
mkdir bulid
cd build
cmake ..
make -j7
sudo make install
ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
sudo dpkg -i cuda-repo-__.deb
sudo apt-get update
sudo apt-get install cuda
参考官方文档:https://www.stereolabs.com/docs/getting-started/installation/
chmod +x ZED_SDK_Linux_*.run
./ZED_SDK_Linux_*.run
参考官方文档: http://wiki.ros.org/melodic/Installation/Ubuntu
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt update
sudo apt install ros-melodic-desktop-full
此处采用桌面完整安装,其他配置参考官方文档。
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
cd ~/catkin_ws/src
git clone https://github.com/stereolabs/zed-ros-wrapper
cd ~/catkin_ws
catkin_make zed-ros-wrapper
source ./devel/setup.bash
cd ~/catkin_ws/src
git clone https://github.com/raulmur/ORB_SLAM2 ORB_SLAM2
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/username/catkin_ws/src/ORB_SLAM2/Examples/ROS
添加路径后通过该命令查看是否添加成功:
echo $ROS_PACKAGE_PATH
第三步:安装相关依赖项
1)安装Boost
2)安装g2o
3)安装Eigen3
4)安装Pangolin
第四步:编译
cd ~/catkin_ws/src/ORB_SLAM2
chmod +x bulid.sh
./build.sh
chmod +x build_ros.sh
./build_ros.sh
仿照/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src目录下的ros_stereo.cc建立一个新文件,如zed_stereo_rect.cc。将代码复制过去,修改以下部分:
message_filters::Subscriber left_sub(nh, "/zed/left/image_rect_color", 1); message_filters::Subscriber right_sub(nh, "/zed/right/image_rect_color",1);
此处选取了ZED的两个数据流。
然后修改CmakeLists.txt,仿照加入:
# Node for ZED camera
rosbuild_add_executable(zed_Stereo_rect
src/zed_stereo_rect.cc
)
target_link_libraries(zed_Stereo_rect
${LIBS}
)
然后在ORB_SLAM2的根目录下重新编译:
./build_ros.sh
会新生成一个可执行文件 zed_Stereo_rect
然后
cd ~/catkin_ws
source ./devel/setup.bash
roscore
//另开一个命令行
cd ~/catkin_ws
source ./devel/setup.bash //不知道为什么不执行这一步就无法找到zed.launch
roslaunch zed_wrapper zed.launch
//另开一个命令行
cd ~/catkin_ws/src/ORB_SLAM2
rosrun ORB_SLAM2 zed_Stereo_rect Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml false