Skip to content

Commit 34a6964

Browse files
authored
Merge pull request #22 from rpl-cmu/easton/examples
Examples
2 parents 99e4f57 + 1e4dc78 commit 34a6964

File tree

29 files changed

+24621
-199
lines changed

29 files changed

+24621
-199
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: default
5050
run: cargo test
5151
- name: serde
52-
run: cargo test --features="serde,serde_json"
52+
run: cargo test --features serde
5353
- name: f32
5454
run: cargo test --features f32
5555
- name: left

Cargo.lock

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repository = "https://github.com/rpl-cmu/factrs"
1010
keywords = ["nonlinear", "optimization", "robotics", "estimation", "SLAM"]
1111
categories = ["science::robotics", "mathematics"]
1212
rust-version = "1.81"
13+
exclude = ["examples/data/*"]
1314

1415
[workspace]
1516
members = ["factrs-proc"]
@@ -19,8 +20,7 @@ exclude = ["factrs-typetag"]
1920
rustdoc-args = ["--html-in-header", "assets/katex-header.html"]
2021

2122
[dependencies]
22-
# base
23-
ahash = "0.8.11"
23+
foldhash = "0.1.3"
2424
paste = "1.0.15"
2525
downcast-rs = "1.2.1"
2626
log = "0.4.22"
@@ -40,7 +40,6 @@ matrixcompare = { version = "0.3" }
4040
# serialization
4141
serde = { version = "1.0.214", optional = true }
4242
typetag = { version = "0.2.18", optional = true, path = "./factrs-typetag" }
43-
serde_json = { version = "1.0.132", optional = true }
4443

4544
# rerun support
4645
rerun = { version = "0.20", optional = true, default-features = false, features = [
@@ -66,11 +65,7 @@ serde = [
6665
"dep:typetag",
6766
"factrs-proc/serde",
6867
"nalgebra/serde-serialize",
69-
"faer/serde",
70-
"ahash/serde",
7168
]
72-
# just used for examples
73-
serde_json = ["dep:serde_json"]
7469

7570
# Support for conversion to rerun variable types
7671
rerun = ["dep:rerun"]
@@ -79,14 +74,8 @@ rerun = ["dep:rerun"]
7974
matrixcompare = "0.3.0"
8075
pretty_env_logger = "0.5"
8176
nalgebra = { version = "0.33.2", features = ["compare"] }
82-
83-
[[example]]
84-
name = "g2o"
85-
86-
[[example]]
87-
name = "g2o-rerun"
88-
required-features = ["rerun"]
77+
serde_json = { version = "1.0.132" }
8978

9079
[[example]]
9180
name = "serde"
92-
required-features = ["serde", "serde_json"]
81+
required-features = ["serde"]

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,25 @@ Currently, it supports the following features
2020

2121
We recommend you checkout the [docs](https://docs.rs/factrs/latest/factrs/) for more info.
2222

23-
# Example
23+
# Examples
24+
There's a number of examples found in the [examples](/examples/) folder, including loading g20 files, serialization, and custom factors.
25+
26+
To run any of the examples, simply clone this repository and run,
27+
```bash
28+
cargo run --release --example g20 ./examples/data/M3500.g20
29+
```
30+
to visualize the optimization steps with [rerun](https://rerun.io) simply add `--features rerun` to the above command.
31+
32+
Running the other examples can be done similarly,
33+
```bash
34+
cargo run --release --example serde --features serde
35+
cargo run --release --example gps
36+
```
37+
38+
Additionally, we recommend checking out the [tests](/tests/) folder for more examples of custom noise models, residuals, robust kernels, and variables.
39+
40+
<details>
41+
<summary>Full Example</summary>
2442

2543
```rust
2644
use factrs::{
@@ -55,7 +73,7 @@ graph.add_factor(factor);
5573
let res = BetweenResidual::new(y.minus(&x));
5674
let robust = Huber::default();
5775
let factor = fac![res, (X(0), X(1)), 0.1 as std, robust];
58-
// The same as above, but verbose
76+
// fac! is syntactic sugar for the following
5977
// let noise = GaussianNoise::from_scalar_sigma(0.1);
6078
// let factor = FactorBuilder::new2(res, X(0), X(1))
6179
// .noise(noise)
@@ -73,6 +91,8 @@ Simply add via cargo as you do any rust dependency,
7391
```bash
7492
cargo add factrs
7593
```
94+
</details>
95+
7696

7797
# Contributions
7898

0 commit comments

Comments
 (0)