天天看点

ROS配置ORB_SLAM2笔记本摄像头运行ORB_SLAM2RealSense的SDK安装启动RVIZ运行RealSenseRealSense运行ORB_SLAM2参考

笔记本摄像头运行ORB_SLAM2

ORB_SLAM2/ROS的安装,具体安装流程博主之前写过,读者可以自行阅读。

添加环境变量

cd ~

gedit .bashrc

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS

该步的作用是设置ROS功能包的执行目录。在执行roslaunch或rosrun时,会去上述路径中寻找功能包。

使用

rospack profile

可查看功能包的路径:

ROS配置ORB_SLAM2笔记本摄像头运行ORB_SLAM2RealSense的SDK安装启动RVIZ运行RealSenseRealSense运行ORB_SLAM2参考

编译ROS文件

cd ORB_SLAM2的目录下

chmod +x build_ros.sh

./build_ros.sh

安装摄像头驱动功能包

编译usb_cam(下载链接:https://github.com/bosch-ros-pkg/usb_cam)

//把usb_cam放到catkin_ws/src下

cd catkin_ws/src/usb_cam

mkdir build

cd build

cmake …

make

cmake …会将CMakeList文件变为MakeFile

修改launch文件

进入catkin_ws/src/usb_cam/launch中,修改usb_cam-test.launch文件

cd ~/catkin_ws/src/usb_cam/launch

gedit usb_cam-test.launch

我这里只需要该设备号即可,笔记本电脑的video0一般是网络摄像头,插入usb摄像头一般是video1。

修改主要是:

< param name=“video_device” value="/dev/video0" /> //video0是电脑自带摄像头

修改节点名称

在/home/dk/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc中,话题名称为:

ros::Subscriber sub = nodeHandler.subscribe("/image/image_raw", 0, &ImageGrabber::GrabImage,&igb);

现在想使用笔记本摄像头,因此将话题名称改为

ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 0, &ImageGrabber::GrabImage,&igb);

运行

一共启动两个节点:

  1. 摄像头驱动节点
  2. ORB_SLAM2功能包中的Mono节点

roscore

// 运行一个新的终端

cd ~/catkin_ws

. devel/setup.bash

roslaunch usb_cam usb_cam-test.launch

//这时摄像头应该已经打开,

//新开一个终端

source ~/.bashrc

//这里用的参数文件是examples自带的,其实还是要自己标定下摄像头的

rosrun ORB_SLAM2 Mono /home/dk/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/dk/ORB_SLAM2/Examples/Monocular/TUM1.yaml

ORB_SLAM2:功能包名称

Mono:可执行程序名称

/home/dk/ORB_SLAM2/Vocabulary/ORBvoc.txt:词典地址

home/dk/ORB_SLAM2/Examples/Monocular/TUM1.yaml:相机参数,应该自己标定一下

一直初始化失败

如果相机一直初始化失败的话,可以改变单目相机初始化时设定的特征点匹配阈值。

在运行的时候,设定相机参数的yaml文件为:/home/dk/ORB_SLAM2/Examples/Monocular/TUM1.yaml

修改以下两个参数:

ORBextractor.iniThFAST: 10
ORBextractor.minThFAST: 5
           

运行效果

ROS配置ORB_SLAM2笔记本摄像头运行ORB_SLAM2RealSense的SDK安装启动RVIZ运行RealSenseRealSense运行ORB_SLAM2参考

RealSense的SDK安装

https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md

注册服务器的公用密钥:

sudo apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE 
           

将服务器添加到存储库列表中:

Ubuntu 16 LTS:

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo xenial main" -u
           

Ubuntu 18 LTS:

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo bionic main" -u
           

Ubuntu 20 LTS:

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo focal 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
           

运行

realsense-viewer
           
ROS配置ORB_SLAM2笔记本摄像头运行ORB_SLAM2RealSense的SDK安装启动RVIZ运行RealSenseRealSense运行ORB_SLAM2参考

启动RVIZ运行RealSense

https://github.com/IntelRealSense/realsense-ros

安装功能包

sudo apt install ros-melodic-realsense2-camera
sudo apt install ros-melodic-realsense2-description
           

启动相机节点

发布点云

roslaunch realsense2_camera rs_camera.launch filters:=pointcloud
           
ROS配置ORB_SLAM2笔记本摄像头运行ORB_SLAM2RealSense的SDK安装启动RVIZ运行RealSenseRealSense运行ORB_SLAM2参考

RealSense运行ORB_SLAM2

插上相机

修改ros_rgbd.cc中的话题名称

进入catkin_ws/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src路径下,找到ros_rgbd.cc,修改:

message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth_registered/image_raw", 1);
           

message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/color/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "/camera/aligned_depth_to_color/image_raw", 1);
           

重新编译

进入ORB_SLAM2,重新编译一下

chmod +x build.sh
chmod +x build_ros.sh
./build.sh
./build_ros.sh
           

运行rs_rgbd.launch

roslaunch realsense2_camera rs_rgbd.launch

运行ORB_SLAM2

rosrun ORB_SLAM2 RGBD /home/dk/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/dk/ORB_SLAM2/Examples/ROS/ORB_SLAM2/RealSenseD435.yaml
ROS配置ORB_SLAM2笔记本摄像头运行ORB_SLAM2RealSense的SDK安装启动RVIZ运行RealSenseRealSense运行ORB_SLAM2参考

参考

https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md

https://github.com/IntelRealSense/realsense-ros

https://blog.csdn.net/Felaim/article/details/79612504

https://blog.csdn.net/Spacegene/article/details/109366009

继续阅读