Skip to content

Commit

Permalink
Merge pull request #22 from rpl-cmu/easton/examples
Browse files Browse the repository at this point in the history
Examples
  • Loading branch information
contagon authored Dec 10, 2024
2 parents 99e4f57 + 1e4dc78 commit 34a6964
Show file tree
Hide file tree
Showing 29 changed files with 24,621 additions and 199 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: default
run: cargo test
- name: serde
run: cargo test --features="serde,serde_json"
run: cargo test --features serde
- name: f32
run: cargo test --features f32
- name: left
Expand Down
10 changes: 7 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository = "https://github.com/rpl-cmu/factrs"
keywords = ["nonlinear", "optimization", "robotics", "estimation", "SLAM"]
categories = ["science::robotics", "mathematics"]
rust-version = "1.81"
exclude = ["examples/data/*"]

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

[dependencies]
# base
ahash = "0.8.11"
foldhash = "0.1.3"
paste = "1.0.15"
downcast-rs = "1.2.1"
log = "0.4.22"
Expand All @@ -40,7 +40,6 @@ matrixcompare = { version = "0.3" }
# serialization
serde = { version = "1.0.214", optional = true }
typetag = { version = "0.2.18", optional = true, path = "./factrs-typetag" }
serde_json = { version = "1.0.132", optional = true }

# rerun support
rerun = { version = "0.20", optional = true, default-features = false, features = [
Expand All @@ -66,11 +65,7 @@ serde = [
"dep:typetag",
"factrs-proc/serde",
"nalgebra/serde-serialize",
"faer/serde",
"ahash/serde",
]
# just used for examples
serde_json = ["dep:serde_json"]

# Support for conversion to rerun variable types
rerun = ["dep:rerun"]
Expand All @@ -79,14 +74,8 @@ rerun = ["dep:rerun"]
matrixcompare = "0.3.0"
pretty_env_logger = "0.5"
nalgebra = { version = "0.33.2", features = ["compare"] }

[[example]]
name = "g2o"

[[example]]
name = "g2o-rerun"
required-features = ["rerun"]
serde_json = { version = "1.0.132" }

[[example]]
name = "serde"
required-features = ["serde", "serde_json"]
required-features = ["serde"]
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ Currently, it supports the following features

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

# Example
# Examples
There's a number of examples found in the [examples](/examples/) folder, including loading g20 files, serialization, and custom factors.

To run any of the examples, simply clone this repository and run,
```bash
cargo run --release --example g20 ./examples/data/M3500.g20
```
to visualize the optimization steps with [rerun](https://rerun.io) simply add `--features rerun` to the above command.

Running the other examples can be done similarly,
```bash
cargo run --release --example serde --features serde
cargo run --release --example gps
```

Additionally, we recommend checking out the [tests](/tests/) folder for more examples of custom noise models, residuals, robust kernels, and variables.

<details>
<summary>Full Example</summary>

```rust
use factrs::{
Expand Down Expand Up @@ -55,7 +73,7 @@ graph.add_factor(factor);
let res = BetweenResidual::new(y.minus(&x));
let robust = Huber::default();
let factor = fac![res, (X(0), X(1)), 0.1 as std, robust];
// The same as above, but verbose
// fac! is syntactic sugar for the following
// let noise = GaussianNoise::from_scalar_sigma(0.1);
// let factor = FactorBuilder::new2(res, X(0), X(1))
// .noise(noise)
Expand All @@ -73,6 +91,8 @@ Simply add via cargo as you do any rust dependency,
```bash
cargo add factrs
```
</details>


# Contributions

Expand Down
Loading

0 comments on commit 34a6964

Please sign in to comment.