Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
contagon committed Aug 13, 2024
1 parent 66fb33c commit 35b3e9a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ We recommend you checkout the [docs](https://docs.rs/factrs/latest/factrs/) (WIP
```rust
use factrs::prelude::*;

// 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());
Expand All @@ -28,13 +32,16 @@ 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 = Factor::new_base(&[X(0)], res);
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 = Factor::new_full(&[X(0), X(1)], res, noise, robust);
let factor = FactorBuilder::new2(res, X(0), X(1))
.noise(noise)
.robust(robust)
.build();
graph.add_factor(factor);

// Optimize!
Expand Down

0 comments on commit 35b3e9a

Please sign in to comment.