Convert Figma logo to code with AI

ethz-asl logookvis

OKVIS: Open Keyframe-based Visual-Inertial SLAM.

1,245
538
1,245
66

Top Related Projects

A Robust and Versatile Monocular Visual-Inertial State Estimator

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities

ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM

Visual Inertial Odometry with SLAM capabilities and 3D Mesh generation.

An optimization-based multi-sensor state estimator

Quick Overview

OKVIS (Open Keyframe-based Visual-Inertial SLAM) is an open-source C++ library for real-time visual-inertial odometry and SLAM. It combines visual and inertial measurements to estimate camera motion and 3D structure, making it suitable for robotics and augmented reality applications.

Pros

  • High accuracy and robustness in challenging environments
  • Efficient implementation with multi-threading support
  • Supports various camera models and IMU configurations
  • Well-documented and actively maintained

Cons

  • Steep learning curve for beginners
  • Requires careful calibration for optimal performance
  • Limited to visual-inertial odometry (no loop closure)
  • Computationally intensive for resource-constrained devices

Code Examples

  1. Initializing OKVIS:
#include <okvis/VioParametersReader.hpp>
#include <okvis/ThreadedKFVio.hpp>

okvis::VioParametersReader vio_parameters_reader("config.yaml");
okvis::VioParameters parameters;
vio_parameters_reader.getParameters(parameters);

okvis::ThreadedKFVio okvis_estimator(parameters);
  1. Adding an image to OKVIS:
#include <opencv2/opencv.hpp>

cv::Mat image;
okvis::Time timestamp(1.0);
size_t camera_index = 0;

okvis_estimator.addImage(timestamp, camera_index, image);
  1. Adding IMU measurements:
Eigen::Vector3d accelerometer(0.1, 0.2, 9.81);
Eigen::Vector3d gyroscope(0.01, 0.02, 0.03);
okvis::Time imu_timestamp(1.001);

okvis_estimator.addImuMeasurement(imu_timestamp, accelerometer, gyroscope);

Getting Started

  1. Clone the repository:

    git clone https://github.com/ethz-asl/okvis.git
    
  2. Install dependencies:

    sudo apt-get install libgoogle-glog-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev
    
  3. Build OKVIS:

    cd okvis
    mkdir build && cd build
    cmake ..
    make
    
  4. Run the example:

    ./okvis_app_synchronous ../config/config_fpga_p2_euroc.yaml ../data/MH_01_easy
    

Competitor Comparisons

A Robust and Versatile Monocular Visual-Inertial State Estimator

Pros of VINS-Mono

  • Supports loop closure for improved accuracy and drift reduction
  • Includes a robust initialization process for better system stability
  • Provides a more comprehensive sensor fusion framework, including IMU pre-integration

Cons of VINS-Mono

  • Generally slower processing speed compared to OKVIS
  • May require more computational resources due to additional features
  • Less optimized for embedded systems or resource-constrained environments

Code Comparison

VINS-Mono (C++):

void FeatureManager::setDepth(const VectorXd &x) {
    int feature_index = -1;
    for (auto &it_per_id : feature) {
        it_per_id.used_num = it_per_id.feature_per_frame.size();
        if (it_per_id.used_num < 4)
            continue;
        feature_index++;
        it_per_id.estimated_depth = 1.0 / x(feature_index);
    }
}

OKVIS (C++):

void ViParameterBlock::setParameters(const okvis::kinematics::Transformation &T_WS) {
  T_WS_ = T_WS;
  setEstimate(okvis::kinematics::minimal::parametersToMinimal(T_WS));
}

Both repositories use C++ and focus on visual-inertial odometry, but VINS-Mono includes additional features like loop closure and a more comprehensive sensor fusion framework. OKVIS, on the other hand, is generally faster and more optimized for embedded systems.

Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities

Pros of ORB_SLAM2

  • Supports monocular, stereo, and RGB-D cameras
  • Includes loop closing and relocalization capabilities
  • Generally faster and more accurate in large-scale environments

Cons of ORB_SLAM2

  • Less robust in dynamic environments
  • Requires good lighting and texture for feature extraction
  • May struggle with pure rotational motion

Code Comparison

ORB_SLAM2 (feature extraction):

void Frame::ExtractORB(int flag, const cv::Mat &im)
{
    if(flag==0)
        (*mpORBextractorLeft)(im,cv::Mat(),mvKeys,mDescriptors);
    else
        (*mpORBextractorRight)(im,cv::Mat(),mvKeysRight,mDescriptorsRight);
}

OKVIS (feature extraction):

void extractKeypoints(const cv::Mat& image, 
                      std::vector<cv::KeyPoint>& keypoints, 
                      cv::Mat& descriptors) {
  detector_->detect(image, keypoints);
  extractor_->compute(image, keypoints, descriptors);
}

