1# g2o - General Graph Optimization 2 3Linux: [![Build Status](https://travis-ci.org/RainerKuemmerle/g2o.svg?branch=master)](https://travis-ci.org/RainerKuemmerle/g2o) 4Windows: [![Build status](https://ci.appveyor.com/api/projects/status/9w0cpb9krc6t4nt7/branch/master?svg=true)](https://ci.appveyor.com/project/RainerKuemmerle/g2o/branch/master) 5[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e87df92948b747d58591372dd425fc59)](https://app.codacy.com/manual/rainer.kuemmerle/g2o?utm_source=github.com&utm_medium=referral&utm_content=RainerKuemmerle/g2o&utm_campaign=Badge_Grade_Dashboard) 6 7g2o is an open-source C++ framework for optimizing graph-based nonlinear error 8functions. g2o has been designed to be easily extensible to a wide range of 9problems and a new problem typically can be specified in a few lines of code. 10The current implementation provides solutions to several variants of SLAM and 11BA. 12 13A wide range of problems in robotics as well as in computer-vision involve the 14minimization of a non-linear error function that can be represented as a graph. 15Typical instances are simultaneous localization and mapping (SLAM) or bundle 16adjustment (BA). The overall goal in these problems is to find the 17configuration of parameters or state variables that maximally explain a set of 18measurements affected by Gaussian noise. g2o is an open-source C++ framework 19for such nonlinear least squares problems. g2o has been designed to be easily 20extensible to a wide range of problems and a new problem typically can be 21specified in a few lines of code. The current implementation provides solutions 22to several variants of SLAM and BA. g2o offers a performance comparable to 23implementations of state-of-the-art approaches for the specific problems 24(02/2011). 25 26## Papers Describing the Approach 27 28Rainer Kuemmerle, Giorgio Grisetti, Hauke Strasdat, 29Kurt Konolige, and Wolfram Burgard 30[g2o: A General Framework for Graph Optimization](http://ais.informatik.uni-freiburg.de/publications/papers/kuemmerle11icra.pdf) 31IEEE International Conference on Robotics and Automation (ICRA), 2011 32 33## Documentation 34 35A detailed description of how the library is structured and how to use and extend it can be found in /doc/g2o.pdf 36The API documentation can be generated as described in doc/doxygen/readme.txt 37 38## License 39 40g2o is licensed under the BSD License. However, some libraries are available 41under different license terms. See below. 42 43The following parts are licensed under LGPL3+: 44 45- csparse_extension 46 47The following parts are licensed under GPL3+: 48 49- g2o_viewer 50- g2o_incremental 51- slam2d_g2o (example for 2D SLAM with a QGLviewer GUI) 52 53Please note that some features of CHOLMOD (which may be used by g2o, see 54libsuitesparse below) are licensed under the GPL. To avoid the GPL, you may 55have to re-compile CHOLMOD without including its GPL features. The CHOLMOD 56library distributed with, for example, Ubuntu or Debian includes the GPL 57features. The supernodal factorization is considered by g2o, if it is 58available. 59 60Within the folder EXTERNAL we include software not written by us to 61guarantee easy compilation. 62 63- ceres: BSD (see EXTERNAL/ceres/LICENSE) 64 Headers to perform Automatic Differentiation 65 66- freeglut: X Consortium (Copyright (c) 1999-2000 Pawel W. Olszta) 67 We use a stripped down version for drawing text in OpenGL. 68 69See the doc folder for the full text of the licenses. 70 71g2o is distributed in the hope that it will be useful, 72but WITHOUT ANY WARRANTY; without even the implied warranty of 73MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 74licenses for more details. 75 76## Requirements 77 78- cmake <http://www.cmake.org> 79- Eigen3 <http://eigen.tuxfamily.org> 80 81On Ubuntu / Debian these dependencies are resolved by installing the 82following packages. 83 84- cmake 85- libeigen3-dev 86 87### Optional requirements 88 89- suitesparse <http://faculty.cse.tamu.edu/davis/suitesparse.html> 90- Qt5 <http://qt-project.org> 91- libQGLViewer <http://www.libqglviewer.com> 92 93On Ubuntu / Debian these dependencies are resolved by installing the 94following packages. 95 96- libsuitesparse-dev 97- qtdeclarative5-dev 98- qt5-qmake 99- libqglviewer-dev-qt5 100 101## Mac OS X 102 103If using [Homebrew](http://brew.sh/), then 104 105`brew install brewsci/science/g2o` 106 107will install g2o together with its required dependencies. In this case no manual compilation is necessary. 108 109## Windows 110 111If using [vcpkg](https://github.com/Microsoft/vcpkg), then 112 113`scripts\install-deps-windows.bat` 114 115will build and install the required dependencies. The location of `vcpkg` and required triplet are determined by the environment variables `VCPKG_ROOT_DIR` and `VCPKG_DEFAULT_TRIPLET`. 116 117## Compilation 118 119Our primary development platform is Linux. Experimental support for 120Mac OS X, Android and Windows (MinGW or MSVC). 121We recommend a so-called out of source build which can be achieved 122by the following command sequence. 123 124- `mkdir build` 125- `cd build` 126- `cmake ../` 127- `make` 128 129The binaries will be placed in bin and the libraries in lib which 130are both located in the top-level folder. 131 132On Windows with `vcpkg` the following two commands will generate build scripts for Visual Studio 2017 MSVC 14 tool set: 133 134- `mkdir build` 135- `cd build` 136- `cmake -G "Visual Studio 14 2017 Win64" -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON -DVCPKG_TARGET_TRIPLET="%VCPKG_DEFAULT_TRIPLET%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT_DIR%\scripts\buildsystems\vcpkg.cmake" ..` 137 138If you are compiling on Windows and you are for some reasons **not** using `vcpkg` please download Eigen3 and extract it. 139Within cmake-gui set the variable G2O_EIGEN3_INCLUDE to that directory. 140 141## Cross-Compiling for Android 142 143- `mkdir build` 144- `cd build` 145- `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 .` 146 147## Acknowledgments 148 149We thank the following contributors for providing patches: 150 151- Simon J. Julier: patches to achieve compatibility with Mac OS X and others. 152- Michael A. Eriksen for submitting patches to compile with MSVC. 153- Mark Pupilli for submitting patches to compile with MSVC. 154 155## Projects using g2o 156 157- [g2opy](https://github.com/uoip/g2opy): Python binding 158- [.Net wrapper](https://github.com/fugro/g2o) 159 160## Contact information 161 162- [Rainer Kuemmerle](mailto:kuemmerl@informatik.uni-freiburg.de) 163- [Giorgio Grisetti](mailto:grisetti@dis.uniroma1.it) 164- [Hauke Strasdat](mailto:strasdat@gmail.com) 165- [Kurt Konolige](mailto:konolige@willowgarage.com) 166- [Wolfram Burgard](mailto:burgard@informatik.uni-freiburg.de) 167