Use Docker to configure the operating environment of SVO SLAM1 and SVO SLAM2

1. Acquisition of ROS docker

sudo docker pull osrf/ros:noetic-desktop-full

2. Enter docker

2.1 Enable docker to use the graphical interface of the host machine (see docker usage for details )

xhost +

2.2 run 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. Installation dependencies

3.0 boost and 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_wiki

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. Compile rpg_svo

4.1, non-ROS compilation

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 compilation

4.2.1 Create ros space

 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 Download package

Copy the dependency package of the third step to robot_work/src

4.2.3 Compile

git clone https://github.com/uzh-rpg/rpg_svo.git 到 robot_work/src/
在robot_work目录下执行
catkin_make

5. If you encounter problems, you can refer to

5.1

/share/DockerFile/Sophus/sophus/so2.cpp:32:26: error: lvalue required as left operand of assignment
   32 |   unit_complex_.real() = 1.;

solve

修改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

solve

CV_RANSAC ==》cv::RANSAC

5.3

error: ‘CV_INTER_LINEAR’ was not declared in this scope

solve

CV_INTER_LINEAR  修改为 cv::INTER_LINEAR

或者,添加头文件 
#include<opencv2/imgproc/imgproc_c.h>

5.4

 error: ‘CV_GRAY2RGB’ was not declared in this scope

solve

加入
#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: "

solve

修改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'

solve

FIND_PACKAGE(Sophus REQUIRED)

${Sophus_INCLUDE_DIRS}

${Sophus_LIBRARIES}

6. Run

6.1 Non-ROS operation

export SVO_DATASET_DIR=/share/DockerFile/Datasets/

Download data set extraction code: d92d

把数据集解压到 Datasets
cd svo/bin

./test_pipeline 

6.2 Running under ROS

6.2.1 Use other terminals to enter docker commands

查看容器id(xxxx)
sudo docker ps -a 
使用命令进入docker
sudo docker exec -it xxxx(ID)  /bin/bash

6.2.2 Start roscore

Terminal 1:roscore

Terminal 2: .launch file to start SVOroslaunch svo_ros test_rig3.launch

Terminal 3: Create a new window to start rviz rosrun rviz rviz -d <PATH TO rpg_svo>/svo_ros/rviz_config.rviz
Terminal 4: Broadcast data extraction code: cpd3 rosbag play airground_rig_s3_2013-03-18_21-38-48.bag

7. Compile rpg_svo_pro_open

7.0 dependencies

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 Create ros space

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 [email protected]: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 Compile

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 [email protected]: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")

Put a practical video on station B

Use docker to run the old and new versions of SVO SLAM and run successfully

Guess you like

Origin blog.csdn.net/u011573853/article/details/128994663