This repository implements the ROS2 version of VINS-MONO, mainly including the following packages:
- camera_model
- feature_tracker
- vins_estimator
- pose_graph
- benchmark_pubilsher
- ar_demo
- config_pkg
NOTE: Since the get_package_share_directory command in ROS2 launch files can only locate packages in the install directory instead of the src directory like ROS1, we create a package called config_pkg to store the config/ and support_files/ folders from VINS-MONO.
- System
- Ubuntu 20.04
- ROS2 foxy
- Libraries
- OpenCV 4.2.0
- Ceres Solver 1.14.0
- Eigen 3.3.7
Clone the repository and colcon build:
cd $(PATH_TO_YOUR_ROS2_WS)/src
git clone https://github.com/dongbo19/VINS-MONO-ROS2.git
cd ..
colcon build
Download EuRoC datasets. However, the datasets are in ROS1 format. To run the code in ROS2, we need to first convert these datasets to ROS2 format. We can use rosbags for this purpose, which can convert ROS built-in messages between ROS1 and ROS2.
All configuration files are in the package, config_pkg, so in launch files, the path to the EuRoC configuration files is found using get_package_share_directory('config_pkg').
Open three terminals, launch the feature_tracker, vins_estimator, rviz2, and ros2 bag. Take the MH01 for example
ros2 launch feature_tracker vins_feature_tracker.launch.py # for feature tracking and rviz2
ros2 launch vins_estimator euroc.launch.py # for backend optimization and loop closure
ros2 bag play $(PATH_TO_YOUR_DATASET)/MH_01_easy # for ros2 bag
First, take the MH01 for example, modifying the 'sequence_name' in the launch file: benchmark_publisher/launch/benchmark_publisher.launch.py
sequence_name_arg = DeclareLaunchArgument(
'sequence_name',
default_value='MH_01_easy',
description='Sequence name for the benchmark'
)
sequence_name = LaunchConfiguration('sequence_name')
PS: After modifying the launch file, don't forget to run colcon build for this package again.
Then, open four terminals, launch the feature_tracker, vins_estimator, benchmark_mark, rviz2, and ros2 bag.
ros2 launch feature_tracker vins_feature_tracker.launch.py # for feature tracking and rviz2
ros2 launch vins_estimator euroc.launch.py # for backend optimization and loop closure
ros2 launch benchmark_publisher benchmark_publisher.launch.py # for benchmark
ros2 bag play $(PATH_TO_YOUR_DATASET)/MH_01_easy # for ros2 bag
Download the bag file.
Then open two terminals
ros2 launch ar_demo 3dm_bag.launch.py # for featuer tracking, backend optimization, ar demo and rviz2.
ros2 bag play $(PATH_TO_YOUR_DATASET)/ar_box # for ros2 bag
If you need to run your own collected datasets, please add your configuration files to the config_pkg/config directory, and then modify the config_path in the launch files mentioned above to find your configuration file:
config_path = PathJoinSubstitution([
config_pkg_path,
'config/$(YOUR_YAML_FILE)'
])
PS: After modifying the launch files or config files, don't forget to run colcon build for those packages again.
We use ros1 version of VINS MONO, ceres solver for non-linear optimization, DBoW2 for loop detection, and a generic camera model. Also, we referred to parts of the implementations from VINS-FUSION-ROS2 and vins-mono-ros2.
The source code is released under GPLv3 license.