Both repositories use feature extraction for visual odometry, but ORB_SLAM2 specifically uses ORB features, while OKVIS allows for different feature types through its modular design.

ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM

Pros of ORB_SLAM3

  • Supports monocular, stereo, and RGB-D cameras, as well as visual-inertial SLAM
  • Includes loop closing and relocalization capabilities
  • More recent and actively maintained project

Cons of ORB_SLAM3

  • May have higher computational requirements due to its feature-based approach
  • Less optimized for embedded systems compared to OKVIS

Code Comparison

ORB_SLAM3:

// Feature extraction and matching
ORBextractor* mpORBextractor;
ORBmatcher matcher(0.9, true);

// Optimization
g2o::SparseOptimizer optimizer;
g2o::BlockSolver_6_3::LinearSolverType* linearSolver;

OKVIS:

// IMU integration
okvis::ImuError imuError(imuMeasurements);

// Multi-camera optimization
okvis::MultiCamera multiCamera;
okvis::ceres::PoseParameterBlock poseParameterBlock;

Both projects use optimization techniques, but ORB_SLAM3 focuses on feature-based methods, while OKVIS emphasizes IMU integration and multi-camera setups. ORB_SLAM3 provides a more comprehensive SLAM solution with additional features like loop closing, while OKVIS is designed for efficient performance on embedded systems.

Visual Inertial Odometry with SLAM capabilities and 3D Mesh generation.

Pros of Kimera-VIO

  • Includes a 3D mesh reconstruction module for dense mapping
  • Supports both stereo and monocular camera setups
  • Provides a more comprehensive SLAM solution with loop closure

Cons of Kimera-VIO

  • May have higher computational requirements due to additional features
  • Potentially more complex to set up and configure for specific use cases

Code Comparison

OKVIS initialization:

okvis::VioParametersReader vio_parameters_reader(FLAGS_config_filename);
okvis::VioParameters parameters;
vio_parameters_reader.getParameters(parameters);
okvis::ThreadedKFVio okvis_estimator(parameters);

Kimera-VIO initialization:

VioParams vio_params;
vio_params.loadFromYaml(FLAGS_params_yaml);
Pipeline vio_pipeline(vio_params);
vio_pipeline.spinOnce();

Both repositories provide C++ implementations of visual-inertial odometry systems. OKVIS focuses on keyframe-based optimization, while Kimera-VIO offers a more comprehensive SLAM solution with additional features like mesh reconstruction. The code snippets show similar initialization processes, with Kimera-VIO using a more streamlined approach.

An optimization-based multi-sensor state estimator

Pros of VINS-Fusion

  • Supports multiple sensor configurations (monocular, stereo, stereo-inertial)
  • Includes loop closure for improved accuracy and drift reduction
  • More recent development with active community support

Cons of VINS-Fusion

  • Higher computational requirements due to additional features
  • May be more complex to set up and configure for specific use cases

Code Comparison

VINS-Fusion example (initialization):

estimator.setParameter();
feature_tracker.readIntrinsicParameter(CAM_NAMES);
estimator.initEstimator();

OKVIS example (initialization):

okvis::VioParametersReader vio_parameters_reader(FLAGS_config_filename);
okvis::VioParameters parameters;
vio_parameters_reader.getParameters(parameters);
okvis::ThreadedKFVio okvis_estimator(parameters);

Both repositories provide robust visual-inertial odometry solutions, but VINS-Fusion offers more flexibility in sensor configurations and includes loop closure. OKVIS, while older, may be more lightweight and easier to integrate for specific applications. The code examples show similar initialization processes, with VINS-Fusion using a more straightforward approach and OKVIS requiring more detailed parameter setup.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

