g2o

RainerKuemmerle活跃维护

C++ 图优化通用框架,把 SLAM 和视觉定位里的位姿估计建模成图,用非线性最小二乘求解,是后端优化的经典基础设施。

g2o: A General Framework for Graph Optimization

20241228_git发布于 2024-12-28 09:25 UTC3,478star1,158fork同步于 2026-11-10 17:42 UTC

怎么上手

由 README 提炼,执行前请确认
sudo apt install libeigen3-dev libspdlog-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev-qt5
mkdir build
cd build
cmake ../
make
硬件要求按 README 说明

README 未说明硬件要求,仅要求 C++17 编译器、CMake 与 Eigen3,属纯 CPU 计算库

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

开源 C++ 图优化框架,用图结构求解 SLAM 与 BA 中的非线性最小二乘问题

C++ 图优化通用框架,把 SLAM 和视觉定位里的位姿估计建模成图,用非线性最小二乘求解,是后端优化的经典基础设施。

核心能力

  • 把非线性误差函数建模成图并做最小二乘优化
  • 内置多种 SLAM 与 BA 问题的求解实现
  • 新问题通常只需几行代码即可扩展定义
  • 提供 g2o_viewer 等可视化与增量优化组件
  • 支持 Linux、macOS、Windows 与 Android 交叉编译

容易踩的坑

