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

Load non-overlapping maps #380

Merged
merged 3 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 11 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,37 @@ jobs:
- name: SLAM test (monocular) with EuRoC MAV dataset (MH_01)
run: |
cd build
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_01 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db MH_01_mono.msg
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_01 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db-out MH_01_mono.msg
mv frame_trajectory.txt ../artifact/frame_trajectory_MH_01_mono_slam.txt
mv track_times.txt ../artifact/track_times_MH_01_mono_slam.txt
- name: SLAM test (stereo) with EuRoC MAV dataset (MH_01)
run: |
cd build
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_01 -c ../example/euroc/EuRoC_stereo.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db MH_01_stereo.msg
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_01 -c ../example/euroc/EuRoC_stereo.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db-out MH_01_stereo.msg
mv frame_trajectory.txt ../artifact/frame_trajectory_MH_01_stereo_slam.txt
mv track_times.txt ../artifact/track_times_MH_01_stereo_slam.txt
- name: Localization test (monocular) with EuRoC MAV dataset (MH_01)
run: |
cd build
./run_euroc_slam --load-map --disable-mapping -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_01 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db MH_01_mono.msg
./run_euroc_slam --disable-mapping -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_01 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db-in MH_01_mono.msg
mv frame_trajectory.txt ../artifact/frame_trajectory_MH_01_mono_localization.txt
mv track_times.txt ../artifact/track_times_MH_01_mono_localization.txt
- name: SLAM test (monocular) with EuRoC MAV dataset (MH_04)
run: |
cd build
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_04 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db MH_04_mono.msg
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_04 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db-out MH_04_mono.msg
mv frame_trajectory.txt ../artifact/frame_trajectory_MH_04_mono_slam.txt
mv track_times.txt ../artifact/track_times_MH_04_mono_slam.txt
- name: SLAM test (stereo) with EuRoC MAV dataset (MH_04)
run: |
cd build
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_04 -c ../example/euroc/EuRoC_stereo.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db MH_04_stereo.msg
./run_euroc_slam -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_04 -c ../example/euroc/EuRoC_stereo.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db-out MH_04_stereo.msg
mv frame_trajectory.txt ../artifact/frame_trajectory_MH_04_stereo_slam.txt
mv track_times.txt ../artifact/track_times_MH_04_stereo_slam.txt
- name: Localization test (monocular) with EuRoC MAV dataset (MH_04)
run: |
cd build
./run_euroc_slam --load-map --disable-mapping -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_04 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db MH_04_mono.msg
./run_euroc_slam --disable-mapping -v /datasets/orb_vocab/orb_vocab.fbow -d /datasets/EuRoC/MH_04 -c ../example/euroc/EuRoC_mono.yaml --frame-skip 2 --no-sleep --log-level=debug --eval-log-dir . --map-db-in MH_04_mono.msg
mv frame_trajectory.txt ../artifact/frame_trajectory_MH_04_mono_localization.txt
mv track_times.txt ../artifact/track_times_MH_04_mono_localization.txt
- name: download openvslam_test_dataset
Expand All @@ -163,19 +163,19 @@ jobs:
- name: SLAM test with equirectangular dataset (1)
run: |
cd build
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ../openvslam_test_dataset/1/equirectangular/video.mp4 -c ../equirectangular.yaml --no-sleep --log-level=debug --eval-log-dir . --map-db equirectangular_map.msg -t 0.0
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ../openvslam_test_dataset/1/equirectangular/video.mp4 -c ../equirectangular.yaml --no-sleep --log-level=debug --eval-log-dir . --map-db-out equirectangular_map.msg -t 0.0
mv frame_trajectory.txt ../artifact/frame_trajectory_equirectangular_1.txt
mv track_times.txt ../artifact/track_times_equirectangular_1.txt
- name: SLAM test with equirectangular dataset (2)
run: |
cd build
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ../openvslam_test_dataset/2/equirectangular/video.mp4 -c ../equirectangular.yaml --no-sleep --log-level=debug --eval-log-dir . --map-db equirectangular_map.msg -t 0.0
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ../openvslam_test_dataset/2/equirectangular/video.mp4 -c ../equirectangular.yaml --no-sleep --log-level=debug --eval-log-dir . --map-db-out equirectangular_map.msg -t 0.0
mv frame_trajectory.txt ../artifact/frame_trajectory_equirectangular_2.txt
mv track_times.txt ../artifact/track_times_equirectangular_2.txt
- name: SLAM test with equirectangular dataset (3)
run: |
cd build
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ../openvslam_test_dataset/3/equirectangular/video.mp4 -c ../equirectangular.yaml --no-sleep --log-level=debug --eval-log-dir . --map-db equirectangular_map.msg -t 0.0
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ../openvslam_test_dataset/3/equirectangular/video.mp4 -c ../equirectangular.yaml --no-sleep --log-level=debug --eval-log-dir . --map-db-out equirectangular_map.msg -t 0.0
mv frame_trajectory.txt ../artifact/frame_trajectory_equirectangular_3.txt
mv track_times.txt ../artifact/track_times_equirectangular_3.txt
- name: Evaluation
Expand Down Expand Up @@ -256,11 +256,11 @@ jobs:
- name: mapping test with the tutorial
run: |
cd build
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ./video_for_ci_1/video.mp4 -c ../example/aist/equirectangular.yaml --frame-skip 3 --no-sleep --log-level=debug --eval-log-dir . --map-db map.msg
./run_video_slam -v /datasets/orb_vocab/orb_vocab.fbow -m ./video_for_ci_1/video.mp4 -c ../example/aist/equirectangular.yaml --frame-skip 3 --no-sleep --log-level=debug --eval-log-dir . --map-db-out map.msg
- name: localization test with the tutorial
run: |
cd build
./run_video_slam --load-map --disable-mapping -v /datasets/orb_vocab/orb_vocab.fbow -m ./video_for_ci_1/video.mp4 -c ../example/aist/equirectangular.yaml --frame-skip 3 --no-sleep --log-level=debug --eval-log-dir . --map-db map.msg
./run_video_slam --disable-mapping -v /datasets/orb_vocab/orb_vocab.fbow -m ./video_for_ci_1/video.mp4 -c ../example/aist/equirectangular.yaml --frame-skip 3 --no-sleep --log-level=debug --eval-log-dir . --map-db-in map.msg

