gcc 7.5
cmake 3.22 最新的那个
opencv 3.2.0,需要改cmakelist.txt的版本号。包括 DWo2,根目录,ros文件夹下的cmakelist文件
python 2.7
安装参考链接 link
注意boost是最高版本1.79
需要gcc 11。安装error问题见https://blog.csdn.net/Robert_Q/article/details/121690089#commentBox
!重要:每次sudo make install 后需要sudo ldconfig。原因见链接。
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
git checkout v0.8
mkdir build
cd build
cmake ..
make -j4 && sudo make install
首选修改ros包里的cv_bridge,不然重连接我没成功过。
方法在sudo apt-get install ros-melodic-cv-bridge后,修改/opt/ros/melodic/shar/cv_bridge/cmake/cv_bridgeConfig.cmake文件,参考https://blog.csdn.net/weixin_44074560/article/details/122958605
根据自己的opencv版本重新编译:
https://blog.csdn.net/double_ZZZ/article/details/113254903
这篇可能也有用:
https://blog.csdn.net/weixin_41120855/article/details/81783081?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_title~default-1.pc_relevant_default&spm=1001.2101.3001.4242.2&utm_relevant_index=4
最后在~.bashrc中把cv_bridge引用上去
source ~/cv_bridge_ws/devel/setup.bash
https://blog.csdn.net/qq_45276794/article/details/120603577
就是运行./build_ros.sh
如果显示rosdep相关的error
source /opt/ros/melodic/setup.bash
小技巧 软链接命令:ln -s 源地址 目的地
数据集下载地址见上面的link,保存位置与下面的命令行参数一一对应。
# 测试orb3源码好不好使
cd ORB_SLAM3
# Mono
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml /home/wang/SLAM/data/EuRoC/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
# Monocular-Inertial
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml /home/wang/SLAM/data/EuRoC/MH01 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH01.txt dataset-MH01_monoi
# 测试使用ros好不好使
# v0.4
rosrun ORB_SLAM3 Mono /home/wang/SLAM/orb_slam3/ORB_SLAM3-0.4-beta/Vocabulary/ORBvoc.txt /home/wang/SLAM/orb_slam3/ORB_SLAM3-0.4-beta/Examples/Monocular/EuRoC.yaml
# v1.0
rosrun ORB_SLAM3 Mono /home/wang/SLAM/orb_slam3/ORB_SLAM3-master/Vocabulary/ORBvoc.txt /home/wang/SLAM/orb_slam3/ORB_SLAM3-master/Examples/Monocular/EuRoC.yaml
# Monocular-Inertial
rosrun ORB_SLAM3 Mono_Inertial /home/wang/SLAM/orb_slam3/ORB_SLAM3-master/Vocabulary/ORBvoc.txt /home/wang/SLAM/orb_slam3/ORB_SLAM3-master/Examples/Monocular-Inertial/EuRoC.yaml true
rosbag play ~/SLAM/data/EuRoC/MH_01_easy.bag
海康威视单目相机ROS包及参数标定方法https://blog.csdn.net/qq_37534947/article/details/116432115#t2
注意这个ros包发的 /hik_cam_node/hik_camera 中没有frame_id参数,暂时没解决这个问题
海康威视单目相机参数,其中camera matrix是内参矩阵,得到
[fx 0 cx]
[0 fy cy]
[0 0 1]
distortion是畸变参数,得到k1 k2 p1 p2 k3.
注意,如果点commit保存相机参数文件失败,需要手动将 /tmp/calibrationdata.tar.gz 解压,其中的 ost.yaml 重命名为 hik_camera.yaml 并保存至 ~/.ros/camera_info 文件夹下面。hik_camera与相机名称一致
下面是在终端中显示的标定结果
**** Calibrating ****
D = [-0.30318064649726423, 0.069185487190414, 0.0012419587934706482, -0.0030126245934705576, 0.0]
K = [700.1655092579188, 0.0, 642.3937890798327, 0.0, 703.867733396442, 341.6599142357398, 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 = [475.14862060546875, 0.0, 628.049404518315, 0.0, 0.0, 641.0703125, 338.66773242736235, 0.0, 0.0, 0.0, 1.0, 0.0]
None
# oST version 5.0 parameters
[image]
width
1280
height
720
[narrow_stereo]
camera matrix
700.165509 0.000000 642.393789
0.000000 703.867733 341.659914
0.000000 0.000000 1.000000
distortion
-0.303181 0.069185 0.001242 -0.003013 0.000000
rectification
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
projection
475.148621 0.000000 628.049405 0.000000
0.000000 641.070312 338.667732 0.000000
0.000000 0.000000 1.000000 0.000000
将其中参数提取出来保存为 zhen_mono.yaml (这个名字我起的)文件,具体内容参考链接https://blog.csdn.net/qq_42025235/article/details/123247083
下面开始测试
记得把orb3文件夹中ros_mono.cc里的topic换成 /hik_cam_node/hik_camera,然后重新./build_ros.sh 编译
# 标定摄像头参数的代码
roslaunch hikvision_ros hik.launch ip_addr:=192.168.1.64 password:=12345678ABC
rosrun camera_calibration cameracalibrator.py --size 8x5 --square 0.026 image:=/hik_cam_node/hik_camera camera:=/hik_cam_node/hik_camera
# 8*5是指棋盘格中横竖方向黑白对顶角个数,0.026是每格实际宽度0.026m
# 测试使用海康威视单目摄像头运行的代码
roslaunch hikvision_ros hik.launch ip_addr:=192.168.1.64 password:=12345678ABC
rosrun ORB_SLAM3 Mono /home/wang/SLAM/orb_slam3/ORB_SLAM3-0.4-beta/Vocabulary/ORBvoc.txt /home/wang/zhenrobot/calibrationdata/zhen_mono.yaml
参考链接 link
除了加代码,还需要改代码:加上判断buf中是否有图像的语句
if(!Tcw.empty()) {