SLAM调试安装笔记

1.indemind双目惯导相机启动方式:
cd  #为SDK具体路径
sudo su
source ros/devel/setup.bash
roslaunch imsee_ros_wrapper start.launch

获取相机参数
./demo/output/bin/get_device_info 

查看某个topic的发布频率
rostopic hz /imsee/imu

查看当前ros环境下发布的所有话题
rostopic list

查看节点和话题之间的连接关系
rqt_graph

2.orbslam2双目相机运行命令
rosrun ORB_SLAM2 Stereo /home/cqq/catkin_ws/src/ORB_SLAM2-fix_compile_g2o/Vocabulary/ORBvoc.txt /home/cqq/catkin_ws/src/ORB_SLAM2-fix_compile_g2o/Examples/Stereo/indemind.yaml false


3.orbslam3

(1)双目运行命令
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml /home/cqq/Downloads/MH_05 ./Examples/Stereo/EuRoC_TimeStamps/MH05.txt dataset-MH05_stereo

(2)双目惯导运行命令
./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml /home/cqq/Downloads/MH_05 ./Examples/Stereo-Inertial/EuRoC_TimeStamps/MH05.txt dataset-MH05_stereo
运行该命令行时报错:
double free or corruption (out)
Aborted (core dumped)
尝试解决该问题,
(1)用gdb调试打印报错信息;
(2)卸载掉opencv3.4.7和opencv3.4.3,重新编译安装opencv3.2.0
《关于跟随ROS一同安装的OpenCV的卸载与重新安装》
https://blog.csdn.net/qq_45867004/article/details/119515595
重装opencv后问题解决

播放ros包
rosbag play --pause MH_04_difficult.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu
同时碰到另外一个问题,
播放ros包时只发布了左边相机的图像,右边相机的图像并没有发布出来。
下载播放新的rosbag包V1_02_medium,问题得到解决。
rosbag play --pause V1_02_medium.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu

单目+IMU
roscore
rosbag play MH_04_difficult.bag /cam0/image_raw:=/camera/image_raw /imu0:=/imu
rosrun ORB_SLAM3 Mono_Inertial Vocabulary/ORBvoc.txt Examples/Monocular-Inertial/EuRoC.yaml true
双目+IMU
roscore
rosbag play --pause V1_02_medium.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu
rosrun ORB_SLAM3 Stereo_Inertial Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/EuRoC.yaml true
双目
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/realsense.yaml true

双目+IMU  realsens d435i
roslaunch realsense2_camera rs_camera_vins.launch
rosrun ORB_SLAM3 Stereo_Inertial Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/realsense.yaml false

10.13
opencv重装成3.2.0之后碰到新的问题,indemind双目惯导相机依赖opencv3.4.3,重装后indemind相机无法运行。
尝试安装两个版本的opencv,
《Ubuntu下多版本OpenCV共存和切换》
https://blog.csdn.net/learning_tortosie/article/details/80594399

修改IMSEE-SDK/demo/CMakeLists.txt文件第49行:
if(OS_UBUNTU)
  #set(MNN_LIB_DIR ${PRO_DIR}/src/detector/lib/x86-64)
  set(INDEMIND_LIB_DIR ${PRO_DIR}/lib/others/x64-opencv3.4.3)

修改indemind SDK路径下cmake文件夹下面的DetectOpenCV.cmake,修改里面opencv的路径,指向opencv3.4.3的安装路径,
make demo 和make ros 都编译成功,但是实际无法运行;
root@cqq:/home/cqq/Downloads/IMSEE-SDK# ./demo/output/bin/get_device_info 
./demo/output/bin/get_device_info: error while loading shared libraries: libopencv_calib3d.so.3.4: cannot open shared object file: No such file or directory

[ERROR] [1634114594.798897499]: Failed to load nodelet [/imsee/imsee_wrapper_node] of type [imsee/ROSWrapperNodelet] even after refreshing the cache: Failed to load library /home/cqq/Downloads/IMSEE-SDK/ros/devel/lib//libimsee_wrapper.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 = libopencv_calib3d3.so.3.3: cannot open shared object file: No such file or directory)
[ERROR] [1634114594.798947019]: The error before refreshing the cache was: Failed to load library /home/cqq/Downloads/IMSEE-SDK/ros/devel/lib//libimsee_wrapper.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 = libopencv_calib3d3.so.3.3: cannot open shared object file: No such file or directory)