README {#mainpage}

Welcome to OKVIS: Open Keyframe-based Visual-Inertial SLAM.

This is the Author's implementation of the [1] and [3] with more results in [2].

[1] Stefan Leutenegger, Simon Lynen, Michael Bosse, Roland Siegwart and Paul Timothy Furgale. Keyframe-based visual–inertial odometry using nonlinear optimization. The International Journal of Robotics Research, 2015.

[2] Stefan Leutenegger. Unmanned Solar Airplanes: Design and Algorithms for Efficient and Robust Autonomous Operation. Doctoral dissertation, 2014.

[3] Stefan Leutenegger, Paul Timothy Furgale, Vincent Rabaud, Margarita Chli, Kurt Konolige, Roland Siegwart. Keyframe-Based Visual-Inertial SLAM using Nonlinear Optimization. In Proceedings of Robotics: Science and Systems, 2013.

Note that the codebase that you are provided here is free of charge and without any warranty. This is bleeding edge research software.

Also note that the quaternion standard has been adapted to match Eigen/ROS, thus some related mathematical description in [1,2,3] will not match the implementation here.

If you publish work that relates to this software, please cite at least [1].

License

The 3-clause BSD license (see file LICENSE) applies.

How do I get set up?

This is a pure cmake project.

You will need to install the following dependencies,

  • CMake,

      sudo apt-get install cmake
    
  • google-glog + gflags,

      sudo apt-get install libgoogle-glog-dev
    
  • BLAS & LAPACK,

      sudo apt-get install libatlas-base-dev
    
  • Eigen3,

      sudo apt-get install libeigen3-dev
    
  • SuiteSparse and CXSparse,

      sudo apt-get install libsuitesparse-dev
    
  • Boost,

      sudo apt-get install libboost-dev libboost-filesystem-dev
    
  • OpenCV 2.4-3.0: follow the instructions on http://opencv.org/ or install via

      sudo apt-get install libopencv-dev
    
  • Optional: use the the package with the Skybotix VI sensor. Note that this requires a system install, not just as ROS package. Also note that Skybotix OSX support is experimental (checkout the feature/osx branch).

      git clone https://github.com/ethz-asl/libvisensor.git
      cd libvisensor
      ./install_libvisensor.sh
    

then download and expand the archive:

wget https://www.doc.ic.ac.uk/~sleutene/software/okvis-1.1.3.zip
unzip okvis-1.1.3.zip && rm okvis-1.1.3.zip

Or, if you were given bitbucket access, clone the repository:

git clone git@github.com:ethz-asl/okvis.git

or

git clone https://github.com/ethz-asl/okvis.git

Building the project

To change the cmake build type for the whole project use:

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j8

NOTE: if you want to use the library, install the project (default or somewhere else), so the dependencies can be resolved.

make install

Running the demo application

You will find a demo application in okvis_apps. It can process datasets in the ASL/ETH format.

In order to run a minimal working example, follow the steps below:

  1. Download a dataset of your choice from http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets. Assuming you downloaded MH_01_easy/. You will find a corresponding calibration / estimator configuration in the config folder.

  2. Run the app as

     ./okvis_app_synchronous path/to/okvis/config/config_fpga_p2_euroc.yaml path/to/MH_01_easy/mav0/
    

Outputs and frames

In terms of coordinate frames and notation,

  • W denotes the OKVIS World frame (z up),
  • C_i denotes the i-th camera frame
  • S denotes the IMU sensor frame
  • B denotes a (user-specified) body frame.

The output of the okvis library is the pose T_WS as a position r_WS and quaternion q_WS, followed by the velocity in World frame v_W and gyro biases (b_g) as well as accelerometer biases (b_a). See the example application to get an idea on how to use the estimator and its outputs (callbacks returning states).

Configuration files

The config folder contains example configuration files. Please read the documentation of the individual parameters in the yaml file carefully. You have various options to trade-off accuracy and computational expense as well as to enable online calibration.

HEALTH WARNING: calibration

If you would like to run the software/library on your own hardware setup, be aware that good results (or results at all) may only be obtained with appropriate calibration of the

  • camera intrinsics,
  • camera extrinsics (poses relative to the IMU),
  • knowledge about the IMU noise parameters,
  • and ACCURATE TIME SYNCHRONISATION OF ALL SENSORS.

To perform a calibration yourself, we recommend the following:

Using the library

Here's a minimal example of your CMakeLists.txt to build a project using OKVIS.

cmake_minimum_required(VERSION 2.8)

set(OKVIS_INSTALLATION <path/to/install>) # point to installation

# require OpenCV
find_package( OpenCV COMPONENTS core highgui imgproc features2d REQUIRED )
include_directories(BEFORE ${OpenCV_INCLUDE_DIRS}) 

# require okvis
find_package( okvis 1.1 REQUIRED)
include_directories(${OKVIS_INCLUDE_DIRS})

# require brisk
find_package( brisk 2 REQUIRED)
include_directories(${BRISK_INCLUDE_DIRS})

# require ceres
list(APPEND CMAKE_PREFIX_PATH ${OKVIS_INSTALLATION})
find_package( Ceres REQUIRED )
include_directories(${CERES_INCLUDE_DIRS}) 

# require OpenGV
find_package(opengv REQUIRED)

# VISensor, if available
list(APPEND CMAKE_MODULE_PATH ${OKVIS_INSTALLATION}/lib/CMake)
find_package(VISensor)
if(VISENSORDRIVER_FOUND)
  message(STATUS "Found libvisensor.")
else()
  message(STATUS "libvisensor not found")
endif()

# now continue with your project-specific stuff...

Contribution guidelines

Support

The developpers will be happy to assist you or to consider bug reports / feature requests. But questions that can be answered reading this document will be ignored. Please contact s.leutenegger@imperial.ac.uk.