Crates.io | factrs |
lib.rs | factrs |
version | 0.1.0 |
source | src |
created_at | 2024-10-04 20:06:30.036846 |
updated_at | 2024-10-04 20:06:30.036846 |
description | Factor graph optimization for robotics |
homepage | |
repository | https://github.com/rpl-cmu/factrs |
max_upload_size | |
id | 1397029 |
size | 357,261 |
factrs is a nonlinear least squares optimization library over factor graphs written in Rust.
It is specifically geared toward sensor fusion in robotics. It aims to be fast, easy to use, and safe. The factrs API takes heavy inspiration from the gtsam library.
Currently, it supports the following features
We recommend you checkout the docs for more info.
use factrs::{
assign_symbols,
containers::{FactorBuilder, Graph, Values},
noise::GaussianNoise,
optimizers::GaussNewton,
residuals::{BetweenResidual, PriorResidual},
robust::Huber,
traits::*,
variables::SO2,
};
// Assign symbols to variable types
assign_symbols!(X: SO2);
// Make all the values
let mut values = Values::new();
let x = SO2::from_theta(1.0);
let y = SO2::from_theta(2.0);
values.insert(X(0), SO2::identity());
values.insert(X(1), SO2::identity());
// Make the factors & insert into graph
let mut graph = Graph::new();
let res = PriorResidual::new(x.clone());
let factor = FactorBuilder::new1(res, X(0)).build();
graph.add_factor(factor);
let res = BetweenResidual::new(y.minus(&x));
let noise = GaussianNoise::from_scalar_sigma(0.1);
let robust = Huber::default();
let factor = FactorBuilder::new2(res, X(0), X(1))
.noise(noise)
.robust(robust)
.build();
graph.add_factor(factor);
// Optimize!
let mut opt: GaussNewton = GaussNewton::new(graph);
let result = opt.optimize(values);
Simply add via cargo as you do any rust dependency,
cargo add factrs
Contributions are more than welcome! Feel free to open an issue or a pull request with any ideas, bugs, features, etc you might have or want.
We feel rust and robotics are a good match and want to see rust robotics libraries catch-up to their C++ counterparts.