realsense相关操作
尝试用realsense D435i运行orbslam3,首先需要标定好realsense D435i的双目相机和IMU
1.打开realsense可视化界面
realsense-viewer

2.启动RealSense的ROS节点
roslaunch realsense2_camera rs_camera.launch
roslaunch realsense2_camera rs_camera_vins.launch

3.参考博客设置realsense D435i
《Intel RealSense D435i:简介、安装与使用(ROS、Python)》
https://zhaoxuhui.top/blog/2020/09/09/intel-realsense-d435i-installation-and-use.html

 
 
 
 


4.显示发布的话题 rostopic list 

5.打印相应的话题信息 rostopic echo /camera/imu

6.录制rosbag包 rosbag record /camera/infra1/image_rect_raw /camera/infra2/image_rect_raw /camera/imu
录制指定话题,设置 bag 包名:rosbag record -O bag_name.bag /topic1_name /topic2_name /xxx
播放rosbag包 rosbag play --pause 1.bag
查看ros包的信息 rosbag info 1.bag

7.关闭红外开关
rosrun rqt_reconfigure rqt_reconfigure

8.修改相机配置参数yaml文件
左边红外相机参数
height: 480
width: 640
distortion_model: "plumb_bob"
D: [0.0, 0.0, 0.0, 0.0, 0.0]
K: [383.5014343261719, 0.0, 321.266357421875, 0.0, 383.5014343261719, 237.60040283203125, 0.0, 0.0, 1.0]
R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P: [383.5014343261719, 0.0, 321.266357421875, 0.0, 0.0, 383.5014343261719, 237.60040283203125, 0.0, 0.0, 0.0, 1.0, 0.0]

右边红外相机参数
height: 480
width: 640
distortion_model: "plumb_bob"
D: [0.0, 0.0, 0.0, 0.0, 0.0]
K: [383.5014343261719, 0.0, 321.266357421875, 0.0, 383.5014343261719, 237.60040283203125, 0.0, 0.0, 1.0]
R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P: [383.5014343261719, 0.0, 321.266357421875, -19.12970542907715, 0.0, 383.5014343261719, 237.60040283203125, 0.0, 0.0, 0.0, 1.0, 0.0]

10.14双目红外相机和IMU联合校准
1.修改topic的频率,按照官方推荐修改IMU为200Hz,图像为20Hz
rosrun topic_tools throttle messages /camera/infra1/image_rect_raw 20.0 /camera/left 
rosrun topic_tools throttle messages /camera/infra2/image_rect_raw 20.0 /camera/right 

2.录制ros包
rosbag record /camera/left /camera/right /camera/imu
rosbag record /camera/infra1/image_rect_raw /camera/infra2/image_rect_raw /camera/imu

3.查看ros包的信息
rosbag info 1.bag

4.安装编译Kalibr
catkin build -DCMAKE_BUILD_TYPE=Release
参考博客
带你实现IMU和双目相机的联合标定
https://mp.weixin.qq.com/s/578zLmelTqxrPggOakxkVw
带你解读Kalibr和VINS标定参数
https://mp.weixin.qq.com/s/Hqi6iUS-VGIQTmAB0Xa_nQ
Kalibr相机校正工具安装与使用笔记
http://zhaoxuhui.top/blog/2020/09/09/kalibr-installation-and-use.html
利用Kalibr对Intel RealSense D435i进行相机及相机-IMU联合标定
http://zhaoxuhui.top/blog/2020/09/29/intel-realsense-D435i-calibration-kalibr.html

10.15 
1.修改红外图像的发布频率为15Hz,IMU频率保持为200Hz,可以实现realsense在线测试
2.修改ORB-SLAM3 ROS包源文件ros_stereo_inertial.cc,在148行下面添加如下代码,可以在结束时保存轨迹文件
  // Stop all threads
  SLAM.Shutdown();
  // Save camera trajectory
  SLAM.SaveKeyFrameTrajectoryTUM("ORB-SLAM3-KeyFrameTrajectory-SI.txt");
  // Save camera trajectory
  SLAM.SaveTrajectoryTUM("ORB-SLAM3-FrameTrajectory-SI.txt");
