Giter Club home page Giter Club logo

ov_hloc's Introduction

OV_HLOC

Using Hierarchical-Localization instead of DBoW2 for loop closure. This was originally part of my undergraduate final project, where I worked on improving the loop closure module of VINS-Fusion. I found it just right for providing a loosely coupled pose graph for OpenVINS.

framework

Thanks to the excellent global pose graph optimization provided by VINS-Fusion, this project performs well on the EuRoC dataset.

MH_05

In the application scenario you can use COLMAP to build SfM maps (using SuperPoint and NetVLAD). The use of a priori maps can give you more accurate positioning results and no accumulative errors.

Dependencies

I recommend installing them in the following order.

[CUDA and cuDNN]

CUDA:

# You need to adjust it according to your system version
export DISTRO=ubuntu2004
export APT_INSTALL=cuda-toolkit-11-6

# add CUDA into apt-key
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64/7fa2af80.pub
echo "deb http://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list
wget https://developer.download.nvidia.com/compute/cuda/repos/${DISTRO}/x86_64/cuda-${DISTRO}.pin
sudo mv cuda-${DISTRO}.pin /etc/apt/preferences.d/cuda-repository-pin-600

# Install CUDA Toolkit
sudo apt update && sudo apt -y upgrade
sudo apt install -y ${APT_INSTALL}

# Set environment variables
cat << 'EOS' >> ~/.profile
export PATH=/usr/local/cuda-11.6/bin${PATH:+:${PATH}}

# Install third-party libraries (optional)
sudo apt install -y g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

cuDNN:

In order to download cuDNN libraries, you need to go to https://developer.nvidia.com/cudnn and click on the Download cuDNN button. The webpage will ask you to login into the NVIDIA developer account. After logging in and accepting their terms and conditions, you should click on the following three links:

cuDNN Runtime Library for Ubuntu20.04 x86_64 (Deb)

cuDNN Developer Library for Ubuntu20.04 x86_64 (Deb)

cuDNN Code Samples and User Guide for Ubuntu20.04 x86_64 (Deb)

which is relevant to Ubuntu 20.04 LTS. After downloading, you should have the following three .deb files:

  1. libcudnn8-samples_8.2.0.53–1+cuda11.3_amd64.deb
  2. libcudnn8-dev_8.2.0.53–1+cuda11.3_amd64.deb
  3. libcudnn8_8.2.0.53–1+cuda11.3_amd64.deb

that you can install using dpkg commands:

sudo dpkg -i  libcudnn8_8.2.0.53-1+cuda11.3_amd64.deb
sudo dpkg -i libcudnn8-dev_8.2.0.53-1+cuda11.3_amd64.deb
sudo dpkg -i libcudnn8-samples_8.2.0.53-1+cuda11.3_amd64.deb

After the installation is complete you can verify the installation with https://github.com/nvidia/cuda-samples.

[Pytorch and libtorch]

Pytorch: Follow Start Locally | PyTorch to install Pytorch. Here I recommend using conda to install pytorch.

conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge

Note: The cudatoolkit version here does not have to be the same as before.

libtorch: Follow Start Locally | PyTorch to install libtorch. Select Stable (1.12.1) Linux LibTorch C++ / Java CUDA 11.6. Download and extract the zip file corresponding to the (cxx11 ABI) link, you will get a folder named libtorch.

[ROS]

ROS: Follow Getting Started » Installation Guide | OpenVINS to install ROS1.

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
export ROS1_DISTRO=noetic # kinetic=16.04, melodic=18.04, noetic=20.04
sudo apt-get install ros-$ROS1_DISTRO-desktop-full
sudo apt-get install python-catkin-tools # ubuntu 16.04, 18.04
sudo apt-get install python3-catkin-tools python3-osrf-pycommon # ubuntu 20.04
sudo apt-get install libeigen3-dev libboost-all-dev libceres-dev

# for bash user
echo "source /opt/ros/$ROS1_DISTRO/setup.bash" >> ~/.bashrc
source ~/.bashrc

# for zsh user
# echo "source /opt/ros/$ROS1_DISTRO/setup.zsh" >> ~/.zshrc
# source ~/.zshrc
[OpenVINS]

OpenVINS: Follow Getting Started » Installation Guide | OpenVINS to clone the OpenVINS project.

mkdir -p ~/workspace/catkin_ws_ov/src/
cd ~/workspace/catkin_ws_ov/src/
git clone https://github.com/rpng/open_vins/
[ov_hloc]

ov_hloc: Congratulations on all the hard work you've gone through to get here.

mkdir -p ~/workspace/catkin_ws_ov/src/
cd ~/workspace/catkin_ws_ov/src/
git clone https://github.com/Li-Jesse-Jiaze/ov_hloc.git

