ROS交流群
ROS Group
产品服务
Product Service
开源代码库
Github
官网
Official website
技术交流
Technological exchanges
激光雷达
LIDAR
ROS教程
ROS Tourials
深度学习
Deep Learning
机器视觉
Computer Vision

xiaoqiang ROS robot tutorial (17)


  • administrators

    Xiaoqiang ROS Robot Tutorial (17)_Using ORB_SLAM2 to create a three-dimensional model of the environment

    To achieve visual navigation, a three-dimensional model of space is a must. ORB_SLAM is a very effective algorithm for building spatial models. This algorithm is based on the recognition of ORB feature points, with high accuracy and high operating efficiency. We have modified the original algorithm, added the map’s save and load functions, making it more applicable to the actual application scenario. The following describes the specific use.

    Prepared work

    Before starting ORB_SLAM2, please confirm that Xiaoqiang’s camera is working properly. In the use of ORB_SLAM2 in the process of building plans to move Xiaoqiang, in the process of moving Xiaoqiang inconvenient to display the ORB_SLAM2 running status (ssh remote operation is not smooth, it is impossible to drag the monitor), so please install Xiaoqiang map remote control windows client.

    Start ORB_SLAM2

    Change the configuration file. The configuration file for ORB_SLAM2 is located in the /home/xiaoqiang/Documents/ros/workspace/src/ORB_SLAM2/Examples/ROS/orb_slam2/Data folder. Change the value of LoadMap in the setting.yaml and set it to 0. When set to 1, the program automatically loads map data from the /home/xiaoqiang/slamdb folder after startup. When set to 0, map data will not be loaded. Since we want to create a map, LoadMap needs to be set to 0.

    0_1536827937244_fc93b92c-4e0c-4f9c-bee1-fe674f399924-image.png

    Use ssh to enter Xiaoqiang and execute the following command

    ssh -X xiaoqiang@192.168.xxx.xxx
    roslaunch ORB_SLAM2 map.launch
    

    Began to establish an environmental 3D model

    Open Xiaoqiang Tuzhu remote control windows client, click on the “Not connected” button to connect Xiaoqiang. Right-click in the image window to open the “original image” and “ORB_SLAM2’s feature point image”

    0_1536828021194_11b4a8c0-1ca7-4b1c-b227-d6ccb6274f48-image.png

    0_1536828027432_dfaee4f9-143f-4baf-8afc-ef1525cb306e-image.png

    In the figure above, the left image is the camera’s original color image, and the right side is the ORB_SLAM2 processed black and white image. The current ORB_SLAM2 has not been initialized successfully, so the black and white image has no feature points. Hold down the “w” key to start the remote control Xiaoqiang slowly move forward, so that ORB_SLAM2 initialized successfully, that is, black and white images began to appear red and green features.

    0_1536828044870_90f0bedd-a772-405a-870a-51ee86b2c8cb-image.png

    It is now possible to begin remote control of Xiaoqiang’s construction of the surrounding environment. During the remote control process, it is necessary to ensure that the black-and-white image always has red and green feature points. If it does not exist, it means that the visual lost, and it is necessary to remotely control Xiaoqiang to return to the place where the last missed lost position. Client Operation Demo Video.

    Use rviz to view the build effect

    Add Xiaoqiang IP address in the local virtual machine hosts, then open a new terminal to open rviz.

    export ROS_MASTER_URI=http://xiaoqiang-desktop:11311
    rviz
    

    Open the /home/xiaoqiang/Documents/ros/src/ORB_SLAM/Data/rivz.rviz configuration file. Some systems may not be able to open this file. You can copy the file locally and open it locally.

    0_1536828130444_9b8f79d5-c516-4290-9cf3-25c1f27efa83-image.png

    As shown in the figure below, the red and black points are three-dimensional models (sparse feature point clouds) established, and the blue boxes are keyframes that can represent the tracks of Xiaoqiang.

    0_1536828143553_e39ab193-28e9-4ecf-8f4b-1a7b6c5c574a-image.png

    Save the map

    After the map has been created to meet the requirements, create a new command window in the VM and enter the following command to save the map:

    ssh -X xiaoqiang@192.168.xxx.xxx
    rostopic pub /map_save std_msgs/Bool '{data: true}'  -1
    

    This command triggers the save task every 10 seconds, so when you see the image below, please close the above window. In the virtual machine, open a new command window and enter the following command to detect whether the map save command has been issued.

    ssh -X xiaoqiang@192.168.xxx.xxx
    rostopic echo /map_save
    

    0_1536828255273_57385256-9c3d-4118-a8ba-f8d4ebfd5097-image.png

    The map file will be saved in the slamdb folder in the user’s home directory.

    Loading of maps

    You can load the ORB_SLAM2 program again after saving the map. After the map is loaded, the program can quickly locate the specific location of the camera. In this way, visual positioning-based navigation algorithms can be developed. The way to load the map is also very simple. Set the value of LoadMap to 1 in the setting.yaml file in the /home/xiaoqiang/Documents/ros/workspace/src/ORB_SLAM2/Examples/ROS/orb_slam2/Data folder.

    Post processing of maps

    After creating the map, you want to use this map for navigation, you need to do further operations on the map file. For example, to create a navigation line, mark the navigation path to walk and so on. This section can be found in the article Visual Navigation Path Editor Tutorial.