rosdep_foxy:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "3rd/tinycolormap"]
path = 3rd/tinycolormap
url = https://github.com/yuki-koyama/tinycolormap.git
[submodule "3rd/filesystem"]
path = 3rd/filesystem
url = https://github.com/gulrak/filesystem
1 change: 1 addition & 0 deletions 3rd/filesystem
Submodule filesystem added at cd6805
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Feedbacks, feature requests, and contribution are welcome!

The following files are derived from third-party libraries.

- `./3rd/filesystem` : [gulrak/filesystem](https://github.com/gulrak/filesystem) (MIT license)
- `./3rd/json` : [nlohmann/json \[v3.6.1\]](https://github.com/nlohmann/json) (MIT license)
- `./3rd/popl` : [badaix/popl \[v1.2.0\]](https://github.com/badaix/popl) (MIT license)
- `./3rd/spdlog` : [gabime/spdlog \[v1.3.1\]](https://github.com/gabime/spdlog) (MIT license)
Expand Down
6 changes: 5 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ----- Find dependencies -----

# filesystem
set(filesystem_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/3rd/filesystem/include)

# popl
set(popl_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/3rd/popl/include)

Expand Down Expand Up @@ -96,9 +99,10 @@ foreach(EXECUTABLE_TARGET IN LISTS EXECUTABLE_TARGETS)
opencv_imgcodecs
opencv_videoio)

# include popl and spdlog headers
# include 3rd party library headers
target_include_directories(${EXECUTABLE_TARGET}
PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/popl/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/filesystem/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/3rd/spdlog/include>)
endforeach()
26 changes: 19 additions & 7 deletions example/run_camera_slam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <spdlog/spdlog.h>
#include <popl.hpp>

#include <ghc/filesystem.hpp>
namespace fs = ghc::filesystem;

#ifdef USE_STACK_TRACE_LOGGER
#include <backward.hpp>
#endif
Expand Down Expand Up @@ -234,9 +237,9 @@ int main(int argc, char* argv[]) {
auto config_file_path = op.add<popl::Value<std::string>>("c", "config", "config file path");
auto mask_img_path = op.add<popl::Value<std::string>>("", "mask", "mask image path", "");
auto scale = op.add<popl::Value<float>>("s", "scale", "scaling ratio of images", 1.0);
auto map_db_path = op.add<popl::Value<std::string>>("p", "map-db", "store a map database at this path after slam", "");
auto map_db_path_in = op.add<popl::Value<std::string>>("i", "map-db-in", "load a map from this path", "");
auto map_db_path_out = op.add<popl::Value<std::string>>("o", "map-db-out", "store a map database at this path after slam", "");
auto log_level = op.add<popl::Value<std::string>>("", "log-level", "log level", "info");
auto load_map = op.add<popl::Switch>("", "load-map", "load a map database");
auto disable_mapping = op.add<popl::Switch>("", "disable-mapping", "disable mapping");
try {
op.parse(argc, argv);
Expand Down Expand Up @@ -289,10 +292,19 @@ int main(int argc, char* argv[]) {
// build a slam system
stella_vslam::system slam(cfg, vocab_file_path->value());
bool need_initialize = true;
if (load_map->is_set()) {
if (map_db_path_in->is_set()) {
need_initialize = false;
// load the prebuilt map
slam.load_map_database(map_db_path->value());
const auto path = fs::path(map_db_path_in->value());
if (path.extension() == ".yaml") {
YAML::Node node = YAML::LoadFile(path);
for (const auto& map_path : node["maps"].as<std::vector<std::string>>()) {
slam.load_map_database(path.parent_path() / map_path);
}
}
else {
// load the prebuilt map
slam.load_map_database(path);
}
}
slam.startup(need_initialize);
if (disable_mapping->is_set()) {
Expand All @@ -306,15 +318,15 @@ int main(int argc, char* argv[]) {
cam_num->value(),
mask_img_path->value(),
scale->value(),
map_db_path->value());
map_db_path_out->value());
}
else if (slam.get_camera()->setup_type_ == stella_vslam::camera::setup_type_t::Stereo) {
stereo_tracking(slam,
cfg,
cam_num->value(),
mask_img_path->value(),
scale->value(),
map_db_path->value());
map_db_path_out->value());
}
else {
throw std::runtime_error("Invalid setup type: " + slam.get_camera()->get_setup_type_string());
Expand Down
26 changes: 19 additions & 7 deletions example/run_euroc_slam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <spdlog/spdlog.h>
#include <popl.hpp>

#include <ghc/filesystem.hpp>
namespace fs = ghc::filesystem;

#ifdef USE_STACK_TRACE_LOGGER
#include <backward.hpp>
#endif
Expand Down Expand Up @@ -320,8 +323,8 @@ int main(int argc, char* argv[]) {
auto auto_term = op.add<popl::Switch>("", "auto-term", "automatically terminate the viewer");
auto log_level = op.add<popl::Value<std::string>>("", "log-level", "log level", "info");
auto eval_log_dir = op.add<popl::Value<std::string>>("", "eval-log-dir", "store trajectory and tracking times at this path (Specify the directory where it exists.)", "");
auto map_db_path = op.add<popl::Value<std::string>>("p", "map-db", "store a map database at this path after slam", "");
auto load_map = op.add<popl::Switch>("", "load-map", "load a map database");
auto map_db_path_in = op.add<popl::Value<std::string>>("i", "map-db-in", "load a map from this path", "");
auto map_db_path_out = op.add<popl::Value<std::string>>("o", "map-db-out", "store a map database at this path after slam", "");
auto disable_mapping = op.add<popl::Switch>("", "disable-mapping", "disable mapping");

auto equal_hist = op.add<popl::Switch>("", "equal-hist", "apply histogram equalization");
Expand Down Expand Up @@ -376,10 +379,19 @@ int main(int argc, char* argv[]) {
// build a slam system
stella_vslam::system slam(cfg, vocab_file_path->value());
bool need_initialize = true;
if (load_map->is_set()) {
if (map_db_path_in->is_set()) {
need_initialize = false;
// load the prebuilt map
slam.load_map_database(map_db_path->value());
const auto path = fs::path(map_db_path_in->value());
if (path.extension() == ".yaml") {
YAML::Node node = YAML::LoadFile(path);
for (const auto& map_path : node["maps"].as<std::vector<std::string>>()) {
slam.load_map_database(path.parent_path() / map_path);
}
}
else {
// load the prebuilt map
slam.load_map_database(path);
}
}
slam.startup(need_initialize);
if (disable_mapping->is_set()) {
Expand All @@ -396,7 +408,7 @@ int main(int argc, char* argv[]) {
wait_loop_ba->is_set(),
auto_term->is_set(),
eval_log_dir->value(),
map_db_path->value(),
map_db_path_out->value(),
equal_hist->is_set());
}
else if (slam.get_camera()->setup_type_ == stella_vslam::camera::setup_type_t::Stereo) {
Expand All @@ -408,7 +420,7 @@ int main(int argc, char* argv[]) {
wait_loop_ba->is_set(),
auto_term->is_set(),
eval_log_dir->value(),
map_db_path->value(),
map_db_path_out->value(),
equal_hist->is_set());
}
else {
Expand Down
24 changes: 18 additions & 6 deletions example/run_image_slam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <spdlog/spdlog.h>
#include <popl.hpp>

#include <ghc/filesystem.hpp>
namespace fs = ghc::filesystem;

#ifdef USE_STACK_TRACE_LOGGER
#include <backward.hpp>
#endif
Expand Down Expand Up @@ -174,8 +177,8 @@ int main(int argc, char* argv[]) {
auto auto_term = op.add<popl::Switch>("", "auto-term", "automatically terminate the viewer");
auto log_level = op.add<popl::Value<std::string>>("", "log-level", "log level", "info");
auto eval_log_dir = op.add<popl::Value<std::string>>("", "eval-log-dir", "store trajectory and tracking times at this path (Specify the directory where it exists.)", "");
auto map_db_path = op.add<popl::Value<std::string>>("p", "map-db", "store a map database at this path after slam", "");
auto load_map = op.add<popl::Switch>("", "load-map", "load a map database");
auto map_db_path_in = op.add<popl::Value<std::string>>("i", "map-db-in", "load a map from this path", "");
auto map_db_path_out = op.add<popl::Value<std::string>>("o", "map-db-out", "store a map database at this path after slam", "");
auto disable_mapping = op.add<popl::Switch>("", "disable-mapping", "disable mapping");
auto start_timestamp = op.add<popl::Value<double>>("t", "start-timestamp", "timestamp of the start of the video capture");
try {
Expand Down Expand Up @@ -244,10 +247,19 @@ int main(int argc, char* argv[]) {
// build a slam system
stella_vslam::system slam(cfg, vocab_file_path->value());
bool need_initialize = true;
if (load_map->is_set()) {
if (map_db_path_in->is_set()) {
need_initialize = false;
// load the prebuilt map
slam.load_map_database(map_db_path->value());
const auto path = fs::path(map_db_path_in->value());
if (path.extension() == ".yaml") {
YAML::Node node = YAML::LoadFile(path);
for (const auto& map_path : node["maps"].as<std::vector<std::string>>()) {
slam.load_map_database(path.parent_path() / map_path);
}
}
else {
// load the prebuilt map
slam.load_map_database(path);
}
}
slam.startup(need_initialize);
if (disable_mapping->is_set()) {
Expand All @@ -265,7 +277,7 @@ int main(int argc, char* argv[]) {
wait_loop_ba->is_set(),
auto_term->is_set(),
eval_log_dir->value(),
map_db_path->value(),
map_db_path_out->value(),
timestamp);
}
else {
Expand Down
Loading