Skip to content

Commit c8ba6cf

Browse files
oseiskarpekkaranjkannalaBerconerahtu
committed
HybVIO initial public release
Licensed under GPLv3 Co-authored-by: Pekka Rantalankila <pekka.rantalankila@gmail.com> Co-authored-by: Juho Kannala <juho.kannala@gmail.com> Co-authored-by: Jerry Ylilammi <jerry.ylilammi@gmail.com> Co-authored-by: Esa Rahtu <esa.rahtu@gmail.com> Co-authored-by: Arno Solin <arno.solin@gmail.com>
0 parents  commit c8ba6cf

File tree

140 files changed

+25314
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+25314
-0
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[*.{cpp,hpp,py}]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.sh]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[*.json]
18+
indent_style = space
19+
indent_size = 2
20+
21+
[CMakeLists.txt]
22+
indent_style = space
23+
indent_size = 2

.github/workflows/build-and-test.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and run unit tests
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Install OpenGL libraries (Mesa)
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install -y mesa-common-dev libglfw3-dev
14+
- name: Write git submodule status to file
15+
run: |
16+
git submodule status > .gitSubmoduleStatus
17+
- name: Cache other libs
18+
id: cache_libs
19+
uses: actions/cache@v1
20+
with:
21+
path: 3rdparty/mobile-cv-suite/build
22+
key: mobile-cv-suite-build-${{ hashFiles('.gitSubmoduleStatus') }}
23+
- name: Build dependencies
24+
if: steps.cache_libs.outputs.cache-hit != 'true'
25+
run: |
26+
cd 3rdparty
27+
git submodule update --init --recursive -- mobile-cv-suite
28+
cd mobile-cv-suite
29+
DO_CLEAR=OFF USE_SLAM=OFF BUILD_VISUALIZATIONS=OFF ./scripts/build.sh
30+
cp mobile-cv-suite-config.cmake build/
31+
cp -R jsonl-recorder/Catch2/single_include/catch2 build/
32+
- name: Handle catch2 symlink
33+
run: |
34+
cd test
35+
rm catch2
36+
ln -s ../3rdparty/mobile-cv-suite/build/catch2 .
37+
- name: CMake build
38+
run: |
39+
if [ -f 3rdparty/mobile-cv-suite/build/mobile-cv-suite-config.cmake ]; then cp -f 3rdparty/mobile-cv-suite/build/mobile-cv-suite-config.cmake 3rdparty/mobile-cv-suite/; fi
40+
mkdir target
41+
cd target
42+
CC=clang CXX=clang++ cmake -DUSE_SLAM=OFF -DBUILD_VISUALIZATIONS=OFF ..
43+
make -j4
44+
- name: Run tests
45+
run: |
46+
cd target
47+
./run-tests

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/build
2+
/data
3+
target*
4+
*.mov
5+
*.png
6+
.idea/
7+
cmake-build-debug/
8+
.vscode
9+
.viscid
10+
__pycache__/
11+
*.pyc
12+
.python-version
13+
codegen/output

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "3rdparty/mobile-cv-suite"]
2+
path = 3rdparty/mobile-cv-suite
3+
url = https://github.com/AaltoML/mobile-cv-suite.git
4+
[submodule "src/slam"]
5+
path = src/slam
6+
url = https://github.com/SpectacularAI/SLAM-module.git

3rdparty/mobile-cv-suite

Submodule mobile-cv-suite added at b3f9141

CMakeLists.txt

