Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dense map #147

Open
wants to merge 105 commits into
base: dense_map
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
bd2efde
Ignore the meta files from CLion
lennarthaller Feb 9, 2019
cfb82f6
Fix using an int variable as a bool
lennarthaller Feb 9, 2019
3c6c96e
Fix the C++11 compiler warning
lennarthaller Feb 9, 2019
a76e046
Add the dynamic_reconfigure package as a dependency; Add a sample par…
lennarthaller Feb 10, 2019
e9f8de2
Fix the Thirdparty folder location
lennarthaller Feb 10, 2019
467c188
Adjusted the CMakeList for dynamic_reconfigure; Updated the dynamic_r…
lennarthaller Feb 12, 2019
ab2b5d9
Moved dynamic parameters to dynamic_reconfigure
lennarthaller Feb 12, 2019
1b700ef
Implement dynamic_reconfigure
lennarthaller Feb 12, 2019
1670c7c
Noted the possibility to use rqt_reconfigure and the three types of p…
lennarthaller Feb 12, 2019
25213fd
Merge branch 'dynamic_reconfigure'
lennarthaller Feb 12, 2019
bc67684
Add config and launch files for the d435 camera; rename the files for…
lennarthaller Feb 6, 2019
0155e5e
New calibration parameters for the D435
lennarthaller Feb 7, 2019
8bcc43e
Now the new config files for the D435 are actually being used
lennarthaller Feb 7, 2019
1c739ca
New parameters for the D435 again, this time from the camera itself
lennarthaller Feb 9, 2019
4c5c56a
Adjusted the depth map threshold for the d435_rgbd
lennarthaller Feb 13, 2019
5037117
Fixed the README file
lennarthaller Feb 13, 2019
963e964
Due to issue #5 add the c++11 compiler option again
lennarthaller Feb 15, 2019
399e75b
Only compile C++ files with the C++11 flag not C files - fixes the wa…
lennarthaller Feb 15, 2019
0903bfa
modify transformation matrix of Node::TransformFromMat()
saoto28 Mar 17, 2019
d33a010
modify transformation matrix of Node::TransformFromMat()
saoto28 Mar 17, 2019
62a40b2
Merge pull request #15 from saoto28/dev
lennarthaller Mar 18, 2019
303de0c
Remove the camera name from the node name
lennarthaller Feb 15, 2019
a937165
Adjsut the individual depth thresholds for the RGBD cams
lennarthaller Mar 18, 2019
35b7f05
Fix variable naming
lennarthaller Mar 18, 2019
4368278
Add an overview on how to use different cameras
lennarthaller Mar 18, 2019
5ab9c0b
Enable the possibility to configurer the minimal number of observatio…
lennarthaller Mar 18, 2019
9aed4bf
Add explanation for the new min_observation param
lennarthaller Mar 18, 2019
664c6cd
Add support for MyntEye S camera
thien94 Apr 8, 2019
9fe87d8
Merge pull request #17 from hoangthien94/mynteye_s_camera
lennarthaller Apr 8, 2019
c070d10
Add PoseStamped publisher
thien94 Apr 9, 2019
007c4db
Add param to enable/disable publishing pose
thien94 Apr 9, 2019
a0c43c8
Merge pull request #18 from hoangthien94/pose_publisher
lennarthaller Apr 9, 2019
d17b87f
Add the cmake-build-debug folder to the .gitignore
lennarthaller Apr 9, 2019
9b8661e
Make the installation of dependencies more clear; Add a note for the …
lennarthaller Apr 9, 2019
6da6e28
Use the num_channels for the payload too
lennarthaller Mar 19, 2019
a4211fb
Give the StereoNode class owenership of the subscribers and sync
lennarthaller Jul 15, 2019
2c86678
add save and load feature
Jun 24, 2019
975319a
correction of launch file
Jun 24, 2019
0039654
Implement the save load feature for all three SLAM types; DDreconfigu…
lennarthaller Jul 8, 2019
4d9a63b
Fix the crash; Adjust all the launch file
lennarthaller Jul 15, 2019
cbefb67
Map save is now offered as a service instead as a parameter; Adjusted…
lennarthaller Jul 15, 2019
f55ff3b
Add documentation for the save and load feature
lennarthaller Jul 15, 2019
0654b85
Fix Headline 4 in the README
lennarthaller Jul 15, 2019
6cf6dac
Fix boldness of service names in the README
lennarthaller Jul 15, 2019
8e626c2
Add link to the PR the save-load feature is based on
lennarthaller Jul 15, 2019
9d1973f
Fix misspelling of variable
lennarthaller Jul 16, 2019
8728603
Implement name specific map_saving
lennarthaller Jul 16, 2019
d3c2d44
Fix two segfaults; Save and load works now for large maps!
lennarthaller Jul 25, 2019
c67a6c4
Make the stereo node compile
lennarthaller Jul 25, 2019
b507ce8
Fix a seqfault which occured when loading large maps
lennarthaller Jul 25, 2019
e6bb3b6
Update README
lennarthaller Jul 26, 2019
6f64c25
Update README
lennarthaller Jul 26, 2019
640569a
Add docker file
lennarthaller Jul 31, 2019
ca869c0
Fix the kinetic dockerfile, add a melodic dockerfile and move them in…
lennarthaller Jul 31, 2019
8abda13
Delete the melodic Dockerfile
lennarthaller Jul 31, 2019
339254f
Add some remarks about Docker to the README
lennarthaller Aug 1, 2019
e978a2c
Add required package for the realsense to the docker file
lennarthaller Aug 4, 2019
36ae984
Corrected typedef so that map value_type and allocator are the same (…
craymichael Jun 9, 2018
1fe5d70
Merge pull request #50 from jessisar/master
lennarthaller Nov 27, 2019
e6cc14a
fix maps cannot be saved multiple times
CodesHub Nov 28, 2019
c9e4bf4
Merge pull request #51 from CodesHub/master
lennarthaller Nov 28, 2019
9e7dc35
Fix Camera.bf for D435
lennarthaller Nov 29, 2019
95c9e23
Add melodic docker file
lennarthaller Nov 29, 2019
c47711e
added ability to turn off tf publishing
Mar 27, 2020
94ed988
building on jetson nano
aldenparker Mar 27, 2020
a73bb69
Made more ROS friendly and cleaned up the interface. Still need to im…
Mar 27, 2020
241d576
small refinements
Mar 28, 2020
84aac90
Moved ROS stuff out of ORB library and added struct to move parameter…
Apr 10, 2020
e0e18ae
Add the parameters to all launch files; make cam_info optional
lennarthaller Apr 10, 2020
2850189
Note in the README that paramters are loaded from launch file
lennarthaller Apr 10, 2020
b397a17
Fix bug where params required for rgbd or stereo would load if the ca…
lennarthaller Apr 11, 2020
8fd3932
Add note about the possibility to use cam_info
lennarthaller Apr 11, 2020
1a38bd1
Fix cam param load logic
lennarthaller Apr 11, 2020
6efc879
Removed unused 'settings_file' param
tim-fan Apr 13, 2020
9da9035
Merge pull request #64 from tim-fan/master
lennarthaller Apr 13, 2020
d79e54f
Fix lookup of camera_info
tim-fan Apr 13, 2020
5a8f5b7
show resolved camera info topic when loading orb params
tim-fan Apr 16, 2020
9207b77
Merge branch 'tim-fan-master'
lennarthaller Apr 22, 2020
a98e183
added TUM2 launch and config file
Aug 13, 2020
6ac1abd
Merge pull request #79 from LXYYY/feature/tum_rgbd
lennarthaller Aug 13, 2020
a7b1206
Publish GBA status
Oct 7, 2020
7282412
Update to use tf2
Jan 8, 2021
f8b5bd2
Add method for transforming map tf and pose estimate to a target fram…
Jan 8, 2021
e96990e
Add ZED2 launch file
Jan 8, 2021
0f1ddc7
Add explanation about obtaining camera calibration data
Jan 8, 2021
09b82ab
Merge pull request #97 from aseligmann/tf2-branch
lennarthaller Jan 8, 2021
93b5fa7
Add ZED 2 (stereo) to supported cameras section
aseligmann Jan 9, 2021
ae67fff
Add target_frame_id parameter description
aseligmann Jan 9, 2021
e140d57
Merge pull request #98 from aseligmann/ZED2-branch
lennarthaller Jan 9, 2021
0357e9e
Update orb_slam2_zed2_stereo.launch
JJBUT Jan 11, 2021
99f81af
Merge pull request #100 from JackBorer/patch-1
lennarthaller Jan 12, 2021
02ab5b8
Merge pull request #103 from nobleo/feature/publish_gba_status
lennarthaller Mar 6, 2021
1819f3c
Fixed bug (missing tf2-geometry) in Dockerfile and added setup.bash s…
samlaf Mar 23, 2021
d62942e
Fix typo
PauloRodriguesJr Apr 4, 2021
537f7d8
Merge pull request #111 from PauloRodriguesJr/master
lennarthaller Apr 19, 2021
403c91a
Merge pull request #110 from samlaf/master
lennarthaller Apr 19, 2021
544f518
Add dependency definition for 'tf2_geometry_msgs' and 'tf2_ros'
caioaamaral May 11, 2021
e933256
Merge pull request #116 from caioaamaral/add/missing-deps
lennarthaller Aug 15, 2021
a2da377
Making it compile on my Ubuntu 20 machine with C++14
archie1983 Aug 10, 2023
b537078
One more compilation issue - RGBDNode had ambiguous Node that came fr…
archie1983 Aug 10, 2023
2e41110
Fixed the compilation/linking problems for mt_task_queue. Comments ab…
archie1983 Aug 10, 2023
6c04286
Merging in latest updates from master
archie1983 Aug 10, 2023
4935a0b
Fixing threading problems.
archie1983 Aug 14, 2023
c8f7539
Adding debug statements
archie1983 Aug 14, 2023
a6e4104
Changed the launch file for the correct topic
archie1983 Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CMakeLists.txt.user
.idea/
cmake-build-debug
KeyFrameTrajectory.txt
Thirdparty/DBoW2/build/
Thirdparty/DBoW2/lib/
Expand Down
66 changes: 53 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,58 @@ IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()

#MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})

# Check for c++11 support
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
IF(COMPILER_SUPPORTS_CXX11)
add_compile_options(-std=c++11)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
IF(COMPILER_SUPPORTS_CXX14)
#add_compile_options(-std=c++14)
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
ELSE()
MESSAGE(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
MESSAGE(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
ENDIF()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/orb_slam2/cmake_modules)

find_package (catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
cv_bridge
image_transport
tf
tf2_geometry_msgs
tf2_ros
sensor_msgs
pcl_conversions
pcl_ros
dynamic_reconfigure
message_generation
)

find_package(OpenCV 3.0 QUIET)
find_package(OpenCV 4.0 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
find_package(OpenCV 3.0 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
endif()
endif()
endif()

find_package(Eigen3 3.1.0 REQUIRED)

set (DYNAMIC_RECONFIGURE_PATH ros/config/dynamic_reconfigure.cfg)
execute_process(COMMAND chmod a+x ${DYNAMIC_RECONFIGURE_PATH}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE cmd_result
OUTPUT_VARIABLE cmd_ver)
message(STATUS "Chmod a+x the dynamic_reconfigure file")

generate_dynamic_reconfigure_options(
${DYNAMIC_RECONFIGURE_PATH}
)

set(LIBS_ORBSLAM
${OpenCV_LIBS}
${EIGEN3_LIBS}
Expand All @@ -53,8 +71,18 @@ ${OpenCV_LIBS}
${catkin_LIBRARIES}
)

add_service_files(
FILES
SaveMap.srv
)

generate_messages(
DEPENDENCIES
std_msgs
)

catkin_package (
CATKIN_DEPENDS roscpp std_msgs cv_bridge image_transport tf sensor_msgs
CATKIN_DEPENDS roscpp rospy std_msgs cv_bridge image_transport tf sensor_msgs dynamic_reconfigure message_runtime
LIBRARIES {PROJECT_NAME} libDBoW2 libg2o libmt_task_queue
)

Expand Down Expand Up @@ -98,11 +126,19 @@ target_link_libraries(${PROJECT_NAME}
${LIBS_ORBSLAM}
)

# map serialization addition - library boost serialization
message(STATUS "Compile With map save/load function")
find_library(BOOST_SERIALIZATION boost_serialization)
if (NOT BOOST_SERIALIZATION)
message(FATAL_ERROR "Can't find libboost_serialization")
endif()
target_link_libraries(${PROJECT_NAME} ${BOOST_SERIALIZATION})

add_executable (${PROJECT_NAME}_mono
ros/src/MonoNode.cc
ros/src/Node.cc
)
add_dependencies (${PROJECT_NAME}_mono ${PROJECT_NAME})
add_dependencies (${PROJECT_NAME}_mono ${PROJECT_NAME} ${PROJECT_NAME}_gencfg)

target_link_libraries(${PROJECT_NAME}_mono
${LIBS_ROS}
Expand All @@ -112,7 +148,7 @@ add_executable (${PROJECT_NAME}_stereo
ros/src/StereoNode.cc
ros/src/Node.cc
)
add_dependencies (${PROJECT_NAME}_stereo ${PROJECT_NAME})
add_dependencies (${PROJECT_NAME}_stereo ${PROJECT_NAME} ${PROJECT_NAME}_gencfg)

target_link_libraries(${PROJECT_NAME}_stereo
${LIBS_ROS}
Expand All @@ -122,7 +158,7 @@ add_executable (${PROJECT_NAME}_rgbd
ros/src/RGBDNode.cc
ros/src/Node.cc
)
add_dependencies (${PROJECT_NAME}_rgbd ${PROJECT_NAME})
add_dependencies (${PROJECT_NAME}_rgbd ${PROJECT_NAME} ${PROJECT_NAME}_gencfg)

target_link_libraries(${PROJECT_NAME}_rgbd
${LIBS_ROS}
Expand All @@ -144,6 +180,10 @@ install(DIRECTORY ros/launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/ros/launch
)

install(DIRECTORY ros/config/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/ros/config
)

install(DIRECTORY orb_slam2/config/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/orb_slam2/config
)
Expand Down
152 changes: 116 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
The original implementation can be found [here](https://github.com/raulmur/ORB_SLAM2.git).

# ORB-SLAM2 ROS node
This is the ROS implementation of the ORB-SLAM2 real-time SLAM library for **Monocular**, **Stereo** and **RGB-D** cameras that computes the camera trajectory and a sparse 3D reconstruction (in the stereo and RGB-D case with true scale). It is able to detect loops and relocalize the camera in real time. This implementation removes the Pangolin dependency, and the original viewer. All data I/O is handled via ROS topics. For vizualization you can use RViz. This repository is maintained by [Lennart Haller](http://lennarthaller.de) on behalf of [appliedAI](http://appliedai.de).
This is the ROS implementation of the ORB-SLAM2 real-time SLAM library for **Monocular**, **Stereo** and **RGB-D** cameras that computes the camera trajectory and a sparse 3D reconstruction (in the stereo and RGB-D case with true scale). It is able to detect loops and relocalize the camera in real time. This implementation removes the Pangolin dependency, and the original viewer. All data I/O is handled via ROS topics. For visualization you can use RViz. This repository is maintained by [Lennart Haller](http://lennarthaller.de) on behalf of [appliedAI](http://appliedai.de).
## Features
- Full ROS compatibility
- Supports a lot of cameras out of the box, such as the Intel RealSense family. See the run section for a list
- Data I/O via ROS topics
- Parameters can be set via the ROS parameters server during runtime
- Parameters can be set with the rqt_reconfigure gui during runtime
- Very quick startup through considerably sped up vocab file loading
- Full Map save and load functionality based on [this PR](https://github.com/raulmur/ORB_SLAM2/pull/381).
- Loading of all parameters via launch file
- Supports loading cam parameters from cam_info topic

### Related Publications:
[Monocular] Raúl Mur-Artal, J. M. M. Montiel and Juan D. Tardós. **ORB-SLAM: A Versatile and Accurate Monocular SLAM System**. *IEEE Transactions on Robotics,* vol. 31, no. 5, pp. 1147-1163, 2015. (**2015 IEEE Transactions on Robotics Best Paper Award**). **[PDF](http://webdiis.unizar.es/~raulmur/MurMontielTardosTRO15.pdf)**.
Expand Down Expand Up @@ -48,83 +52,159 @@ if you use ORB-SLAM2 (Stereo or RGB-D) in an academic work, please cite:
year={2017}
}

# 2. Prerequisites
# 2. Building orb_slam2_ros
We have tested the library in **Ubuntu 16.04** with **ROS Kinetic** and **Ubuntu 18.04** with **ROS Melodic**. A powerful computer (e.g. i7) will ensure real-time performance and provide more stable and accurate results.
A C++11 compiler is needed.

## C++11
We use all kinds of functionalities from C++11.

## OpenCV
We use [OpenCV](http://opencv.org) to manipulate images and features. OpenCV should be installed along with ROS.
## Getting the code
Clone the repository into your catkin workspace:
```
git clone https://github.com/appliedAI-Initiative/orb_slam_2_ros.git
```
## ROS
This ROS node requires catkin_make_isolated or catkin build to build. This package depends on a number of other ROS packages which ship with the default installation of ROS.
If they are not installed use [rosdep](http://wiki.ros.org/rosdep) to install them. In your catkin folder run
```
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src -r -y
```
to install all dependencies for all packages. If you already initialized rosdep you get a warning which you can ignore.

## Eigen3
Required by g2o (see below). Download and install instructions can be found at: http://eigen.tuxfamily.org.
Required by g2o. Download and install instructions can be found [here](http://eigen.tuxfamily.org).
Otherwise Eigen can be installed as a binary with:
```
sudo apt install libeigen3-dev
```
**Required at least 3.1.0**.
**Required at least Eigen 3.1.0**.

## Point Cloud Library (PCL)
We use the [PCL](http://pointclouds.org) to create the dense map. The PCL should come with the full ROS installation. If this is not the case make sure to install it, for example with rosdep.

## DBoW2 and g2o (Included in Thirdparty folder)
We use modified versions of the [DBoW2](https://github.com/dorian3d/DBoW2) library to perform place recognition and [g2o](https://github.com/RainerKuemmerle/g2o) library to perform non-linear optimizations. Both modified libraries (which are BSD) are included in the *Thirdparty* folder.

## ROS / catkin
This ROS node requires catkin_make_isolated or catkin build to build.

# 3. Building the ORB-SLAM2 ROS node
## Getting the code
Clone the repository into your catkin workspace:
```
git clone https://github.com/appliedAI-Initiative/orb_slam_2_ros.git
```
## Building
To build the node run
```
catkin build
```
in your catkin folder.

# 4. Configuration
## Config file
To run the algorithm expects both a vocabulary file (see the paper) and a **config file with the camera- and some hyper parameters**. The vocab file ships with this repository, together with config files for the Intel RealSense r200 camera. If you want to use any other camera you need to adjust the file (you can use one of the provided ones as a template). They are at orb_slam2/config.
# 3. Configuration
## Vocab file
To run the algorithm expects both a vocabulary file (see the paper) which ships with this repository.

## ROS parameters and topics
# Config
The config files for camera calibration and tracking hyper paramters from the original implementation are replaced with ros paramters which get set from a launch file.

## ROS parameters, topics and services
### Parameters
In the launch files which can be found at ros/launch there are different parameters which can be adjusted:
There are three types of parameters right now: static- and dynamic ros parameters and camera settings.
The static parameters are send to the ROS parameter server at startup and are not supposed to change. They are set in the launch files which are located at ros/launch. The parameters are:

- **load_map**: Bool. If set to true, the node will try to load the map provided with map_file at startup.
- **map_file**: String. The name of the file the map is loaded from.
- **voc_file**: String. The location of config vocanulary file mentioned above.
- **publish_pointcloud**: Bool. If the pointcloud containing all key points (the map) should be published.
- **localize_only**: Bool. Toggle from/to only localization. The SLAM will then no longer add no new points to the map.
- **reset_map**: Bool. Set to true to erase the map and start new. After reset the parameter will automatically update back to false.
- **publish_pose**: Bool. If a PoseStamped message should be published. Even if this is false the tf will still be published.
- **pointcloud_frame_id**: String. The Frame id of the Pointcloud/map.
- **camera_frame_id**: String. The Frame id of the camera position.
- **target_frame_id**: String. Map transform and pose estimate will be provided in this frame id if set.
- **load_calibration_from_cam**: Bool. If true, camera calibration is read from a `camera_info` topic. Otherwise it is read from launch file params.

Dynamic parameters can be changed at runtime. Either by updating them directly via the command line or by using [rqt_reconfigure](http://wiki.ros.org/rqt_reconfigure) which is the recommended way.
The parameters are:

- **localize_only**: Bool. Toggle from/to only localization. The SLAM will then no longer add no new points to the map.
- **reset_map**: Bool. Set to true to erase the map and start new. After reset the parameter will automatically update back to false.
- **min_num_kf_in_map**: Int. Number of key frames a map has to have to not get reset after tracking is lost.
- **min_observations_for_ros_map**: Int. Number of minimal observations a key point must have to be published in the point cloud. This doesn't influence the behavior of the SLAM itself at all.

Finally, the intrinsic camera calibration parameters along with some hyperparameters can be found in the specific yaml files in orb_slam2/config.

### Published topics
The following topics are being published and subscribed to by the nodes:
- All nodes publish (given the settings) a **PointCloud2** containing all key points of the map.
- Also all nodes publish (given the settings) a **PoseStamped** with the current pose of the camera frame, or the target frame if `target_frame_id` is set.
- Live **image** from the camera containing the currently found key points and a status text.
- A **tf** from the pointcloud frame id to the camera frame id (the position).
- A **tf** from the pointcloud frame id to the camera frame id (the position), or the target frame if `target_frame_id` is set.

### Subscribed topics
- The mono node subscribes to **/camera/image_raw** for the input image.
- The mono node subscribes to:
- **/camera/image_raw** for the input image
- **/camera/camera_info** for camera calibration (if `load_calibration_from_cam`) is `true`

- The RGBD node subscribes to:
- **/camera/rgb/image_raw** for the RGB image
- **/camera/depth_registered/image_raw** for the depth information
- **/camera/rgb/camera_info** for camera calibration (if `load_calibration_from_cam`) is `true`

- The stereo node subscribes to:
- **image_left/image_color_rect** and
- **image_right/image_color_rect** for corresponding images
- **image_left/camera_info** for camera calibration (if `load_calibration_from_cam`) is `true`

- The RGBD node subscribes to **/camera/rgb/image_raw** for the RGB image and
- **/camera/depth_registered/image_raw** for the depth information.
# 4. Services
All nodes offer the possibility to save the map via the service node_type/save_map.
So the save_map services are:
- **/orb_slam2_rgbd/save_map**
- **/orb_slam2_mono/save_map**
- **/orb_slam2_stereo/save_map**

- The stereo node subscribes to **image_left/image_color_rect** and
- **image_right/image_color_rect** for corresponding images.
The save_map service expects the name of the file the map should be saved at as input.

At the moment, while the save to file takes place, the SLAM is inactive.

# 5. Run
After sourcing your setup bash using
```
source devel/setup.bash
```
you can run the the corresponding nodes with one of the following commands:
## Suported cameras
| Camera | Mono | Stereo | RGBD |
|----------------------|----------------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------|
| Intel RealSense r200 | ``` roslaunch orb_slam2_ros orb_slam2_r200_mono.launch ``` | ``` roslaunch orb_slam2_ros orb_slam2_r200_stereo.launch ``` | ``` roslaunch orb_slam2_ros orb_slam2_r200_rgbd.launch ``` |
| Intel RealSense d435 | ``` roslaunch orb_slam2_ros orb_slam2_d435_mono.launch ``` | - | ``` roslaunch orb_slam2_ros orb_slam2_d435_rgbd.launch ``` |
| Mynteye S | ```roslaunch orb_slam2_ros orb_slam2_mynteye_s_mono.launch ``` | ```roslaunch orb_slam2_ros orb_slam2_mynteye_s_stereo.launch ``` | - |
| Stereolabs ZED 2 | - | ```roslaunch orb_slam2_ros orb_slam2_zed2_stereo.launch ``` | - | | | | |

Use the command from the corresponding cell for your camera to launch orb_slam2_ros with the right parameters for your setup.

# 6. Docker
An easy way is to use orb_slam2_ros with Docker. This repository ships with a Dockerfile based on ROS kinetic.
The container includes orb_slam2_ros as well as the Intel RealSense package for quick testing and data collection.

# 7. FAQ
Here are some answers to frequently asked questions.
### How to save the map
To save the map with a simple command line command run one the commands (matching to your node running):
```
rosservice call /orb_slam2_rgbd/save_map map.bin
rosservice call /orb_slam2_stereo/save_map map.bin
rosservice call /orb_slam2_mono/save_map map.bin
```
You can replace "map.bin" with any file name you want.
The file will be saved at ROS_HOME which is by default ~/.ros

**Note** that you need to source your catkin workspace in your terminal in order for the services to become available.

### Using a new / different camera
You can use this SLAM with almost any mono, stereo or RGBD cam you want.
In order to use this with a different camera you need to supply a set of paramters to the algorithm. They are loaded from a launch file from the ros/launch folder.
1) You need the **camera intrinsics and some configurations**. [Here](https://docs.opencv.org/3.1.0/dc/dbb/tutorial_py_calibration.html) you can read about what the camera calibration parameters mean. Use [this](http://wiki.ros.org/camera_calibration) ros node to obtain them for your camera. If you use a stereo or RGBD cam in addition to the calibration and resolution you also need to adjust three other parameters: Camera.bf, ThDepth and DepthMapFactor.
2) **The ros launch file** which is at ros/launch needs to have the correct topics to subscribe to from the new camera.
**NOTE** If your camera supports this, orb_slam_2_ros can subscribe to the camera_info topic and read the camera calibration parameters from there.

### Problem running the realsense node
The node for the RealSense fails to launch when running
```
roslaunch realsense2_camera rs_rgbd.launch
```
to get the depth stream.
**Solution:**
install the rgbd-launch package with the command (make sure to adjust the ROS distro if needed):
```
roslaunch orb_slam2_ros orb_slam2_mono.launch
roslaunch orb_slam2_ros orb_slam2_stereo.launch
roslaunch orb_slam2_ros orb_slam2_rgbd.launch
sudo apt install ros-melodic-rgbd-launch
```
Loading