ORB_SLAM2/ROS的安装,具体安装流程博主之前写过,读者可以自行阅读。
cd ~
gedit .bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
该步的作用是设置ROS功能包的执行目录。在执行roslaunch或rosrun时,会去上述路径中寻找功能包。
使用
rospack profile
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
进入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);
一共启动两个节点:
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
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
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
插上相机
进入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
roslaunch realsense2_camera rs_rgbd.launch
rosrun ORB_SLAM2 RGBD /home/dk/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/dk/ORB_SLAM2/Examples/ROS/ORB_SLAM2/RealSenseD435.yaml
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