1、ROS docker的获取
sudo docker pull osrf/ros:noetic-desktop-full
2、进入docker
2.1 使docker可以使用宿主机的图形界面(具体可以查看docker使用)
xhost +
2.2 运行docker
sudo docker run -ti -h ubuntu --hostname ubuntu -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/xxx/:/share --gpus all osrf/ros:noetic-desktop-full /bin/bash
3、安装依赖
3.0 boost与eigen
sudo apt-get install libboost-all-dev
apt-get install libeigen3-dev
opencv相关的
3.1 Sophus
git clone https://github.com/strasdat/Sophus.git
cd Sophus
git checkout a621ff
mkdir build
cd build
cmake ..
make -j4
make install
3.2、fast
git clone https://github.com/uzh-rpg/fast.git
cd fast
mkdir build
cd build
cmake ..
make -j4
make install
3.3、g2o
wget https://github.com/RainerKuemmerle/g2o/archive/20160424_git.tar.gz -O g2o-20160424_git.tar.gz
tar xvzf g2o-20160424_git.tar.gz
cd g2o-20160424_git
mkdir build
cd build
cmake ..
make -j4
sudo make install
3.4、rpg_vikit
git clone https://github.com/uzh-rpg/rpg_vikit.git
非ROS编译
cd rpg_vikit/vikit_common
修改CMakeLists.txt中
SET(USE_ROS TRUE) # Set False if you want to build this package without Catkin
变FALSE
mkdir build
cd build
cmake ..
make -j4
make install
4、编译rpg_svo
4.1 、非ROS编译
git clone https://github.com/uzh-rpg/rpg_svo.git
cd rpg_svo/svo/
修改CMakeLists.txt中
SET(USE_ROS TRUE) # Set FALSE if you want to build this package without Catkin
变FALSE
mkdir build
cd build
cmake ..
make -j4
4.2、ROS编译
4.2.1创建ros空间
mkdir -p robot_work/src
cd robot_work/src
catkin_init_workspace
cd .. && catkin_make
echo "source /share/DockerFile/robot_work/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
4.2.2 下载包
把第三步的依赖包复制到robot_work/src
4.2.3编译
git clone https://github.com/uzh-rpg/rpg_svo.git 到 robot_work/src/
在robot_work目录下执行
catkin_make
5、遇到问题 可参考
5.1
/share/DockerFile/Sophus/sophus/so2.cpp:32:26: error: lvalue required as left operand of assignment
32 | unit_complex_.real() = 1.;
解决
修改Sophus/sophus/so2.cpp
把
SO2::SO2()
{
unit_complex_.real() = 1.;
unit_complex_.imag() = 0.;
}
变成
SO2::SO2()
{
unit_complex_.real(1.);
unit_complex_.imag(0.);
}
5.2
error: ‘CV_RANSAC’ was not declared in this scope
解决
CV_RANSAC ==》cv::RANSAC
5.3
error: ‘CV_INTER_LINEAR’ was not declared in this scope
解决
CV_INTER_LINEAR 修改为 cv::INTER_LINEAR
或者,添加头文件
#include<opencv2/imgproc/imgproc_c.h>
5.4
error: ‘CV_GRAY2RGB’ was not declared in this scope
解决
加入
#include <opencv2/imgproc/types_c.h>
5.5
出现 "Invalid argument "/world" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like: "
解决
修改rpg_vikit 中vikit_ros/src/output_helper.cpp 中的frame_id 去掉斜杠
5.6
undefined reference to `Sophus::SE3::operator*(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) const'
解决
FIND_PACKAGE(Sophus REQUIRED)
${Sophus_INCLUDE_DIRS}
${Sophus_LIBRARIES}
6、运行
6.1 非ROS运行
export SVO_DATASET_DIR=/share/DockerFile/Datasets/
下载数据集 提取码: d92d
把数据集解压到 Datasets
cd svo/bin
./test_pipeline
6.2 ROS下运行
6.2.1 使用其他终端进入docker命令
查看容器id(xxxx)
sudo docker ps -a
使用命令进入docker
sudo docker exec -it xxxx(ID) /bin/bash
6.2.2 启动roscore
终端1: roscore
终端2: .launch文件启动SVO roslaunch svo_ros test_rig3.launch
终端3: 新建一个窗口启动rviz rosrun rviz rviz -d <PATH TO rpg_svo>/svo_ros/rviz_config.rviz
终端4:播数据提取码: cpd3 rosbag play airground_rig_s3_2013-03-18_21-38-48.bag
7、编译rpg_svo_pro_open
7.0 依赖
sudo apt-get install python3-catkin-tools python3-vcstool python3-osrf-pycommon
# system dep.
sudo apt-get install libglew-dev libopencv-dev libyaml-cpp-dev
# Ceres dep.
sudo apt-get install libblas-dev liblapack-dev libsuitesparse-dev
7.1创建ros空间
ROS-DISTRO=melodic/noetic
mkdir svo_ws && cd svo_ws
catkin config --init --mkdirs --extend /opt/ros/<ROS-DISTRO> --cmake-args -DCMAKE_BUILD_TYPE=Release -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3
cd src
//此部分可能会出现git权限问题,解决方法是在本机生成ssh密钥并把公钥上传到自己的git中就应该ok
git clone git@github.com:uzh-rpg/rpg_svo_pro_open.git
vcs-import < ./rpg_svo_pro_open/dependencies.yaml
touch minkindr/minkindr_python/CATKIN_IGNORE
cd rpg_svo_pro_open/svo_online_loopclosing/vocabularies && ./download_voc.sh
cd ../../..
7.2 编译
7.2.1 front-end + sliding window back-end + loop closure/pose graph
catkin build
7.2.2 Build with the global map using iSAM2 (all functionalities)
rm rpg_svo_pro_open/svo_global_map/CATKIN_IGNORE
修改 svo_cmake/cmake/Modules/SvoSetup.cmake
SET(USE_GLOBAL_MAP TRUE)
git clone --branch 4.0.3 git@github.com:borglab/gtsam.git
修改
# 1. 修改gtsam/CMakelists.txt: 使用 system Eigen
-option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" OFF)
+option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" ON)
# 2. 修改gtsam/cmake/GtsamBuildTypes
把 list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC "-march=native")
改为
list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC "-mno-avx")
在B站上放了一个实操视频
使用docker运行SVO SLAM的老版本与新版本并成功运行
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)