+192
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
project(hybvio VERSION 1.0.0 DESCRIPTION "HybVIO VIO/SLAM runner")
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -O2")
6+
# allow building a single shared library (adds -fPIC when compiling static libs)
7+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
8+
# Generate `compile_commands.json` for `clang-tidy`.
9+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
10+
11+
option(FIND_BLAS "Force -DEIGEN_USE_BLAS." OFF)
12+
option(MARCH_NATIVE "Enable -march=native." OFF)
13+
if (MARCH_NATIVE)
14+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
15+
endif()
16+
17+
if (NOT CMAKE_BUILD_TYPE)
18+
# TODO: setting this to RelWithDebInfo should be used for optimization flags
19+
# However: that seems to result to crashes for unknown reasons
20+
set(CMAKE_BUILD_TYPE Debug)
21+
endif()
22+
23+
set(BUILD_CLI_TOOLS ON CACHE STRING "Build `main` binaries and tests.")
24+
set(LOGGING_ENABLED ON CACHE STRING "Enable logging")
25+
26+
set(BUILD_WITH_GPU ON CACHE STRING "Build with GPU (OpenGL) support")
27+
28+
set(BUILD_WITH_GLFW ON CACHE STRING "Support headless GPU processing on desktop with GLFW")
29+
set(BUILD_VISUALIZATIONS OFF CACHE STRING "Build Pangolin-based visualizations")
30+
set(LOGGING_LIBS "")
31+
if(BUILD_CLI_TOOLS AND LOGGING_ENABLED)
32+
add_definitions(-DUSE_LOGURU)
33+
endif()
34+
if(LOGGING_ENABLED)
35+
add_definitions(-DLOGGING_ENABLED)
36+
endif()
37+
38+
39+
# Make sure no Eigen LGPL code is used. It's mostly stuff like sparse matrix
40+
# operations that we would not want to use through Eigen in any case
41+
add_definitions("-DEIGEN_MPL2_ONLY")
42+
43+
# Do not auto-parallelize matrix products (mainly affects the Odometry class)
44+
# Note that the odometry module may be faster without this flag, if also using
45+
# OpenMP, but then it may hog 100% CPU (on all cores)
46+
# from time to time, which is not what we're looking for. This may not have
47+
# an effect unless Eigen is configured to use OpenMP
48+
add_definitions("-DEIGEN_DONT_PARALLELIZE")
49+
50+
# Note: try these too for debugging. For example, NaN initialization should
51+
# not affect the results if everything is implemented correctly.
52+
#add_definitions("-DEIGEN_INITIALIZE_MATRICES_BY_NAN")
53+
#add_definitions("-DEIGEN_NO_AUTOMATIC_RESIZING")
54+
55+
if (FIND_BLAS)
56+
# Use Accelerate framework on Mac or system BLAS on Linux for Eigen.
57+
# This may or may not be faster than without BLAS. Similarly to the OpenMP
58+
# stuff in Eigen (disabled with EIGEN_DONT_PARALLELIZE), this can cause
59+
# CPU hogging on multiple-threads and the end result may not be optimal.
60+
find_package(BLAS REQUIRED)
61+
if(BLAS_FOUND)
62+
message(STATUS "using BLAS with Eigen")
63+
add_definitions("-DEIGEN_USE_BLAS")
64+
list(APPEND LIBS "${BLAS_LIBRARIES}") # appends "-framework Accelerate"
65+
endif()
66+
endif()
67+
68+
option(USE_SLAM "Compile with SLAM support" OFF)
69+
set(TARGET_ARCH "host" CACHE STRING "Target architecture")
70+
find_package(mobile-cv-suite REQUIRED PATHS 3rdparty/mobile-cv-suite)
71+
72+
add_subdirectory("codegen")
73+
foreach(X ${generated_sources})
74+
message(STATUS "marking ${X} as a generated source file")
75+
set_source_files_properties(${X} PROPERTIES GENERATED TRUE)
76+
endforeach()
77+
78+
add_library(parameters
79+
codegen/output/parameters.cpp
80+
src/util/util.cpp
81+
src/util/parameter_parser.cpp
82+
codegen/output/cmd_parameters.cpp
83+
src/util/util.cpp
84+
src/util/timer.cpp
85+
src/util/parameter_parser.cpp)
86+
add_dependencies(parameters generated_parameters cmd_generated_parameters)
87+
target_link_libraries(parameters mobile-cv-suite::core)
88+
89+
if (BUILD_WITH_GPU)
90+
add_definitions(-DDAZZLING_GPU_ENABLED)
91+
if (BUILD_WITH_GLFW)
92+
add_definitions(-DDAZZLING_GLFW_ENABLED)
93+
find_package(glfw3 REQUIRED)
94+
list(APPEND LIBS glfw)
95+
endif()
96+
find_package(OpenGL REQUIRED) # can't find GL ES :(
97+
list(APPEND LIBS ${OPENGL_LIBRARIES})
98+
endif()
99+
100+
# This causes the targets in feature-tracking/CMakeList.txt to be available
101+
# here without including the individual source files
102+
add_subdirectory("src/tracker")
103+
104+
if (USE_SLAM)
105+
# add SLAM
106+
add_subdirectory("src/slam")
107+
else()
108+
add_library(slam src/util/slam_noop.cpp)
109+
target_link_libraries(slam mobile-cv-suite::core) # Required for Eigen includes
110+
endif()
111+
112+
# Static library that main program and tests can link to.
113+
add_library(odometry
114+
src/odometry/control.cpp
115+
src/odometry/ekf.cpp
116+
src/odometry/triangulation.cpp
117+
src/odometry/util.cpp
118+
src/odometry/sample_sync.cpp
119+
src/odometry/ekf_state_index.cpp
120+
src/odometry/backend.cpp
121+
src/odometry/output.cpp
122+
src/views/api_visualization_helpers.cpp
123+
src/views/visualization_pose.cpp
124+
src/views/visualization_internals.cpp
125+
src/api/visualizations.cpp
126+
src/api/api.cpp
127+
src/util/util.cpp
128+
src/api/type_convert.cpp
129+
)
130+
131+
target_link_libraries(odometry slam tracker ${LIBS} mobile-cv-suite::core)
132+
target_include_directories(odometry PUBLIC ".")
133+
134+
if(BUILD_CLI_TOOLS)
135+
if (BUILD_VISUALIZATIONS)
136+
add_definitions(-DBUILD_VISUALIZATIONS)
137+
set(VISU_SRCS
138+
src/commandline/visual_update_viewer.cpp
139+
src/commandline/draw_gl.cpp)
140+
set(VISU_LIBS
141+
Threads::Threads
142+
parameters
143+
${LOGGING_LIBS}
144+
mobile-cv-suite::visualization
145+
${OPENGL_LIBRARIES})
146+
else()
147+
set(VISU_SRCS "")
148+
set(VISU_LIBS "")
149+
endif()
150+
if(USE_SLAM)
151+
add_definitions(-DUSE_DBOW2)
152+
add_definitions(-DUSE_SLAM)
153+
154+
set(SLAM_SRCS "")
155+
set(SLAM_LIBS
156+
Threads::Threads
157+
parameters
158+
mobile-cv-suite::slam)
159+
160+
# Select newer OpenGL, see `cmake --help-policy CMP0072`
161+
# cmake_policy(SET CMP0072 NEW) # TODO what CMake version does this require?
162+
163+
find_package(Threads REQUIRED)
164+
else()
165+
set(SLAM_LIBS "")
166+
set(SLAM_SRCS "")
167+
endif()
168+
169+
add_executable(main
170+
src/commandline/command_queue.cpp
171+
src/commandline/input.cpp
172+
src/commandline/input_csv.cpp
173+
src/commandline/input_jsonl.cpp
174+
src/commandline/main.cpp
175+
src/commandline/video_input.cpp
176+
src/commandline/videoutil.cpp
177+
${VISU_SRCS}
178+
${SLAM_SRCS})
179+
target_link_libraries(main PRIVATE odometry parameters ${LIBS} ${VISU_LIBS} ${SLAM_LIBS})
180+
181+
# Put binaries from subdirectories (test) to the target directory.
182+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
183+
184+
# Copy test data to the target directory so that we can simply run the test binary.
185+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test)
186+
187+
# Lets `make test` and `ctest` commands run tests.
188+
enable_testing()
189+
190+
list(APPEND LIBS mobile-cv-suite::core) # applies to run-tests
191+
add_subdirectory(test)
192+
endif()

0 commit comments

Comments
 (0)