Skip to content

Commit

Permalink
Merge pull request #9 from rpng/test2004
Browse files Browse the repository at this point in the history
Update to maplab 2.0 and Ubuntu 20.04 Docker
  • Loading branch information
goldbattle authored Aug 14, 2023
2 parents d638965 + 18f5c90 commit e039ecb
Show file tree
Hide file tree
Showing 14 changed files with 412 additions and 191 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build_ros1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ROS 1 Workflow

on:
push:
branches: [ master ]
pull_request:

jobs:
build_2004:
name: "ROS1 Ubuntu 20.04"
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v2
- name: Reconfigure git to use HTTP authentication
run: |
git config --global url."https://github.com/".insteadOf [email protected]: &&
git config --global url."https://".insteadOf git://
- name: Create Workspace and Docker Image
run: |
export REPO=$(basename $GITHUB_REPOSITORY) &&
cd $GITHUB_WORKSPACE/.. && mkdir src/ && cd src/ &&
git clone https://github.com/rpng/open_vins.git &&
git clone https://github.com/ethz-asl/maplab.git --recursive &&
cd .. && mv $REPO/ src/ && mkdir $REPO/ && mv src/ $REPO/ && cd $REPO/ &&
docker build -t ov_maplab -f $GITHUB_WORKSPACE/src/$REPO/Dockerfile_ros1_20_04 .
- name: Run Build in Docker
run: >
docker run -t --mount type=bind,source=$GITHUB_WORKSPACE,target=/catkin_ws ov_maplab /bin/bash -c
"cd /catkin_ws
&& catkin init
&& catkin config --merge-devel
&& catkin config --extend /opt/ros/noetic
&& catkin build ov_maplab"
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ project(ov_maplab)
find_package(catkin REQUIRED COMPONENTS roscpp rosbag tf std_msgs geometry_msgs sensor_msgs nav_msgs visualization_msgs cv_bridge ov_core ov_msckf vi_map vio_common feature_tracking online_map_builders console_common)
add_definitions(-DROS_AVAILABLE=1)

# Include libraries
# Include libraries (if we don't have opencv 4, then fallback to opencv 3)
# The OpenCV version needs to match the one used by cv_bridge otherwise you will get a segmentation fault!
find_package(Eigen3 REQUIRED)
find_package(OpenCV 3 REQUIRED)
find_package(OpenCV 3 QUIET)
if (NOT OpenCV_FOUND)
find_package(OpenCV 4 REQUIRED)
endif ()
find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time)
message(STATUS "OPENCV: " ${OpenCV_VERSION} " | BOOST: " ${Boost_VERSION})
find_package(Ceres REQUIRED)
message(STATUS "OPENCV: " ${OpenCV_VERSION} " | BOOST: " ${Boost_VERSION} " | CERES: " ${Ceres_VERSION})

