├── CMakeLists.txt
├── LICENSE
├── README.md
├── config
├── comparative_test.yaml
├── extention_test.yaml
├── orbvoc
│ └── ORBvoc.bin
└── rviz
│ └── default.rviz
├── core
├── include
│ └── dre_slam
│ │ ├── ORBextractor.h
│ │ ├── camera.h
│ │ ├── common.h
│ │ ├── config.h
│ │ ├── dre_slam.h
│ │ ├── dynamic_pixel_culling.h
│ │ ├── dynamic_pixel_detector.h
│ │ ├── encoder.h
│ │ ├── encoder_integration.h
│ │ ├── feature_detector.h
│ │ ├── frame.h
│ │ ├── keyframe.h
│ │ ├── local_mapping.h
│ │ ├── loop_closing.h
│ │ ├── map.h
│ │ ├── map_point.h
│ │ ├── octomap_fusion.h
│ │ ├── optimizer.h
│ │ ├── ros_puber.h
│ │ ├── run_timer.h
│ │ ├── sub_octomap.h
│ │ ├── sub_octomap_construction.h
│ │ ├── tracking.h
│ │ └── vocabulary.h
└── src
│ ├── ORBextractor.cpp
│ ├── camera.cpp
│ ├── common.cpp
│ ├── config.cpp
│ ├── dre_slam.cpp
│ ├── dynamic_pixel_culling.cpp
│ ├── dynamic_pixel_detector.cpp
│ ├── encoder_integration.cpp
│ ├── feature_detector.cpp
│ ├── frame.cpp
│ ├── keyframe.cpp
│ ├── local_mapping.cpp
│ ├── loop_closing.cpp
│ ├── map.cpp
│ ├── map_point.cpp
│ ├── octomap_fusion.cpp
│ ├── optimizer.cpp
│ ├── ros_puber.cpp
│ ├── sub_octomap.cpp
│ ├── sub_octomap_construction.cpp
│ └── tracking.cpp
├── corridor.gif
├── launch
├── comparative_test.launch
└── extention_test.launch
├── node
└── dre_slam_node.cpp
├── object_detector
├── CMakeLists.txt
├── object_detector.cpp
└── object_detector.h
├── package.xml
└── third_party
├── DBoW2
├── CMakeLists.txt
├── DBoW2
│ ├── BowVector.cpp
│ ├── BowVector.h
│ ├── FClass.h
│ ├── FORB.cpp
│ ├── FORB.h
│ ├── FeatureVector.cpp
│ ├── FeatureVector.h
│ ├── ScoringObject.cpp
│ ├── ScoringObject.h
│ └── TemplatedVocabulary.h
├── DUtils
│ ├── Random.cpp
│ ├── Random.h
│ ├── Timestamp.cpp
│ └── Timestamp.h
├── LICENSE.txt
└── README.txt
└── Sophus
├── CMakeLists.txt
├── README
├── SophusConfig.cmake.in
├── cmake_modules
└── FindEigen3.cmake
└── sophus
├── scso3.cpp
├── scso3.h
├── se2.cpp
├── se2.h
├── se3.cpp
├── se3.h
├── sim3.cpp
├── sim3.h
├── so2.cpp
├── so2.h
├── so3.cpp
├── so3.h
├── test_scso3.cpp
├── test_se2.cpp
├── test_se3.cpp
├── test_sim3.cpp
├── test_so2.cpp
└── test_so3.cpp
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(dre_slam)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | add_compile_options(-std=c++11)
6 | set(CMAKE_BUILD_TYPE Release)
7 |
8 | ## Find catkin macros and libraries
9 | find_package(catkin REQUIRED COMPONENTS
10 | roscpp
11 | cv_bridge
12 | image_transport
13 | geometry_msgs
14 | message_filters
15 | pcl_ros
16 | )
17 |
18 | catkin_package(
19 | )
20 |
21 | ## System dependencies are found with CMake's conventions
22 | find_package(PCL REQUIRED)
23 | find_package(OpenCV 3 REQUIRED)
24 | find_package(Eigen3 REQUIRED)
25 | find_package(Ceres REQUIRED )
26 | find_package(Sophus REQUIRED)
27 | find_package(octomap REQUIRED)
28 |
29 | include_directories(
30 | ${catkin_INCLUDE_DIRS}
31 | ${OpenCV_INCLUDE_DIRS}
32 | ${EIGEN3_INCLUDE_DIR}
33 | ${PCL_INCLUDE_DIRS}
34 | ${CERES_INCLUDE_DIRS}
35 | ${Sophus_INCLUDE_DIRS}
36 | ${OCTOMAP_INCLUDE_DIRS}
37 | ${PROJECT_SOURCE_DIR}
38 | ${PROJECT_SOURCE_DIR}/core/include/
39 | ${PROJECT_SOURCE_DIR}/third_party/
40 | )
41 |
42 | ## Declare a C++ library
43 | add_library(${PROJECT_NAME}_lib
44 | core/src/dre_slam.cpp
45 | core/src/config.cpp
46 | core/src/ORBextractor.cpp
47 | core/src/camera.cpp
48 | core/src/tracking.cpp
49 | core/src/local_mapping.cpp
50 | core/src/loop_closing.cpp
51 | core/src/map.cpp
52 | core/src/map_point.cpp
53 | core/src/feature_detector.cpp
54 | core/src/frame.cpp
55 | core/src/keyframe.cpp
56 | core/src/encoder_integration.cpp
57 | core/src/common.cpp
58 | core/src/optimizer.cpp
59 | core/src/dynamic_pixel_detector.cpp
60 | core/src/dynamic_pixel_culling.cpp
61 | core/src/ros_puber.cpp
62 | core/src/octomap_fusion.cpp
63 | core/src/sub_octomap.cpp
64 | core/src/sub_octomap_construction.cpp
65 | )
66 |
67 | target_link_libraries(${PROJECT_NAME}_lib
68 | ${catkin_LIBRARIES}
69 | ${OpenCV_LIBS}
70 | ${EIGEN3_LIBS}
71 | ${PCL_LIBRARIES}
72 | ${CERES_LIBRARIES}
73 | ${Sophus_LIBRARIES}
74 | ${PROJECT_SOURCE_DIR}/third_party/DBoW2/lib/libDBoW2.so
75 | ${PROJECT_SOURCE_DIR}/object_detector/lib/libobject_detector.so
76 | ${OCTOMAP_LIBRARIES}
77 | )
78 |
79 |
80 | # dre_slam_node
81 | add_executable(dre_slam_node
82 | node/dre_slam_node.cpp)
83 | target_link_libraries(dre_slam_node
84 | ${PROJECT_NAME}_lib
85 | ${catkin_LIBRARIES}
86 | )
87 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DRE-SLAM
2 | ## Dynamic RGB-D Encoder SLAM for a Differential-Drive Robot
3 | **Authors**: [Dongsheng Yang](https://github.com/ydsf16), [Shusheng Bi](http://ir.lib.buaa.edu.cn/Scholar/ScholarCard/5784), [Wei Wang](http://ir.lib.buaa.edu.cn/Scholar/ScholarCard/5800), Chang Yuan, Wei Wang, Xianyu Qi, and [Yueri Cai](http://ir.lib.buaa.edu.cn/Scholar/ScholarCard/5785)
4 |
5 | 
6 |
7 | **DRE-SLAM** is developed for a differential-drive robot that runs in dynamic indoor scenarios. It takes the information of an RGB-D camera and two wheel-encoders as inputs. The outputs are the 2D pose of the robot and a static background OctoMap.
8 |
9 | **Video**: [Youtube](https://youtu.be/3A5wpWgrHTI) or [Dropbox](https://www.dropbox.com/s/uvqyb3mo6tj4pf2/DRE-SLAM-20190111-v3.mp4?dl=0) or [Pan.Baidu](https://pan.baidu.com/s/1vVakfXZJziU12-vqw7Go1Q)
10 |
11 |
13 |
14 | **Paper**: ***DRE-SLAM: Dynamic RGB-D Encoder SLAM for a Differential-Drive Robot***, Dongsheng Yang, Shusheng Bi, Wei Wang, Chang Yuan, Wei Wang, Xianyu Qi, and Yueri Cai. (Remote Sensing, 2019) [PDF](https://www.mdpi.com/2072-4292/11/4/380/pdf), [WEB](https://www.mdpi.com/2072-4292/11/4/380)
15 |
16 | # Prerequisites
17 | ### 1. **Ubuntu 16.04**
18 |
19 | ### 2. **[ROS Kinetic](http://wiki.ros.org)**
20 | Follow the instructions in:
21 | ### 3. **ROS pacakges**
22 | ```
23 | sudo apt-get install ros-kinetic-cv-bridge ros-kinetic-tf ros-kinetic-message-filters ros-kinetic-image-transport ros-kinetic-octomap ros-kinetic-octomap-msgs ros-kinetic-octomap-ros ros-kinetic-octomap-rviz-plugins ros-kinetic-octomap-server ros-kinetic-pcl-ros ros-kinetic-pcl-msgs ros-kinetic-pcl-conversions ros-kinetic-geometry-msgs
24 | ```
25 |
26 | ### 4. [OpenCV 4.0](https://opencv.org/opencv-4-0-0.html)
27 | We use the YOLOv3 implemented in OpenCV 4.0.
28 |
29 | Follow the instructions in:
30 |
31 | ### 5. Ceres
32 | Follow the instructions in:
33 |
34 | # Build DRE-SLAM
35 | ### 1. Clone the repository
36 | ```
37 | cd ~/catkin_ws/src
38 | git clone https://github.com/ydsf16/dre_slam.git
39 | ```
40 |
41 | ### 2. Build DBow2
42 | ```
43 | cd dre_slam/third_party/DBoW2
44 | mkdir build
45 | cd build
46 | cmake ..
47 | make -j4
48 | ```
49 |
50 | ### 3. Build Sophus
51 | ```
52 | cd ../../Sophus
53 | mkdir build
54 | cd build
55 | cmake ..
56 | make -j4
57 | ```
58 |
59 | ### 4. Build object detector
60 | ```
61 | cd ../../../object_detector
62 | mkdir build
63 | cd build
64 | cmake ..
65 | make -j4
66 | ```
67 |
68 | ### 5. Download the YOLOv3 model
69 | ```
70 | cd ../../config
71 | mkdir yolov3
72 | cd yolov3
73 | wget https://pjreddie.com/media/files/yolov3.weights
74 | wget https://github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg?raw=true -O ./yolov3.cfg
75 | wget https://github.com/pjreddie/darknet/blob/master/data/coco.names?raw=true -O ./coco.names
76 | ```
77 |
78 | ### 6. Catkin_make
79 | ```
80 | cd ~/catkin_ws
81 | catkin_make
82 | source ~/catkin_ws/devel/setup.bash
83 | ```
84 |
85 | # Example
86 |
87 | ## Dataset
88 | We collected several data sequences in our lab using our Redbot robot. The dataset is available at [Pan.Baidu](https://pan.baidu.com/s/1freJVLeIE525xHUZY01HmQ) or [Dropbox](https://www.dropbox.com/sh/f7fsx8s9k9oya3r/AACBoOUlPNo7inOVceHD5gy_a?dl=0).
89 |
90 | ## Run
91 | ### 1. Open a terminal and launch dre_slam
92 | ```
93 | roslaunch dre_slam comparative_test.launch
94 | ```
95 |
96 | ### 2. Open a terminal and play one rosbag
97 |
98 | ```
99 | rosbag play .bag
100 | ```
101 |
102 | # Run on your own robot
103 | **You need to do three things:**
104 |
105 | 1. Calibrate the intrinsic parameter of the camera, the robot odometry parameter, and the rigid transformation from the camera to the robot.
106 |
107 | 2. Prepare a parameter configuration file, refer to the ***config*** folder.
108 |
109 | 3. Prepare a launch file, refer to the ***launch*** folder.
110 |
111 | # Contact us
112 | For any issues, please feel free to contact **[Dongsheng Yang](https://github.com/ydsf16)**:
113 |
--------------------------------------------------------------------------------
/config/comparative_test.yaml:
--------------------------------------------------------------------------------
1 | %YAML:1.2
2 |
3 | #--------------------------------------------------------------------------------------------
4 | # Camera params. Pinhole
5 | #--------------------------------------------------------------------------------------------
6 | cam_rgb_topic_: /kinect2/qhd/image_color
7 | cam_depth_topic_: /kinect2/qhd/image_depth_rect
8 |
9 | cam_fx_: 525.2866213437447
10 | cam_fy_: 525.2178123117577
11 | cam_cx_: 472.85738972861157
12 | cam_cy_: 264.77181506420266
13 | cam_k1_: 0.04160142651680036
14 | cam_k2_: -0.04771035303381654
15 | cam_p1_: -0.0032638387781624705
16 | cam_p2_: -0.003985120051161831
17 | cam_k3_: 0.01110263483766991
18 |
19 | cam_height_: 540
20 | cam_width_: 960
21 |
22 | cam_depth_factor_: 0.001 # Depth scale factor.
23 |
24 | cam_dmax_: 8.0 # Max depth value to be used. (m)
25 | cam_dmin_: 0.1 # Min depth value to be used. (m)
26 |
27 | cam_fps_: 20 # Camera FPs.
28 |
29 | #--------------------------------------------------------------------------------------------
30 | # Robot intrinsic and extrinsic
31 | #--------------------------------------------------------------------------------------------
32 | #### Intrinsic
33 | encoder_topic_: /rbot/encoder
34 |
35 | odom_kl_: 4.0652e-5 # left wheel factor
36 | odom_kr_: 4.0668e-5 # right wheel factor
37 | odom_b_: 0.3166 # wheel space
38 | odom_K_: 0.008 # Noise factor.
39 |
40 | #### Extrinsic Trc
41 | Trc_: !!opencv-matrix
42 | rows: 3
43 | cols: 4
44 | dt: d
45 | data: [ 0.0, -0.034899497, 0.999390827, 0.124, -1.0, 0.0, 0.0, -0.1, 0.0, -0.999390827, -0.034899497, 0.0 ]
46 |
47 | #--------------------------------------------------------------------------------------------
48 | # RGB-D Encoder Tracking
49 | #--------------------------------------------------------------------------------------------
50 | #### ORB feature
51 | ret_ft_n_features_: 1600 # Number of ORB features per frame.
52 |
53 | #### Tracking
54 | ret_tk_dist_th_: 4.0 # Local map search radius. (m)
55 | ret_tk_angle_th_: 1.0 # Local map search angle. (rad)
56 | ret_tk_db_: 0.20 # Base threshold for erroneous match discard. (m)
57 | ret_tk_kd_: 0.025 # Scale factor of the threshold for erroneous match discard.
58 |
59 | #### Keyframe decision
60 | # Condation 1.
61 | ret_kd_fps_factor_: 0.9
62 | # Condation 2:
63 | ret_kd_dist_th_: 0.3 # Max distance (m)
64 | ret_kd_angle_th_: 0.5 # Max angle (rad)
65 |
66 | #--------------------------------------------------------------------------------------------
67 | # Dynamic Pixels Culling
68 | #--------------------------------------------------------------------------------------------
69 | dpc_n_near_kfs_: 5 # Number of near keyframes.
70 | dpc_npts_per_cluster_: 6000 # Number of points per cluster.
71 | dpc_n_sel_pts_per_cluster_: 100 # Number of points per cluster to be selected for dynamic cluster decision.
72 | dpc_search_square_size_: 9 # 9 pixels
73 |
74 | #--------------------------------------------------------------------------------------------
75 | # Sparse Mapping
76 | #--------------------------------------------------------------------------------------------
77 | #### Local Mapping
78 | sm_lm_window_size_: 8 # local BA window size sp_lm_window_size_ KFs.
79 |
80 |
81 | #--------------------------------------------------------------------------------------------
82 | # OctoMap Construction
83 | #--------------------------------------------------------------------------------------------
84 | oc_voxel_size_: 0.1 # Voxel size of the OctoMap (m).
85 | oc_submap_size_: 5 # Sub-OctoMap size (KFs)
86 |
87 |
88 |
--------------------------------------------------------------------------------
/config/extention_test.yaml:
--------------------------------------------------------------------------------
1 | %YAML:1.2
2 |
3 | #--------------------------------------------------------------------------------------------
4 | # Camera params. Pinhole
5 | #--------------------------------------------------------------------------------------------
6 | cam_rgb_topic_: /kinect2/qhd/image_color
7 | cam_depth_topic_: /kinect2/qhd/image_depth_rect
8 |
9 | cam_fx_: 525.2866213437447
10 | cam_fy_: 525.2178123117577
11 | cam_cx_: 472.85738972861157
12 | cam_cy_: 264.77181506420266
13 | cam_k1_: 0.04160142651680036
14 | cam_k2_: -0.04771035303381654
15 | cam_p1_: -0.0032638387781624705
16 | cam_p2_: -0.003985120051161831
17 | cam_k3_: 0.01110263483766991
18 |
19 | cam_height_: 540
20 | cam_width_: 960
21 |
22 | cam_depth_factor_: 0.001 # Depth scale factor.
23 |
24 | cam_dmax_: 8.0 # Max depth value to be used. (m)
25 | cam_dmin_: 0.1 # Min depth value to be used. (m)
26 |
27 | cam_fps_: 10 # Camera FPs.
28 |
29 | #--------------------------------------------------------------------------------------------
30 | # Robot intrinsic and extrinsic
31 | #--------------------------------------------------------------------------------------------
32 | #### Intrinsic
33 | encoder_topic_: /rbot/encoder
34 |
35 | odom_kl_: 4.0652e-5 # left wheel factor
36 | odom_kr_: 4.0668e-5 # right wheel factor
37 | odom_b_: 0.3166 # wheel space
38 | odom_K_: 0.008 # Noise factor.
39 |
40 | #### Extrinsic Trc
41 | Trc_: !!opencv-matrix
42 | rows: 3
43 | cols: 4
44 | dt: d
45 | data: [ 0.0, 0.275637, 0.9612617, 0.124, -1.0, 0.0, 0.0, -0.1, 0.0, -0.9612617, 0.275637, 0.0 ]
46 |
47 | #--------------------------------------------------------------------------------------------
48 | # RGB-D Encoder Tracking
49 | #--------------------------------------------------------------------------------------------
50 | #### ORB feature
51 | ret_ft_n_features_: 1600 # Number of ORB features per frame.
52 |
53 | #### Tracking
54 | ret_tk_dist_th_: 4.0 # Local map search radius. (m)
55 | ret_tk_angle_th_: 1.0 # Local map search angle. (rad)
56 | ret_tk_db_: 0.20 # Base threshold for erroneous match discard. (m)
57 | ret_tk_kd_: 0.025 # Scale factor of the threshold for erroneous match discard.
58 |
59 | #### Keyframe decision
60 | # Condation 1.
61 | ret_kd_fps_factor_: 0.9
62 | # Condation 2:
63 | ret_kd_dist_th_: 0.3 # Max distance (m)
64 | ret_kd_angle_th_: 0.5 # Max angle (rad)
65 |
66 | #--------------------------------------------------------------------------------------------
67 | # Dynamic Pixels Culling
68 | #--------------------------------------------------------------------------------------------
69 | dpc_n_near_kfs_: 5 # Number of near keyframes.
70 | dpc_npts_per_cluster_: 6000 # Number of points per cluster.
71 | dpc_n_sel_pts_per_cluster_: 100 # Number of points per cluster to be selected for dynamic cluster decision.
72 | dpc_search_square_size_: 9 # 9 pixels
73 |
74 | #--------------------------------------------------------------------------------------------
75 | # Sparse Mapping
76 | #--------------------------------------------------------------------------------------------
77 | #### Local Mapping
78 | sm_lm_window_size_: 8 # local BA window size sp_lm_window_size_ KFs.
79 |
80 |
81 | #--------------------------------------------------------------------------------------------
82 | # OctoMap Construction
83 | #--------------------------------------------------------------------------------------------
84 | oc_voxel_size_: 0.1 # Voxel size of the OctoMap (m).
85 | oc_submap_size_: 5 # Sub-OctoMap size (KFs)
86 |
--------------------------------------------------------------------------------
/config/orbvoc/ORBvoc.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ydsf16/dre_slam/346e740578d2e58e1b2daa4fd60c811af7134375/config/orbvoc/ORBvoc.bin
--------------------------------------------------------------------------------
/core/include/dre_slam/ORBextractor.h:
--------------------------------------------------------------------------------
1 | // This file is part of dre_slam - Dynamic RGB-D Encoder SLAM for Differential-Drive Robot.
2 | //
3 | // Copyright (C) 2019 Dongsheng Yang
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | /**
18 | * This file is part of ORB-SLAM2.
19 | *
20 | * Copyright (C) 2014-2016 Raúl Mur-Artal (University of Zaragoza)
21 | * For more information see
22 | *
23 | * ORB-SLAM2 is free software: you can redistribute it and/or modify
24 | * it under the terms of the GNU General Public License as published by
25 | * the Free Software Foundation, either version 3 of the License, or
26 | * (at your option) any later version.
27 | *
28 | * ORB-SLAM2 is distributed in the hope that it will be useful,
29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 | * GNU General Public License for more details.
32 | *
33 | * You should have received a copy of the GNU General Public License
34 | * along with ORB-SLAM2. If not, see .
35 | */
36 |
37 | #ifndef ORBEXTRACTOR_H
38 | #define ORBEXTRACTOR_H
39 |
40 | #include
41 | #include
42 | #include
43 |
44 |
45 | namespace dre_slam
46 | {
47 |
48 | class ExtractorNode
49 | {
50 | public:
51 | ExtractorNode():bNoMore(false){}
52 |
53 | void DivideNode(ExtractorNode &n1, ExtractorNode &n2, ExtractorNode &n3, ExtractorNode &n4);
54 |
55 | std::vector vKeys;
56 | cv::Point2i UL, UR, BL, BR;
57 | std::list::iterator lit;
58 | bool bNoMore;
59 | };
60 |
61 | class ORBextractor
62 | {
63 | public:
64 |
65 | enum {HARRIS_SCORE=0, FAST_SCORE=1 };
66 |
67 | ORBextractor(int nfeatures, float scaleFactor, int nlevels,
68 | int iniThFAST, int minThFAST);
69 |
70 | ~ORBextractor(){}
71 |
72 | // Compute the ORB features and descriptors on an image.
73 | // ORB are dispersed on the image using an octree.
74 | // Mask is ignored in the current implementation.
75 | void operator()( cv::InputArray image, cv::InputArray mask,
76 | std::vector& keypoints,
77 | cv::OutputArray descriptors);
78 |
79 | int inline GetLevels(){
80 | return nlevels;}
81 |
82 | float inline GetScaleFactor(){
83 | return scaleFactor;}
84 |
85 | std::vector inline GetScaleFactors(){
86 | return mvScaleFactor;
87 | }
88 |
89 | std::vector inline GetInverseScaleFactors(){
90 | return mvInvScaleFactor;
91 | }
92 |
93 | std::vector inline GetScaleSigmaSquares(){
94 | return mvLevelSigma2;
95 | }
96 |
97 | std::vector inline GetInverseScaleSigmaSquares(){
98 | return mvInvLevelSigma2;
99 | }
100 |
101 | std::vector mvImagePyramid;
102 |
103 | protected:
104 |
105 | void ComputePyramid(cv::Mat image);
106 | void ComputeKeyPointsOctTree(std::vector >& allKeypoints);
107 | std::vector DistributeOctTree(const std::vector& vToDistributeKeys, const int &minX,
108 | const int &maxX, const int &minY, const int &maxY, const int &nFeatures, const int &level);
109 |
110 | void ComputeKeyPointsOld(std::vector >& allKeypoints);
111 | std::vector pattern;
112 |
113 | int nfeatures;
114 | double scaleFactor;
115 | int nlevels;
116 | int iniThFAST;
117 | int minThFAST;
118 |
119 | std::vector mnFeaturesPerLevel;
120 |
121 | std::vector umax;
122 |
123 | std::vector mvScaleFactor;
124 | std::vector mvInvScaleFactor;
125 | std::vector mvLevelSigma2;
126 | std::vector mvInvLevelSigma2;
127 | };
128 |
129 | } //namespace dre_slam
130 |
131 | #endif
132 |
133 |
--------------------------------------------------------------------------------
/core/include/dre_slam/camera.h:
--------------------------------------------------------------------------------
1 | // This file is part of dre_slam - Dynamic RGB-D Encoder SLAM for Differential-Drive Robot.
2 | //
3 | // Copyright (C) 2019 Dongsheng Yang
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef CAMERA_H
18 | #define CAMERA_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace dre_slam
26 | {
27 |
28 | class Camera
29 | {
30 | public:
31 | Camera ( int width, int height,
32 | double fx, double fy, double cx, double cy,
33 | double k1, double k2 , double p1 , double p2, double k3);
34 |
35 |
36 | Eigen::Vector3d img2Cam ( const Eigen::Vector2d& px, const double& depth );
37 | Eigen::Vector2d cam2Img ( const Eigen::Vector3d& ptc );
38 | void undistortKeyPoints ( const std::vector< cv::KeyPoint >& dist_kps, std::vector< cv::KeyPoint >& undist_kps );
39 | bool projectWithCovariance(const Sophus::SE3& Trc, const Sophus::SE3& T_w_rr, const Sophus::SE2& T_rr_rc, const Eigen::Matrix3d& cov_o, const Eigen::Vector3d& pw, const double& simga_p, Eigen::Vector2d& u, Eigen::Matrix2d& cov_u);
40 | bool projectWorldPoint2Img(const Sophus::SE3& Trc, const Sophus::SE3& Twr, const Eigen::Vector3d& pw, Eigen::Vector2d& u);
41 |
42 | inline bool isInFrame ( const Eigen::Vector2d & obs, int boundary=0 ) const {
43 | if ( obs[0]>=boundary && obs[0]=boundary && obs[1]
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef COMMON_H
18 | #define COMMON_H
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | namespace dre_slam{
27 |
28 | double normAngle ( double angle );
29 | int DescriptorDistance(const cv::Mat &a, const cv::Mat &b);
30 | std::vector CvMat2DescriptorVector(const cv::Mat &Descriptors);
31 | Eigen::Matrix4d AngleAxisTrans2EigenT(cv::Vec3d rvec, cv::Vec3d tvec);
32 | Sophus::SE2 EigenT2Pose2d(Eigen::Matrix4d& T);
33 |
34 | } ; // namespace dre_slam
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/core/include/dre_slam/config.h:
--------------------------------------------------------------------------------
1 | // This file is part of dre_slam - Dynamic RGB-D Encoder SLAM for Differential-Drive Robot.
2 | //
3 | // Copyright (C) 2019 Dongsheng Yang
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef CONFIG_H
18 | #define CONFIG_H
19 |
20 | #include
21 | #include
22 |
23 | namespace dre_slam{
24 |
25 | class Config{
26 | public:
27 | Config(const std::string& cfg_dir);
28 |
29 | public:
30 | /**** Camera ****/
31 | std::string cam_rgb_topic_;
32 | std::string cam_depth_topic_;
33 |
34 | double cam_fx_;
35 | double cam_fy_;
36 | double cam_cx_;
37 | double cam_cy_;
38 | double cam_k1_;
39 | double cam_k2_;
40 | double cam_p1_;
41 | double cam_p2_;
42 | double cam_k3_;
43 | int cam_height_;
44 | int cam_width_;
45 | double cam_depth_factor_; // Depth scale factor.
46 | double cam_dmax_; // Max depth value to be used.
47 | double cam_dmin_; // Min depth value to be used.
48 | double cam_fps_; // Camera FPs.
49 |
50 | /**** Robot intrinsic and extrinsic ****/
51 | std::string encoder_topic_;
52 |
53 | double odom_kl_; // left wheel factor
54 | double odom_kr_; // right wheel factor
55 | double odom_b_; // wheel space
56 | double odom_K_; // Noise factor.
57 | Sophus::SE3 Trc_; // Extrinsic parameter. Translation from the camera to the robot.
58 |
59 |
60 | /**** RGB-D Encoder Tracking ****/
61 | /** ORB feature **/
62 | int ret_ft_n_features_; // Number of ORB features per frame.
63 | float ret_ft_scale_factor_ = 1.2;
64 | int ret_ft_n_levels_ = 8;
65 | int ret_ft_init_th_ = 20;
66 | int ret_ft_min_th_ = 7;
67 |
68 | /** Tracking **/
69 | double ret_tk_dist_th_; // Local map search radius.
70 | double ret_tk_angle_th_; // Local map search angle.
71 | double ret_tk_max_local_mpts_ = 4000; // Max mappoints in the local map.
72 | double ret_tk_sigma_p_ = 0.03; // (m)
73 | double ret_tk_db_; // The base threshold for erroneous match discard.
74 | double ret_tk_kd_; // The scale factor of the threshold for erroneous match discard.
75 |
76 | /** Keyframe decision **/
77 | // Condation 1.
78 | double ret_kd_fps_factor_;
79 | // Condation 2:
80 | double ret_kd_dist_th_; // Max distance threshold.
81 | double ret_kd_angle_th_; // Max angle threshold.
82 |
83 |
84 |
85 | /**** Dynamic Pixels Culling ****/
86 | double dpc_ob_scale_up_factor_ = 1.2; // Scale-up factor of the bounding boxes
87 | std::vector dpc_predef_dyn_obj_names_ = {"person", "bicycle", "car", "motorbike", "bird", "cat", "dog", "horse", "cow"}; // Names of the predefined dynamic objects.
88 | int dpc_n_near_kfs_; // Only using nearest dpc_max_nkf_passed_ KFs that are in the local map for dynamic cluster decision.
89 | int dpc_npts_per_cluster_; // Number of points per cluster.
90 | int dpc_n_sel_pts_per_cluster_; // Number of points per cluster to be selected for dynamic cluster decision.
91 | int dpc_search_square_size_; // Size of the square search area.
92 |
93 |
94 | /**** Sparse Mapping ****/
95 | /** Local Mapping **/
96 | int sm_lm_cobv_th_ = 20; // sp_lm_cobv_th_ a visual edge.
97 | int sm_lm_lba_niter = 50; // sp_lm_lba_niter iter.
98 | int sm_lm_window_size_; // local BA window size: sp_lm_window_size_ KFs.
99 |
100 | /** Loop Closure **/
101 | double sm_lc_search_dist_ = 8.0;
102 | double sm_lc_search_angle_ = 2.0;
103 | double sm_lc_loop_edge_weight_ = 90;
104 | double sm_lc_cov_edge_weight_ = 30;
105 | double sm_lc_encoder_edge_weight_ = 60;
106 | int sm_lc_pgop_niter_ = 120; // sp_lc_pgop_niter_ iter.
107 |
108 |
109 | /**** OctoMap Construction ****/
110 | double oc_voxel_size_; // Voxel size of the OctoMap (m).
111 | double oc_submap_size_; // Sub-OctoMap size (KFs)
112 |
113 | /** OctoMap parameters **/
114 | double oc_occ_th_ = 0.61;
115 | double oc_prob_hit_= 0.6;
116 | double oc_prob_miss_ = 0.45;
117 |
118 | }; // class Config
119 |
120 | } // namespace dre_slam
121 |
122 |
123 | #endif // CONFIG_H
--------------------------------------------------------------------------------
/core/include/dre_slam/dre_slam.h:
--------------------------------------------------------------------------------
1 | // This file is part of dre_slam - Dynamic RGB-D Encoder SLAM for Differential-Drive Robot.
2 | //
3 | // Copyright (C) 2019 Dongsheng Yang
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef DRE_SLAM_H
18 | #define DRE_SLAM_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | namespace dre_slam{
32 |
33 | class DRE_SLAM{
34 | public:
35 | DRE_SLAM( ros::NodeHandle& nh, Config* cfg, const std::string& orbvoc_dir, const std::string& yolov3_classes_dir, const std::string& yolov3_model_dir, const std::string& yolov3_weights_dir );
36 |
37 | void addRGBDImage(const cv::Mat& rgb, const cv::Mat& depth, const double& timestamp);
38 | void addEncoder(const double& enc_l, const double& enc_r, const double& timestamp);
39 |
40 | // Save Results
41 | void saveMapPoints(const std::string& dir);
42 | void saveKeyFrames(const std::string& dir);
43 | void saveFrames(const std::string& dir);
44 | void saveOctoMap(const std::string& dir);
45 |
46 | private:
47 | Config* cfg_;
48 | Camera* cam_;
49 |
50 | Map* map_;
51 | Tracking* tracking_;
52 | DynamicPixelCulling* dynamic_pixel_culling_;
53 | LocalMapping* local_mapping_;
54 | LoopClosing* loop_closing_;
55 | SubOctoMapConstruction* sub_octomap_construction_;
56 | OctoMapFusion* octomap_fusion_;
57 | Optimizer* optimizer_;
58 | RosPuber* ros_puber_;
59 |
60 | Vocabulary* orb_voc_;
61 | ObjectDetector* objector_detector_;
62 |
63 | }; // class DRE_SLAM
64 |
65 |
66 | } // namespace dre_slam
67 |
68 |
69 | #endif // DRE_SLAM_H
--------------------------------------------------------------------------------
/core/include/dre_slam/dynamic_pixel_culling.h:
--------------------------------------------------------------------------------
1 | // This file is part of dre_slam - Dynamic RGB-D Encoder SLAM for Differential-Drive Robot.
2 | //
3 | // Copyright (C) 2019 Dongsheng Yang
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef DYNAMIC_PIXEL_CULLING_H
18 | #define DYNAMIC_PIXEL_CULLING_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace dre_slam {
25 |
26 | class DynamicPixelCulling{
27 |
28 | public:
29 | DynamicPixelCulling( LocalMapping* local_mapping, ObjectDetector* object_detector, RosPuber* ros_puber, Map* map, Camera* cam, Config* cfg );
30 | void processing();
31 |
32 | void insertKeyFrame(KeyFrame* kf);
33 | bool checkNewFrame();
34 | KeyFrame* getNewKeyFrame();
35 |
36 | private:
37 | LocalMapping* local_mapping_;
38 | RosPuber* ros_puber_;
39 | Map* map_;
40 | Camera* cam_;
41 | Config* cfg_;
42 |
43 | // thread.
44 | std::mutex mutex_kfs_queue_;
45 | std::queue kfs_queue_;
46 | std::thread* th_dynamic_pixel_culling_;
47 |
48 | DynamicPixelDetector* dynamic_pixel_detector_;
49 |
50 | // Passed KFs
51 | std::queue passed_kfs_queue_;
52 |
53 | }; // class DynamicPixelCulling
54 |
55 | } //namespace dre_slam
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/core/include/dre_slam/dynamic_pixel_detector.h:
--------------------------------------------------------------------------------
1 | // This file is part of dre_slam - Dynamic RGB-D Encoder SLAM for Differential-Drive Robot.
2 | //
3 | // Copyright (C) 2019 Dongsheng Yang
4 | // (Biologically Inspired Mobile Robot Laboratory, Robotics Institute, Beihang University)
5 | //
6 | // dre_slam is free software: you can redistribute it and/or modify it under the
7 | // terms of the GNU General Public License as published by the Free Software
8 | // Foundation, either version 3 of the License, or any later version.
9 | //
10 | // dre_slam is distributed in the hope that it will be useful, but WITHOUT ANY
11 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | #ifndef DYNAMIC_PIXEL_DETECTOR_H
18 | #define DYNAMIC_PIXEL_DETECTOR_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace dre_slam {
26 |
27 | enum PointType{
28 | UNKNOWN,
29 | STATIC,
30 | DYNAMIC
31 | };
32 |
33 | class DynamicPixelDetector{
34 | public:
35 | DynamicPixelDetector( ObjectDetector* object_detector, Map* map, Camera* cam, Config* cfg );
36 |
37 | void removeDynamicPixels( KeyFrame* ckf );
38 |
39 | private:
40 | // detect Objects by YOLOv3
41 | void detectObjects( const cv::Mat& rgb, std::vector