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://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
apt-cache search ros-kinetic
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
创建一个ROS Workspace :
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/
catkin_make
安装realsense
参考:
https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
https://blog.csdn.net/qq_41839222/article/details/86503113
https://blog.csdn.net/jiangchuanhu/article/details/92795791
sudo apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo xenial main" -u
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
sudo apt-get install librealsense2-dev
sudo apt-get install librealsense2-dbg
安装stereo_image_pro(非必要可选)
参考:
http://wiki.ros.org/stereo_image_proc
安装:
sudo apt-get install ros-kinetic-stereo-image-proc
1.安装好要用到的工具
sudo apt-get install cmake
sudo apt-get install git
2.安装Eigen
sudo apt-get install libeigen3-dev(版本问题可能存在大坑)
3.安装Pangolin
依赖:
sudo apt-get install cmake
sudo apt-get install libpython2.7-dev
安装:
git clone https://github.com/stevenlovegrove/Pangolin.gitcd Pangolinmkdir build
cd build
cmake ..
make –j4
sudo make install
4.安装ORBSLAM2
git clone https://github.com/raulmur/ORB_SLAM2.git
cd ORB_SLAM2
分别删除以下文件中的“-march=native”
ORB_SLAM2/Thirdparty/g2o/CMakeLists.txt 第57、58行
ORB_SLAM2/CMakeLists.txt 第10、11行
ORB_SLAM2/Thirdparty/DBoW2/CMakeLists.txt 第4、5行
chmod +x build.sh
./build.sh
cd
sudo vim ./.bashrc
在最后一行添加如下:
export ORB_SLAM2_ROOT_DIR=/home/luo/source/ORB_SLAM2 (非常重要)
跑一下ORB_SLAM2验证安装是否成功,如:(跑数据集)
ORB_SLAM根目录下运行:
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /home/luo/rgbd_dataset_freiburg1_desk
参考:
https://github.com/introlab/rtabmap/wiki/Installation
1.安装依赖
sudo apt-get update
sudo apt-get install libsqlite3-dev libpcl-dev libopencv-dev git cmake libproj-dev libqt5svg5-dev
2.安装
参考:https://github.com/introlab/rtabmap/wiki/Installation
git clone https://github.com/introlab/rtabmap.git rtabmap
打开:rtabmap/corelib/include/rtabmap/core/StereoCameraModel.h第104行(修改双目基线)
将 double baseline() const {return right_.fx()!=0.0 && left_.fx() != 0.0 ? left_.Tx() / left_.fx() - right_.Tx()/right_.fx():0.0;}
改为 double baseline() const {return 0.05;} //right_.fx()!=0.0 && left_.fx() != 0.0 ? left_.Tx() / left_.fx() - right_.Tx()/right_.fx():0.0;}
cd rtabmap/build
cmake -DWITH_G2O=OFF -DCMAKE_INSTALL_PREFIX=/home/luo/catkin_ws/devel .. (非常重要 如果把GTSAM库也OFF可能会没有回环)
make -j4
sudo make install
sudo ldconfig
测试源码安装是否成功:插上D435i
参考:https://github.com/introlab/rtabmap/wiki/Kinect-mapping
cd ../bin
./rtabmap
步骤:
->OK
->OK
->New database
->Select source ->RGB-D camera ->Realsense D435 ->Realsense 2
->start
界面能显示建图效果,则源码安装成功
若运行start以后界面闪退(天坑),则安装失败 具体情况根据error而定
(若编译的时候报大量Eigen的警告,可能是Eigen的原因,跟换Eigen版本)
编译rtabmap_ros(修改双目基线)
cd ~/catkin_ws
git clone https://github.com/IntelRealSense/realsense-ros
vim realsense-ros/realsense2_camera/src/base_realsense_node.cpp
将第1646行 _camera_info[stream_index].P.at(3) = 0;
更改为:
if(stream_index.second == 2)
{
_camera_info[stream_index].P.at(3) = -0.05;
}
git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
catkin_make
3.运行rtabmap
3.1 rtabmap+orb_slam2(双目)+realsense2
//启动realsense
1. roslaunch realsense2_camera rs_camera.launch
//双目矫正(可选)
2. ROS_NAMESPACE=camera rosrun stereo_image_proc stereo_image_proc left/image_raw:=/camera/infra1/image_rect_raw right/image_raw:=/camera/infra2/image_rect_raw left/camera_info:=/camera/infra1/camera_info right/camera_info:=/camera/infra2/camera_info _approximate_sync:=true
//启动rtabmap
3. roslaunch rtabmap_ros stereo_mapping.launch stereo_namespace:="/camera" rtabmap_args:="--delete_db_on_start --Odom/Strategy 5 --OdomORBSLAM2/VocPath "/home/luo/source/ORB_SLAM2/Vocabulary/ORBvoc.txt"" left_image_topic:=/camera/left/image_rect right_image_topic:=/camera/right/image_rect left_camera_info_topic:=/camera/infra1/camera_info right_camera_info_topic:=/camera/infra2/camera_info /rtabmap/odom_info:=/camera/infra1/camera_info stereo:=true frame_id:=camera_link approx_sync:=false
3.2 rtabmap+orb_slam2(RGB-D)+realsense2
//启动realsense
1. roslaunch realsense2_camera rs_rgbd.launch
//启动rtabmap
2. roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start --Odom/Strategy 5 --OdomORBSLAM2/VocPath "/home/luo/source/ORB_SLAM2/Vocabulary/ORBvoc.txt"" depth_topic:=/camera/depth/image_rect_raw rgb_topic:=/camera/color/image_raw camera_info_topic:=/camera/color/camera_info approx_sync:=false
3.3 rtabmap+F2M(RGB-D)+realsense2
//启动相机
1. roslaunch realsense2_camera rs_rgbd.launch
//启动realsense
2. roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" depth_topic:=/camera/depth/image_rect_raw rgb_topic:=/camera/color/image_raw camera_info_topic:=/camera/color/camera_info approx_sync:=false