Run through ORB-SLAM2 with opencv4.5.2 + melody + USB binocular camera
preface
Getting started with SLAM requires basic hardware such as depth camera and lidar, but considering their own economic strength, they start with the following camera. The specific length of this camera is like this. I bought it on Taobao for 35 yuan to practice.
In addition to the information provided by the merchants, many contents worthy of further extension have been found, such as how to carry out binocular ranging algorithm under ROS, PCL three-dimensional reconstruction, how to contact the binocular mapping of ORB-SLAM2, etc. When an idea is available, the next step is to start practicing. However, the road of practice is not as smooth as thought, and many problems have been encountered. In the process of checking the data, we have also found the incisive summary of many predecessors, so we do some sorting here
- How to communicate with usb device camera under ubuntu
- ros learn the cheapest binocular Chusei 3d webcam and use the uvcdynctrl command to control the binding under linux
- hack a 3D camera to relieve the boredom
- Read the C + + version of CHUSEI 3D Webcam binocular camera under Ubuntu (call python script for configuration)
- Calibration and ranging of binocular camera (Ubuntu 16.04 + openCV)
- Debug the cheapest binocular camera (including the upper computer of Linux version) CAM5031/CHUSEI 3D WEBCAM under linux/Ubuntu to solve the problem of billing only
- windows + python + opencv open binocular camera chusei3d step pit
Thanks to the experience of our predecessors, we have also solved some problems.
Question 1: binocular mode switching under Ubuntu
There are shell scripts in the materials provided by the merchant, but I personally feel that the experience in the use process is not friendly.
So I also made some improvements to the script. Note that the right needs to be raised before use
user@ubuntu:~/Stereo_cam/Camera_switch$ chmod +x ./camera_switch.sh
camera_switch.sh
#!/bin/bash # user@ubuntu:~/Stereo_cam/Camera_switch$ chmod +x ./camera_switch.sh upgrade execution permission # author : ruoxi printf "%-10s\n"Please enter camera channel read id # Select camera channel echo -e "It is switch to $id \n" # -e open escape printf "1.Left monocular mode: LEFT_EYE_MODE\n" printf "2.Right monocular mode: RIGHT_EYE_MODE\n" printf "3.Red blue mode: RED_BLUE_MODE\n" printf "4.Binocular mode: BINOCULAR_MODE\n" printf "%-10s\n"Please enter the camera output mode serial number read mode # Switch camera output mode printf "\n" uvcdynctrl -d /dev/video${id} -S 6:8 '(LE)0x50ff' uvcdynctrl -d /dev/video${id} -S 6:15 '(LE)0x00f6' uvcdynctrl -d /dev/video${id} -S 6:8 '(LE)0x2500' uvcdynctrl -d /dev/video${id} -S 6:8 '(LE)0x5ffe' uvcdynctrl -d /dev/video${id} -S 6:15 '(LE)0x0003' uvcdynctrl -d /dev/video${id} -S 6:15 '(LE)0x0002' uvcdynctrl -d /dev/video${id} -S 6:15 '(LE)0x0012' uvcdynctrl -d /dev/video${id} -S 6:15 '(LE)0x0004' uvcdynctrl -d /dev/video${id} -S 6:8 '(LE)0x76c3' uvcdynctrl -d /dev/video${id} -S 6:10 "(LE)0x0${mode}00" # Switch camera output mode printf "\n" echo -e "It is camera_mode $mode \n"
You can directly use the system("") call in the cpp file. The relative path is not introduced here
system("../../sh/camera_switch.sh"); //Under Ubuntu system, change here to your script storage relative path
Question 2: how to use the node in ROS to call the camera to display binocular images
An article is attached here Calibration and use of monocular and binocular cameras of ROS & opencv
This is provided by my little partner Node file , for your reference.
git clone -b melodic https://github.com/ruoxi521/Stereo_camera.git
Start camera_split node
user@ubuntu:~$ roslaunch camera_split stereo.launch
Operation results
Question 3: how to test the binocular camera to run through ORB-SLAM2
Modify orb_ SLAM2/Examples/ROS/ORB_ SLAM2/src/ros_ Two pieces of code of stereo.cc are changed to subscribe to camera_split node / left_cam and / right_cam's / image_raw topic
message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/left_cam/image_raw", 1); message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "/right_cam/image_raw", 1); //message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/camera/left/image_raw", 1); //message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "camera/right/image_raw", 1);
cd SLAM/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/ mkdir build cd build cmake .. make
Start camera_split node
user@ubuntu:~$ roslaunch camera_split stereo.launch
user@ubuntu:~$ roscore
Start Stereo binocular mapping
user@ubuntu:~/SLAM/src/ORB_SLAM2$ rosrun ORB_SLAM2 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml true
Operation results
Careful friends may find that they only subscribe to the topics published by the left camera, but we set them to subscribe to the topics published by the left and right cameras,
Why?
I think it may be that for the binocular USB camera, the output image is synthesized. We segment the images of the left and right cameras through the software method. At the same time, for the need to subscribe to two topics at the same time, we need to merge them synchronously, and then transfer them as parameters. The specific process is not introduced here. Students can explore and solve it by themselves.
You can refer to the ideas of this article ROS subscribes to multiple topics and processes them synchronously (multi-sensor fusion)
summary
The above is the content of this paper. This paper introduces how to run through ORB-SLAM2 with opencv4.5.2 + melody + USB binocular camera on Ubuntu 18.04. This paper is rough. If there are any deficiencies, please correct them.Set up a Flag here, and then share some learning experience of laser SLAM
reference material:
(1) ROS official website http://wiki.ros.org/melodic/Installation/Ubuntu
If you need to reprint, please indicate: reprinted from CSDN Su Jie
Welcome continuous attention My ROS column and My SLAM column