3.安装SLAM轨迹精度评价工具evo
参考博客《SLAM轨迹精度评价工具evo简介与使用》
http://zhaoxuhui.top/blog/2021/03/27/evo-slam-trajectory-evaluation.html
显示轨迹:
evo_traj tum ORB-SLAM3-KeyFrameTrajectory-SI.txt -p --plot_mode=xy
evo_traj tum ORB-SLAM3-FrameTrajectory-SI.txt -p --plot_mode=xyz


运行VINS-Fusion
roslaunch realsense2_camera rs_camera_vins-fusion.launch 
roslaunch vins vins_rviz.launch 
rosrun vins vins_node /home/cqq/catkin_ws/src/VINS-Fusion/config/realsense_d435i/realsense_stereo_imu_config.yaml

rosrun vins vins_node /home/nvidia/catkin_ws/src/VINS-Fusion-gpu/config/realsense_d435i/realsense_stereo_imu_config.yaml

使用evo工具评估vins-fusion轨迹精度
参考博客
《vins-mono保存、重载地图、evo工具测试》
https://blog.csdn.net/Hanghang_/article/details/104535370


10.16 
标定IMU,参考博客《D435i标定摄像头和IMU笔记三(IMU标定篇)》
https://blog.csdn.net/qq_35616298/article/details/116190164
测试发现该参数无法使用

10.20 校准realsense IMU
https://github.com/engcang/vins-application/blob/Intel-D435i/imu_calibration.png
https://www.intel.com/content/dam/support/us/en/documents/emerging-technologies/intel-realsense-technology/RealSense_Depth_D435i_IMU_Calib.pdf

10.21 安装PL-vins
github上的命令行是错误的,使用以下命令行才能运行:
使用时确定plvins_show_linepoint.launch的名称是否正确
roslaunch plvins_estimator plvins_show_linepoint.launch

------------------------------------------------------------------------------------------------------------------

机械革命Z3 air安装记录:
1.安装sogou输入法

2.安装opencv3.4.3,参考博客
《ubuntu18编译安装opencv3.4.3》
https://blog.csdn.net/weixin_43056275/article/details/106005112

3.安装ROS melodic,参考博客
《Ubuntu18.04 melodic 安装与下载ROS(超详细教程)》
https://www.guyuehome.com/10082
安装过程中运行sudo rosdep init 
sudo: rosdep: command not found 参考教程解决了问题
《ROS 不能再详细的安装教程》
https://blog.csdn.net/virtue333/article/details/52820407

4.安装Pangolin
《Ubuntu18.04 Pangolin 安装》
https://blog.csdn.net/weixin_44354586/article/details/89399289

5.安装eigen3.4.0
《Ubuntu18.04 两种方式安装eigen3》
https://blog.csdn.net/weixin_44354586/article/details/89396357

6.安装vscode
《ubuntu18.04系统下安装vscode教程》
https://blog.csdn.net/weixin_49199646/article/details/108949425

7.安装ORB_SLAM3
运行build.sh时报错
atkin_ws/src/ORB_SLAM3/src/LocalMapping.cc:628:49: error: no match for ‘operator/’ (operand types are ‘cv::Matx’ and ‘float’) x3D = x3D_h.get_minor<3,1>(0,0) / x3D_h(3); ~~~~~~~~~~~~~~~~~~^~

解决方法
找到目标所在的文件,比如我上面的就是localMapping.cc里。
然后来到地628行,把
x3D = x3D_h.get_minor<3,1>(0,0) / x3D_h(3);
换成
x3D = cv::Matx31f(x3D_h.get_minor<3,1>(0,0)(0) / x3D_h(3), x3D_h.get_minor<3,1>(0,0)(1) / x3D_h(3), x3D_h.get_minor<3,1>(0,0)(2) / x3D_h(3));

ORB_SLAM3/src/CameraModels/KannalaBrandt8.cpp:534:

参考博客《ubuntu18.04编译ORB_SLAM3遇到的问题》
https://blog.csdn.net/Mwithz/article/details/117222990

8.安装realsense d435i驱动
参考博客《Ubuntu18.04 + ROS melodic 安装使用 RealSenseD435i》
https://blog.csdn.net/Lynn_mg/article/details/103149489?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3.no_search_link

刚开始运行时报错,执行以下命令后错误解决:
./scripts/setup_udev_rules.sh

9.安装ceres2.0.0
《在linux ubuntu18.04版本中安装ceres solver》
https://blog.csdn.net/YMWM_/article/details/101601345

10.安装PL-VINS
catkin_make后多处报错:
/home/cqq/catkin_ws/src/PL-VINS/feature_tracker/src/linefeature_tracker.h:18:10: fatal error: line_descriptor_custom.hpp: No such file or directory
 #include "line_descriptor_custom.hpp"

11.在NVIDIA NX上安装clash
https://github.com/FanDady/VPN-Collection
https://github.com/Dreamacro/clash/releases
http://www.ptbird.cn/ubuntu-2004-clash-for-linux.html
https://einverne.github.io/post/2021/03/linux-use-clash.html
https://zhuanlan.zhihu.com/p/420381244
《Ubuntu:(设置终端代理IP)简单有效地设置全局代理上网》
https://blog.csdn.net/li575098618/article/details/49818547

设置开机自启动,在命令行输入
gnome-session-properties
会出现一个gui界面,执行chmod a+x a.AppImg,添加权限,然后添加要执行的程序的位置即可。

12.nvidia nx安装opencv3.2.0
参考博客《Xavier NX安装opencv3.4.7~3.4.15》
https://blog.csdn.net/ysten618/article/details/106691236
《ubuntu1804系统(xavier、NX)编译opencv报E:Unable to locate package libjasper-dev等最新解决方法》
https://blog.csdn.net/ysten618/article/details/120082709?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-1.no_search_link&spm=1001.2101.3001.4242.1
《OpenCV3.3+CUDA9.0+Cmake3.9 环境搭建》
https://blog.csdn.net/u014613745/article/details/78310916
《Ubuntu16.04编译opencv3.2.0的lapack错误解决方法》
https://blog.csdn.net/moshiyaofei/article/details/82855169

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320 ..

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320 -D WITH_CUDA=ON -D CUDA_ARCH_BIN="7.2" -D CUDA_ARCH_PTX="" -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D ENABLE_NEON=ON -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D WITH_QT=OFF -D WITH_OPENGL=ON -D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" -D WITH_TBB=ON  ..

sudo chmod 777 cuda_fp16.h

13.更改文件夹所有者和权限
《如何更改linux文件的拥有者及用户组(chown和chgrp)》
https://blog.csdn.net/hudashi/article/details/7797393

14.拉取github报错 gnutls_handshake() failed: The TLS connection was non-properly terminated.
https://zhuanlan.zhihu.com/p/378894743

若需使用代理,http协议和socket协议的配置分别如下,以8080端口为例:
# http
git config --global http.https://github.com.proxy http://127.0.0.1:7890
git config --global https.https://github.com.proxy https://127.0.0.1:7890
# socket
git config --global http.proxy 'socks5://127.0.0.1:7891'
git config --global https.proxy 'socks5://127.0.0.1:7891'

15.使用Nvidia SDK Manager刷机后在Xavier上查看OS、Jetson、CUDA、cudnn、OpenCV和TensorRT版本信息。
https://cloud.tencent.com/developer/article/1828610
系统版本$ uname  -a
Jetson版本$ jetson_release -v
CUDA版本$ nvcc -V
cudnn版本$ cat /usr/include/cudnn.h |grep CUDNN_MAJOR -A 2
OepnCV版本$ pkg-config --modversion opencv
TensorRT版本$ dpkg -l grep TensorRT