# Describe catkin project
catkin_package(
Expand All @@ -36,13 +41,15 @@ include_directories(
src
${EIGEN3_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${CERES_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)

# Set link libraries used by all binaries
list(APPEND thirdparty_libraries
${Boost_LIBRARIES}
${OpenCV_LIBRARIES}
${CERES_LIBRARIES}
${catkin_LIBRARIES}
)

Expand Down
25 changes: 18 additions & 7 deletions Dockerfile → Dockerfile_ros1_20_04
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM osrf/ros:melodic-desktop-full
FROM osrf/ros:noetic-desktop-full

# =========================================================
# =========================================================
Expand All @@ -14,14 +14,25 @@ FROM osrf/ros:melodic-desktop-full
# Dependencies we use, catkin tools is very good build system
# Also some helper utilities for fast in terminal edits (nano etc)
RUN apt-get update && apt-get install -y libeigen3-dev nano git
RUN sudo apt-get install -y python-catkin-tools

# Seems this has Python 3.6 installed on it...
RUN sudo apt-get install -y python3-dev python3-matplotlib python3-numpy python3-psutil python3-tk
RUN sudo apt-get install -y python3-catkin-tools python3-osrf-pycommon

# Ceres solver install and setup
RUN sudo apt-get install -y cmake libgoogle-glog-dev libgflags-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev libceres-dev
# ENV CERES_VERSION="2.0.0"
# RUN git clone https://ceres-solver.googlesource.com/ceres-solver && \
# cd ceres-solver && \
# git checkout tags/${CERES_VERSION} && \
# mkdir build && cd build && \
# cmake .. && \
# make -j$(nproc) install && \
# rm -rf ../../ceres-solver

# Seems this has Python 3.8 installed on it...
RUN apt-get update && apt-get install -y python3-dev python3-matplotlib python3-numpy python3-psutil python3-tk

# Maplab dependecies
# https://github.com/ethz-asl/maplab/wiki/Installation-Ubuntu
RUN sudo apt install -y autotools-dev ccache doxygen dh-autoreconf git liblapack-dev libblas-dev libgtest-dev libreadline-dev libssh2-1-dev pylint clang-format python-autopep8 python-catkin-tools python-pip python-git python-setuptools python-termcolor python-wstool libatlas3-base
RUN sudo apt install -y autotools-dev ccache doxygen dh-autoreconf git liblapack-dev libblas-dev libgtest-dev libreadline-dev libssh2-1-dev pylint clang-format-6.0 python3-autopep8 python3-catkin-tools python3-pip python3-git python3-setuptools python3-termcolor python3-wstool libatlas3-base libv4l-dev
RUN sudo pip install requests

# Install CMake 3.13.5
Expand All @@ -33,7 +44,7 @@ RUN cmake --version

# Install deps needed for clion remote debugging
# https://blog.jetbrains.com/clion/2020/01/using-docker-with-clion/
RUN sed -i '6i\source "/catkin_ws/devel/setup.bash"\' /ros_entrypoint.sh
# RUN sed -i '6i\source "/catkin_ws/devel/setup.bash"\' /ros_entrypoint.sh
RUN apt-get update && apt-get install -y ssh build-essential gcc g++ \
gdb clang cmake rsync tar python && apt-get clean
RUN ( \
Expand Down
15 changes: 9 additions & 6 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# OpenVINS Maplab Interface

Here we have our interface wrapper for exporting visual-inertial runs from [OpenVINS](https://github.com/rpng/open_vins) into the ViMap structure taken by [maplab](https://github.com/ethz-asl/maplab). The state estimates and raw images are appended to the ViMap as OpenVINS runs through a dataset. After completion of the dataset, we re-extract features and triangulate them due to the incompatibilities of the two frontends. Maplab requires BRISK or FREAK descriptors, while OpenVINS works with KLT or ORB feature tracking. In the future we will try to only extract descriptors on tracked features from OpenVINS, but for now we just re-detect for simplicity. We have tested this on the [EurocMav](https://docs.openvins.com/gs-datasets.html#gs-data-euroc) and [TUM-VI](https://docs.openvins.com/gs-datasets.html#gs-data-tumvi) datasets and have had good success with merging the different runs and optimizing the resulting graph. To ensure that we are able to compile maplab, we provide a [docker image](Dockerfile) for Ubuntu 18.04 which has all dependencies required.
[![ROS 1 Workflow](https://github.com/rpng/ov_maplab/actions/workflows/build_ros1.yml/badge.svg)](https://github.com/rpng/ov_maplab/actions/workflows/build_ros1.yml)

Here we have our interface wrapper for exporting visual-inertial runs from [OpenVINS](https://github.com/rpng/open_vins) into the ViMap structure taken by [maplab](https://github.com/ethz-asl/maplab). The state estimates and raw images are appended to the ViMap as OpenVINS runs through a dataset. After completion of the dataset, we re-extract features and triangulate them due to the incompatibilities of the two frontends. Maplab requires BRISK or FREAK descriptors, while OpenVINS works with KLT or ORB feature tracking. In the future we will try to only extract descriptors on tracked features from OpenVINS, but for now we just re-detect for simplicity. We have tested this on the [EurocMav](https://docs.openvins.com/gs-datasets.html#gs-data-euroc) and [TUM-VI](https://docs.openvins.com/gs-datasets.html#gs-data-tumvi) datasets and have had good success with merging the different runs and optimizing the resulting graph. To ensure that we are able to compile maplab, we provide a [docker image](Dockerfile) for Ubuntu 20.04 which has all dependencies required.

## Dependencies

* OpenVINS (v2.7 release) - https://docs.openvins.com/gs-installing.html
* maplab (develop v1, 18.04 release) - https://github.com/ethz-asl/maplab/wiki/Installation-Ubuntu
* maplab (v2.0, 20.04 release) - https://github.com/ethz-asl/maplab/wiki/Installation-Ubuntu
* Docker - https://docs.docker.com/get-docker/

## Installation Guide
Expand All @@ -20,11 +22,11 @@ git clone https://github.com/rpng/open_vins.git
git clone https://github.com/ethz-asl/maplab.git --recursive
# switch open_vins to last tested commit (might build with newer)
cd open_vins/
git checkout 2b506eeedd0b158c014641b9240a62ae80f6d7a0
git checkout 4534a2f32d4763bdc8c95121b3292c7423e12aca
cd ..
# switch maplab to last tested commit (might build with newer)
cd maplab/
git checkout 483daf4988a76c15be362fd017ec78581c4f88d9
git checkout 0b4868efeb292851d71f98d31a1e6bb40ebb244b
git submodule update --init --recursive
cd ..
```
Expand Down Expand Up @@ -52,8 +54,9 @@ ov_docker ov_maplab bash
cd catkin_ws/
catkin init
catkin config --merge-devel
catkin config --extend /opt/ros/melodic
catkin build maplab ov_maplab ov_data -j4
catkin config --extend /opt/ros/noetic
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin build maplab ov_maplab -j4
catkin build ov_maplab -j4 --no-deps # after first build
source devel/setup.bash
```
Expand Down
Binary file added docs/Screenshot from 2023-08-13 13-42-36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

# setup ros environment
# ensure you have already built the workspace!
source "/catkin_ws/devel/setup.bash" --
exec "$@"
2 changes: 1 addition & 1 deletion launch/serial.launch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<arg name="mapfolder" default="/datasets/$(arg config)/maplab/$(arg dataset)/" />

<!-- if we should viz the groundtruth -->
<arg name="dolivetraj" default="false" />
<arg name="dolivetraj" default="true" />
<arg name="path_gt" default="$(find ov_data)/$(arg config)/$(arg dataset).txt" />

<!-- MASTER NODE! -->
Expand Down
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<build_depend>visualization_msgs</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>ov_core</build_depend>
<build_depend>ov_data</build_depend>
<build_depend>ov_msckf</build_depend>
<build_depend>vi_map</build_depend>
<build_depend>vio_common</build_depend>
Expand All @@ -48,6 +49,8 @@
<run_depend>visualization_msgs</run_depend>
<run_depend>cv_bridge</run_depend>
<run_depend>ov_core</run_depend>
<run_depend>ov_data</run_depend>
<run_depend>ov_eval</run_depend>
<run_depend>ov_msckf</run_depend>
<run_depend>vi_map</run_depend>
<run_depend>vio_common</run_depend>
Expand Down
30 changes: 30 additions & 0 deletions scripts/commands_eurocmav.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

vi_map_folder_paths:
- /datasets/euroc_mav/maplab/V1_01_easy
- /datasets/euroc_mav/maplab/V1_02_medium
- /datasets/euroc_mav/maplab/V1_03_difficult
- /datasets/euroc_mav/maplab/V2_01_easy
- /datasets/euroc_mav/maplab/V2_02_medium
- /datasets/euroc_mav/maplab/V2_03_difficult
commands:
- load --map_folder=<CURRENT_VIMAP_FOLDER>
- retriangulate_landmarks
- v --vis_color_by_mission
- optvi --ba_num_iterations=5 -ba_visualize_every_n_iterations=1
- retriangulate_landmarks
- loopclosure_all_missions
- optvi --ba_num_iterations=5 -ba_visualize_every_n_iterations=1
- retriangulate_landmarks
- loopclosure_all_missions
- optvi --ba_num_iterations=30 -ba_visualize_every_n_iterations=5
- evaluate_landmark_quality
- remove_bad_landmarks
- save --map_folder=<CURRENT_VIMAP_FOLDER>_result
- export_to_openvins --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result
- export_trajectory_to_csv --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result
- keyframe_heuristic
- v --vis_color_by_mission
- save --map_folder=<CURRENT_VIMAP_FOLDER>_result_keyframed
- export_to_openvins --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result_keyframed
- export_trajectory_to_csv --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result_keyframed

32 changes: 32 additions & 0 deletions scripts/commands_rpngplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

vi_map_folder_paths:
- /datasets/rpng_plane/maplab/table_01
- /datasets/rpng_plane/maplab/table_02
- /datasets/rpng_plane/maplab/table_03
- /datasets/rpng_plane/maplab/table_04
- /datasets/rpng_plane/maplab/table_05
- /datasets/rpng_plane/maplab/table_06
- /datasets/rpng_plane/maplab/table_07
- /datasets/rpng_plane/maplab/table_08
commands:
- load --map_folder=<CURRENT_VIMAP_FOLDER>
- retriangulate_landmarks
- v --vis_color_by_mission
- optvi --ba_num_iterations=5 -ba_visualize_every_n_iterations=1
- retriangulate_landmarks
- loopclosure_all_missions
- optvi --ba_num_iterations=5 -ba_visualize_every_n_iterations=1
- retriangulate_landmarks
- loopclosure_all_missions
- optvi --ba_num_iterations=30 -ba_visualize_every_n_iterations=5
- evaluate_landmark_quality
- remove_bad_landmarks
- save --map_folder=<CURRENT_VIMAP_FOLDER>_result
- export_to_openvins --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result
- export_trajectory_to_csv --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result
- keyframe_heuristic
- v --vis_color_by_mission
- save --map_folder=<CURRENT_VIMAP_FOLDER>_result_keyframed
- export_to_openvins --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result_keyframed
- export_trajectory_to_csv --overwrite --export_path=<CURRENT_VIMAP_FOLDER>_result_keyframed

66 changes: 66 additions & 0 deletions scripts/process_eurocmav.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

# Source our workspace directory to load ENV variables
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source ${SCRIPT_DIR}/../../../devel/setup.bash

#=============================================================
#=============================================================
#=============================================================

# dataset locations
bagnames=(
"V1_01_easy"
"V1_02_medium"
"V1_03_difficult"
"V2_01_easy"
"V2_02_medium"
"V2_03_difficult"
)

#=============================================================
#=============================================================
#=============================================================

big_start_time="$(date -u +%s)"

# Loop through all datasets
for i in "${!bagnames[@]}"; do

# start timing
start_time="$(date -u +%s)"

# run our ROS launch file (note we send console output to terminator)
roslaunch ov_maplab serial.launch \
max_cameras:="2" \
use_stereo:="true" \
config:="euroc_mav" \
dataset:="${bagnames[i]}" \
dolivetraj:="true" &> /dev/null

# print out the time elapsed
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
echo "BASH: ${bagnames[i]} - vio took $elapsed seconds";

done

# start timing
start_time="$(date -u +%s)"

# run our maplab batch processing command
rosrun maplab_console batch_runner --batch_control_file=src/ov_maplab/scripts/commands_eurocmav.yaml

# print out the time elapsed
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
echo "BASH: full maplab opt took $elapsed seconds";

# fix our permissions...
sudo chmod -R 777 /datasets/euroc_mav/maplab/
sudo chown -R patrick /datasets/euroc_mav/maplab/

# print out the time elapsed
big_end_time="$(date -u +%s)"
big_elapsed="$(($big_end_time-$big_start_time))"
echo "BASH: script took $big_elapsed seconds in total!!";
68 changes: 68 additions & 0 deletions scripts/process_rpngplane.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

# Source our workspace directory to load ENV variables
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source ${SCRIPT_DIR}/../../../devel/setup.bash

#=============================================================
#=============================================================
#=============================================================

# dataset locations
bagnames=(
"table_01"
"table_02"
"table_03"
"table_04"
"table_05"
"table_06"
"table_07"
"table_08"
)

#=============================================================
#=============================================================
#=============================================================

big_start_time="$(date -u +%s)"

# Loop through all datasets
for i in "${!bagnames[@]}"; do

# start timing
start_time="$(date -u +%s)"

# run our ROS launch file (note we send console output to terminator)
roslaunch ov_maplab serial.launch \
max_cameras:="1" \
use_stereo:="true" \
config:="rpng_plane" \
dataset:="${bagnames[i]}" \
dolivetraj:="true" &> /dev/null

# print out the time elapsed
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
echo "BASH: ${bagnames[i]} - vio took $elapsed seconds";

done

# start timing
start_time="$(date -u +%s)"

# run our maplab batch processing command
rosrun maplab_console batch_runner --batch_control_file=src/ov_maplab/scripts/commands_rpngplane.yaml

# print out the time elapsed
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
echo "BASH: full maplab opt took $elapsed seconds";

# fix our permissions...
sudo chmod -R 777 /datasets/rpng_plane/maplab/
sudo chown -R patrick /datasets/rpng_plane/maplab/

# print out the time elapsed
big_end_time="$(date -u +%s)"
big_elapsed="$(($big_end_time-$big_start_time))"
echo "BASH: script took $big_elapsed seconds in total!!";
Loading

0 comments on commit e039ecb

Please sign in to comment.