Fill the libtorch folder path into loop_hloc/CMakeLists.txt line 22.

# set your own libtorch path
set(TORCH_PATH */libtorch/share/cmake/Torch)
[build and run]

build:

cd ~/workspace/catkin_ws_ov
catkin build
source ~/workspace/catkin_ws_ov/devel/setup.bash # for bash user
# source ~/workspace/catkin_ws_ov/devel/setup.zsh # for zsh user

Download and Convert HF-Net

Download SuperGluePretrainedNetwork/models/weights and place them in support_files/Networks/weights.

cd ~/workspace/catkin_ws_ov/src/ov_hloc/support_files/
python convert_model.py

Run Example

roslaunch ov_msckf subscribe.launch config:=euroc_mav # term 1
rosrun loop_hloc loop_hloc_node ~/workspace/catkin_ws_ov/src/ov_secondary/config/master_config.yaml # term 2
rviz # term 3
rosbag play your/dataset/path/V1_01_easy.bag # term 4

select config/vins_rviz_config.rviz as config in rviz

The pose graph was not very smooth when I tested it on my laptop(RTX 2060 Max-Q 65W). This is mainly because my NetVLAD is using a VGG16 (it tooks more than 50ms for each frame 😠). It would be better to use a lighter backbone (e.g. MobileNetV3) and fine-tuning NetVLAD for your application scenario.

Here's a simple video of it working with VINS-Fusion.

ov_hloc's People

Contributors

li-jesse-jiaze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ov_hloc's Issues

terminate called after throwing an instance of 'c10::Error'

Hi,

Got this error when running rosrun loop_hloc loop_hloc_node ./src/ov_hloc/config/master_config.yaml:


config_file: /home/trainer/ovhloc/workspace/catkin_ws_ov/src/ov_hloc/config/master_config.yaml
[ WARN] [1690048092.565376487]: Loading HF-Net...
terminate called after throwing an instance of 'c10::Error'
  what():  Unrecognized data format
Exception raised from load at ../torch/csrc/jit/serialization/import.cpp:449 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6b (0x7f35cf1ad2eb in /home/trainer/ovhloc/workspace/catkin_ws_ov/src/libtorch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, char const*) + 0xd1 (0x7f35cf1a8e41 in /home/trainer/ovhloc/workspace/catkin_ws_ov/src/libtorch/lib/libc10.so)
frame #2: torch::jit::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, c10::optional<c10::Device>, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&) + 0x1b6 (0x7f35a5635876 in /home/trainer/ovhloc/workspace/catkin_ws_ov/src/libtorch/lib/libtorch_cpu.so)
frame #3: torch::jit::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, c10::optional<c10::Device>) + 0x6f (0x7f35a563594f in /home/trainer/ovhloc/workspace/catkin_ws_ov/src/libtorch/lib/libtorch_cpu.so)
frame #4: SuperPoint::SuperPoint() + 0x78 (0x559439d64698 in /home/trainer/ovhloc/workspace/catkin_ws_ov/devel_isolated/loop_hloc/lib/loop_hloc/loop_hloc_node)
frame #5: SuperPoint::Extract(cv::Mat const&, std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >&, std::vector<float, std::allocator<float> >&, cv::Mat&) + 0x6c (0x559439d67b3c in /home/trainer/ovhloc/workspace/catkin_ws_ov/devel_isolated/loop_hloc/lib/loop_hloc/loop_hloc_node)
frame #6: init_hloc() + 0x1fc (0x559439d16e5c in /home/trainer/ovhloc/workspace/catkin_ws_ov/devel_isolated/loop_hloc/lib/loop_hloc/loop_hloc_node)
frame #7: main + 0x35a (0x559439d132ba in /home/trainer/ovhloc/workspace/catkin_ws_ov/devel_isolated/loop_hloc/lib/loop_hloc/loop_hloc_node)
frame #8: __libc_start_main + 0xf3 (0x7f3577c67083 in /usr/lib/x86_64-linux-gnu/libc.so.6)
frame #9: _start + 0x2e (0x559439d1630e in /home/trainer/ovhloc/workspace/catkin_ws_ov/devel_isolated/loop_hloc/lib/loop_hloc/loop_hloc_node)

Aborted (core dumped)

Using:
cuda11.3.1
cudnn8
ubuntu20.04
python3.8
torch1.12.1
libtorch-cxx11-abi-shared-with-deps-1.12.1
ceres-solver-2.0.0

Any ideas?

hloc使用问题咨询

感谢你出色的工作!大佬想问下,使用hloc的时候需要预加载环境的3D模型吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.