16.在NX上安装opencv3.4.1
cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local/opencv341 \
      -D OPENCV_GENERATE_PKGCONFIG=YES \
      -D WITH_CUDA=ON \
      -D CUDA_ARCH_BIN=7.2 \
      -D CUDA_ARCH_PTX="" \
      -D ENABLE_FAST_MATH=ON \
      -D CUDA_FAST_MATH=ON \
      -D WITH_CUBLAS=ON \
      -D WITH_LIBV4L=ON \
      -D WITH_GSTREAMER=ON \
      -D WITH_GSTREAMER_0_10=OFF \
      -D WITH_QT=ON \
      -D WITH_OPENGL=ON \
      -D BUILD_opencv_cudacodec=OFF \
      -D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \
      -D WITH_TBB=ON \
      ../

《Jetson Xavier NX安装opencv3.x以及踩过的坑_gz7seven-程序员宅基地》
https://www.cxyzjd.com/article/guzhao9901/116016755
修改 /usr/local/cuda/include/cuda_gl_interop.h 的62行到68行,修改后如下:

sudo gedit /usr/local/cuda/include/cuda_gl_interop.h
    此部分修改为
//#if defined(__arm__) || defined(__aarch64__)
//#ifndef GL_VERSION
//#error Please include the appropriate gl headers before including cuda_gl_interop.h
//#endif
//#else
 #include
//#endif
    修复libGL.so的符号链接
cd /usr/lib/aarch64-linux-gnu/
sudo ln -sf tegra/libGL.so libGL.so

问题2:
make[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libGL.so', needed by 'lib/libopencv_cudev.so.3.4.1'.  Stop.
参考自己写的博客
《RK3399pro编译安装OpenCV报错*** No rule to make target ‘/usr/lib/aarch64-linux-gnu/libGL.so‘解决办法》
https://blog.csdn.net/CQQ1021114542/article/details/115405798?spm=1001.2101.3001.6650.6&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7Eessearch%7Evector-6.essearch_pc_relevant&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7Eessearch%7Evector-6.essearch_pc_relevant

17.Jetson平台通过jtop指令查看系统内存GPU等情况

18.Ubuntu18 查看CUDA的CUDA_ARCH_BIN
安装好cuda之后,可以从cuda sample中获得:
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

输出信息:
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "Xavier"
  CUDA Driver Version / Runtime Version          10.2 / 10.2
  CUDA Capability Major/Minor version number:    7.2
  Total amount of global memory:                 7763 MBytes (8140558336 bytes)
  ( 6) Multiprocessors, ( 64) CUDA Cores/MP:     384 CUDA Cores
  GPU Max Clock rate:                            1109 MHz (1.11 GHz)
  Memory Clock rate:                             1109 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            Yes
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 0 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.2, CUDA Runtime Version = 10.2, NumDevs = 1
Result = PASS


19.在NX上安装opencv3.4.1,卸载掉opencv3.2.0,删除/usr/lib/aarch64-linux-gnu/文件夹下面和3.2.0相关的so文件,删除catkin_ws文件夹下面的devel和build文件夹,重新使用catkin_make编译,source ./devel/setup.bashrc
执行以下命令:
 rosrun vins vins_node /home/nvidia/catkin_ws/src/VINS-Fusion-gpu/config/realsense_d435i/realsense_stereo_imu_config.yaml
报错信息:
/home/nvidia/catkin_ws/devel/lib/vins/vins_node: error while loading shared libraries: libopencv_imgcodecs.so.3.2: cannot open shared object file: No such file or directory
分析原因:opencv3.2.0删除后,ROS工程依然链接到他上面,所以直接删除原来的catkin_ws文件夹,
利用home/nvidia/Downloads/installROSXavier/setupCatkinWorkspace.sh脚本重新创建catkin_ws工程;
之后在重新catkin_make编译,依然不行;
《解决cv_bridge和opencv之间版本匹配问题》
https://zhuanlan.zhihu.com/p/392939687
接着卸载原来版本的cv_bridge
sudo apt-get remove ros-melodic-cv-bridge
重新编译安装cv_bridge之后,catkin_make编译后成功!

20.设置clash开机自启动
添加权限 chmod a+x clash
添加开机自启动 gnome-session-properties,直接输入路径即可
选择地址,浏览器输入http://clash.razord.top/#/proxies

你可能感兴趣的:(slam,人工智能,机器学习,自动驾驶,python)