Compile and run the monocular AR routine of ORB_SLAM2 with laptop camera and ROS under ubuntu16.04

To compile the ROS routine of ORB_SLAM2, you first need to install ROS, install and call the usb_cam driver under ROS, and finally build ORB_SLAM2.

1. ROS installation

My computer is installed with the ubuntu16.04 system, so I installed the 2016 release version ROS_Kinetic. Generally speaking, the version of ROS is updated once a year, which is synchronized with the system update of ubuntu. If your system is ubuntu14.04, you can install the 2014 release ROS_Indigo.

The installation of ROS_Kinetic on ubuntu16.04 can refer to my blog: click on the link address

 

2. Compilation of usb_cam in ROS

First, create a new ROS workspace

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

build workspace

cd ~/catkin_ws/
catkin_make

Set environment variables

source devel/setup.bash

If your terminal is zsh, please use the following command

source devel/setup.zsh

Go to the catkin_ws/src directory and download the source file of usb_cam to this directory

cd ~/catkin_ws/src
git clone https://github.com/bosch-ros-pkg/usb_cam.git

Exit to the catkin_ws directory and execute the catkin_make command to compile and set the environment

cd ..
catkin_make
source ~/catkin-ws/devel/setup.bash

Can test whether the configuration is successful

roscd usb_cam

If no error is reported, the installation is successful

3. Compile the ORB_SLAM2 library

The simplest can be installed successfully according to the project address of orb_slam2 on github

Project address: https://github.com/raulmur/ORB_SLAM2

For details, please refer to my blog post: Click on the link address

 

4. Compile ROS routines

There are many tutorials for compiling ROS routines on the Internet, but I still think that the ones provided on github are the most convenient

First enter your ORB_SLAM2 source code directory, and then execute the command

chmod +x build_ros.sh
./build_ros.sh

This may not be 100% compiled successfully, but Mono and MonoAR can be compiled successfully, mainly because ros_rgbd cannot be compiled successfully, and an error occurs, so I ignore him.

After compiling, remember to add after .bashrc:

 

source /home/zn/ORB_SLAM2-master/Examples/ROS/ORB_SLAM2/build/devel/setup.bash

 

5. Run the Demo in ROS

After the above steps are successful, we can run the demo in ros

There is one more place to change before we start:

 

 

put ros_mono_ar.cc in

 

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

 

Change it to:

 

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

 

(See no, the path has changed. Because our pictures are all sent from /usb_cam/image_raw)

 

Then compile the Example again~

 

Now you can start:

 

First, we need to start the ros kernel, open a new terminal, and execute

roscore

Start the usb_cam camera node, open a new terminal, and execute

roslaunch usb_cam usb_cam.launch

Start the Mono node (monocular) of ORB_SLAM2

rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
PATH_TO_VOCABULARY is the ORBvoc.txt file path , PATH_TO_SETTINGS_FILE is your camera parameter file path

So you can enter the following command in the third terminal:

rosrun ORB_SLAM2 MonoAR /home/zn/ORB_SLAM2-master/Vocabulary/ORBvoc.txt  /home/zn/ORB_SLAM2-master/Examples/Monocular/TUM1.yaml

Change the path according to your own computer path. TUM1.yaml is the parameter setting file, mainly the internal parameters of the camera, which must be calibrated by yourself. If you are too lazy to calibrate, you can use TUM1.yaml directly without affecting the running of the program.

 

 

 

 end......

 Reference blog post: https://blog.csdn.net/u79501/article/details/68942174

http://www.liuxiao.org/2016/07/ubuntu-orb-slam2-%E5%9C%A8-ros-%E4%B8%8A%E7%BC%96%E8%AF%91%E8%B0%83%E8%AF%95/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325338596&siteId=291194637