A .Net wrapper for the G2O (graph-based optimization) library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


General Graph Optimization in .Net

A .Net wrapper for the G2O (graph-based optimization) library

Get Started

Clone this project and build it by using Visual Studio 2017. Reference Fugro.G2O.dll in your own project and you are ready to go. The repository includes unit tests which can be run by using NUnit.

C# example

  1. Create a class for each type of state you have. Derive from State and implement the OnUpdate function. Provide an initial value and the dimension of the state to the base class. Next instantiate it for each state you want to estimate.
  2. Create a class for each kind of measurement you have. Derive from Observation and implement the OnComputeError function. The base class needs the sd's of the measurement and all the states its dependent on. Next instantiate it for each observation you have.
  3. Now instantiate a Graph, add all the obsevations and call Optimize(). This will optimize the graph and estimate the states.
var state = new State(0.0);
var measurement = new Measurement(3.0, state);

var graph = new Graph();

// Should output 3.0

class State : State<double>
    public State(double initialValue = 0.0) 
        : base(initialValue, 1)
    { }

    protected override double OnUpdate(double[] delta)
        return Estimate + delta[0];

class Measurement : Observation
    private readonly double m_Measurement;
    private readonly State m_State;

    public Measurement(double measurement, State state, double sd = 1.0)
        : base(new[] { sd }, state)
        m_State = state;
        m_Measurement = measurement;

    protected override double[] OnComputeError()
        var error = m_Measurement - m_State;

        return new[] { error };


For easy compilation, we included necessary parts of G2O and Eigen in the repository.


This library is licensed under the MIT License