Eigen3 是必需依赖,Windows 非 vcpkg 构建需手动设置 EIGEN3_INCLUDE_DIR;g2o_viewer、g2o_incremental 等组件为 GPL3+ 授权,商用需注意;CHOLMOD 若带 GPL 特性会被启用,需规避 GPL 时得自行重编 CHOLMOD;Python 绑定在实验性 pymem 分支,正式包需另装 g2o-python

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本20241228_git
  1. 20241228_git最新正式版2024-12-28 · 2024-12-28 09:25 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/RainerKuemmerle/g2o/compare/20230806_git...20241228_git

  2. 20230806_git2023-08-06 · 2023-08-06 13:51 UTC
    查看更新说明
    • Integrate spdlog as logging framework
    • Move to C++17, including refactoring fixed sized edges
    • Drop broken single precision feature
    • Add SO_VERSION and VERSION
    • Drop build type suffix and place bin/lib in build folder
    • Move g2o_hierarchical into examples
    • Implement drawing covariance matrix in examples/slam2d
    • Fix Fair and Geman McClure robust kernel
    • Fix SSE auto detection
  3. 20230223_git2023-02-26 · 2023-02-26 11:36 UTC
    查看更新说明
    • Support dynamically sized vertices
    • Use Eigen based solver to provide gn_var, lm_var from the solver factory
    • Require C++14 for core module
    • Only depend on Cholmod and CSparse at build time
    • clang-formatted code base
  4. 20201223_git2020-12-23 · 2020-12-23 13:57 UTC
    查看更新说明
    • Add support for dynamically sized vertices
    • Switch to Eigen's Sparse Cholesky modules as the standard solver
      • Eigen's Sparse Module is included in the Eigen header and available under LGPL2
      • Still, cholmod should be preferred if performance is important
    • Drop own copy of CSparse (see above)
    • Own examples use Eigen or Cholmod (no longer CSparse)
    • Add tests
  5. 20200410_git202004102020-04-10 · 2020-04-10 11:46 UTC

    这个版本没有写更新说明。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    g2o - General Graph Optimization

    Linux/Mac: CI Windows: win64 Codacy Badge pre-commit

    g2o is an open-source C++ framework for optimizing graph-based nonlinear error functions. g2o has been designed to be easily extensible to a wide range of problems and a new problem typically can be specified in a few lines of code. The current implementation provides solutions to several variants of SLAM and BA.

    A wide range of problems in robotics as well as in computer-vision involve the minimization of a non-linear error function that can be represented as a graph. Typical instances are simultaneous localization and mapping (SLAM) or bundle adjustment (BA). The overall goal in these problems is to find the configuration of parameters or state variables that maximally explain a set of measurements affected by Gaussian noise. g2o is an open-source C++ framework for such nonlinear least squares problems. g2o has been designed to be easily extensible to a wide range of problems and a new problem typically can be specified in a few lines of code. The current implementation provides solutions to several variants of SLAM and BA. g2o offers a performance comparable to implementations of state-of-the-art approaches for the specific problems (02/2011).

    Python and updated memory management

    The branch pymem contains a python wrapper and switches to smart pointer instead of RAW pointers. It is currently experimental but PRs and improvements are welcome - as always.

    See g2o-python for the pypi release of g2o's python bindings.

    Papers Describing the Approach

    Rainer Kuemmerle, Giorgio Grisetti, Hauke Strasdat, Kurt Konolige, and Wolfram Burgard g2o: A General Framework for Graph Optimization IEEE International Conference on Robotics and Automation (ICRA), 2011

    Documentation

    A detailed description of how the library is structured and how to use and extend it can be found in /doc/g2o.pdf The API documentation can be generated as described in doc/doxygen/readme.txt

    License

    g2o is licensed under the BSD License. However, some libraries are available under different license terms. See below.

    The following parts are licensed under LGPL v2.1+:

    • csparse_extension

    The following parts are licensed under GPL3+:

    • g2o_viewer
    • g2o_incremental
    • slam2d_g2o (example for 2D SLAM with a QGLviewer GUI)

    Please note that some features of CHOLMOD (which may be used by g2o, see libsuitesparse below) are licensed under the GPL. To avoid the GPL, you may have to re-compile CHOLMOD without including its GPL features. The CHOLMOD library distributed with, for example, Ubuntu or Debian includes the GPL features. For example, the supernodal factorization that is licensed under GPL is considered by g2o if it is available.

    Within sub-folders we include software not written by us to guarantee easy compilation and integration into g2o itself.

    • ceres: BSD (see g2o/autodiff/LICENSE) Extracted headers to perform Automatic Differentiation.

    • freeglut: X-Consortium (see g2o/EXTERNAL/freeglut/COPYING) Copyright (c) 1999-2000 Pawel W. Olszta We use a stripped down version for drawing text in OpenGL.

    See the doc folder for the full text of the licenses.

    g2o is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the licenses for more details.

    Requirements

    On Ubuntu / Debian these dependencies are resolved by installing the following packages.

    • cmake
    • libeigen3-dev

    Optional requirements

    On Ubuntu / Debian these dependencies are resolved by installing the following packages.

    • libspdlog-dev
    • libsuitesparse-dev
    • qtdeclarative5-dev
    • qt5-qmake
    • libqglviewer-dev-qt5

    You can install those packages with the following command

    sudo apt install libeigen3-dev libspdlog-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev-qt5
    

    Mac OS X

    If using Homebrew, then

    brew install g2o

    will install g2o together with its required dependencies. In this case no manual compilation is necessary.

    Windows

    If using vcpkg, then

    script\install-deps-windows.bat

    or for full dependencies installation

    script\install-additional-deps-windows.bat

    will build and install the dependencies. The location of vcpkg and required triplet can be passed as cli arguments respectively. Note that usually vcpkg will auto detect the triplet. Set it only if your are not using the default build for your OS.

    Compilation

    Our primary development platform is Linux. Experimental support for Mac OS X, Android and Windows (MinGW or MSVC). We recommend a so-called out of source build which can be achieved by the following command sequence.

    mkdir build
    cd build
    cmake ../
    make
    

    The binaries will be placed in bin and the libraries in lib which are both located underneath cmake's build folder.

    On Windows with vcpkg the following commands will generate build scripts (please change the Visual Studio version number in accordance with your system):

    mkdir build
    cd build
    cmake -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON-DVCPKG_TARGET_TRIPLET="%VCPKG_DEFAULT_TRIPLET%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT_DIR%\scripts\buildsystems\vcpkg.cmake" ..`
    cmake --build . --target ALL_BUILD
    

    If you are compiling on Windows and you are for some reasons not using vcpkg please download Eigen3 and extract it. Within cmake-gui set the variable EIGEN3_INCLUDE_DIR to that directory.

    mkdir build
    cd build
    cmake .. -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON -DEIGEN3_INCLUDE_DIR="<THE_PATH_WHERE_YOU_PLACED_EIGEN3_AND_THE_EIGEN3_CMakeLists.txt>"
    

    Cross-Compiling for Android

    mkdir build`
    cd build`
    cmake -DCMAKE_TOOLCHAIN_FILE=../script/android.toolchain.cmake -DANDROID_NDK=<YOUR_PATH_TO_ANDROID_NDK_r10d+> -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" -DEIGEN3_INCLUDE_DIR="<YOUR_PATH_TO_EIGEN>" -DEIGEN3_VERSION_OK=ON ..
    cmake --build .
    

    Acknowledgments

    We thank the following contributors for providing patches:

    • Simon J. Julier: patches to achieve compatibility with Mac OS X and others.
    • Michael A. Eriksen for submitting patches to compile with MSVC.
    • Mark Pupilli for submitting patches to compile with MSVC.

    Projects using g2o