Skip to content

Commit fe07b5b

Browse files
authored
Merge pull request #29 from rpl-cmu/prep-release
Release v0.2.0
2 parents aa86c7c + 51298f1 commit fe07b5b

File tree

8 files changed

+65
-52
lines changed

8 files changed

+65
-52
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "factrs"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
license = "MIT"
66
description = "Factor graph optimization for robotics"
@@ -32,8 +32,9 @@ foldhash = "0.1.4"
3232
paste = "1.0.15"
3333
downcast-rs = "2.0.1"
3434
log = "0.4.22"
35-
factrs-proc = { version = "0.1.0", path = "./factrs-proc" }
3635
pad-adapter = "0.1.1"
36+
dyn-clone = "1.0.17"
37+
factrs-proc = { version = "0.2.0", path = "./factrs-proc" }
3738

3839
# numerical
3940
faer = { version = "0.20.2", default-features = false, features = [
@@ -43,19 +44,18 @@ faer = { version = "0.20.2", default-features = false, features = [
4344
] }
4445
faer-ext = { version = "0.4.1", features = ["nalgebra"] }
4546
nalgebra = { version = "0.33.2", features = ["compare"] }
47+
simba = { version = "0.9.0", default-features = false }
4648
num-dual = "0.11.0"
4749
matrixcompare = { version = "0.3.0" }
4850

4951
# serialization
5052
serde = { version = "1.0.217", optional = true }
51-
typetag = { version = "0.2.18", optional = true, path = "./factrs-typetag" }
53+
factrs-typetag = { version = "0.2.0", optional = true, path = "./factrs-typetag" }
5254

5355
# rerun support
5456
rerun = { version = "0.21.0", optional = true, default-features = false, features = [
5557
"sdk",
5658
] }
57-
simba = { version = "0.9.0", default-features = false }
58-
dyn-clone = "1.0.17"
5959

6060

6161
[features]
@@ -74,7 +74,7 @@ rayon = ["faer/rayon"]
7474
# Add support for serialization
7575
serde = [
7676
"dep:serde",
77-
"dep:typetag",
77+
"dep:factrs-typetag",
7878
"factrs-proc/serde",
7979
"nalgebra/serde-serialize",
8080
]

factrs-bench/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "factrs-bench"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55

66
[dependencies]
77
nalgebra = { version = "0.33", features = ["compare"] }
8-
factrs = { version = "0.1.0", path = ".." }
8+
factrs = { version = "0.2.0", path = ".." }
99
tiny-solver = { git = "https://github.com/contagon/tiny-solver-rs", branch = "rayon" }
1010

1111
[dev-dependencies]

factrs-proc/Cargo.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
[package]
22
name = "factrs-proc"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
5+
license = "MIT"
6+
description = "Proc-macros for factrs"
7+
authors = ["Easton Potokar", "Taylor Pool"]
8+
repository = "https://github.com/rpl-cmu/factrs"
9+
keywords = ["nonlinear", "optimization", "robotics", "estimation", "SLAM"]
10+
categories = ["science::robotics", "mathematics"]
11+
rust-version = "1.83"
512

613
[lib]
714
name = "factrs_proc"
815
path = "src/lib.rs"
916
proc-macro = true
1017

1118
[dependencies]
12-
proc-macro2 = "1.0.89"
13-
quote = "1.0.37"
14-
syn = { version = "2.0.87", features = ["full"] }
19+
proc-macro2 = "1.0.93"
20+
quote = "1.0.38"
21+
syn = { version = "2.0.96", features = ["full"] }
1522

1623
[features]
1724
serde = []

src/containers/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub struct DefaultSymbolHandler;
5858

5959
impl DefaultSymbolHandler {
6060
pub fn sym_to_key(chr: char, idx: u32) -> Key {
61-
Key((chr as u64) << IDX_SIZE | idx as u64 & IDX_MASK)
61+
Key(((chr as u64) << IDX_SIZE) | (idx as u64 & IDX_MASK))
6262
}
6363

6464
pub fn key_to_sym(k: Key) -> (char, u32) {

src/variables/so3.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,21 @@ impl<T: Numeric> Variable for SO3<T> {
160160

161161
fn log(&self) -> VectorX<T> {
162162
let xi = vectorx![self.xyzw.x, self.xyzw.y, self.xyzw.z];
163-
// Abs value in case we had a negative quaternion
164-
let w = self.xyzw.w.abs();
163+
let w = self.xyzw.w;
165164

166-
let norm_v = xi.norm();
167-
if norm_v < T::from(1e-3) {
168-
xi * T::from(2.0)
165+
let norm_v2 = xi.norm_squared();
166+
let scale = if norm_v2 < T::from(1e-6) {
167+
// Here we don't have to worry about the sign as it'll cancel out
168+
T::from(2.0) / w - T::from(2.0 / 3.0) * norm_v2 / (w * w * w)
169169
} else {
170-
xi * norm_v.atan2(w) * T::from(2.0) / norm_v
171-
}
170+
// flip both xi and w sign here (to reduce multiplications)
171+
#[rustfmt::skip]
172+
let sign = if w.is_sign_positive() { T::one() } else { T::from(-1.0) };
173+
let norm_v = norm_v2.sqrt();
174+
sign * norm_v.atan2(sign * w) * T::from(2.0) / norm_v
175+
};
176+
177+
xi * scale
172178
}
173179

174180
fn cast<TT: Numeric + SupersetOf<Self::T>>(&self) -> Self::Alias<TT> {

tests/custom_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ impl DoubleCharHandler {
3232
debug_assert!(chr1.is_ascii());
3333
debug_assert!(chr2.is_ascii());
3434

35-
Key((chr1 as u64) << IDX_SIZE << CHR_SIZE
36-
| (chr2 as u64) << IDX_SIZE
35+
Key(((chr1 as u64) << IDX_SIZE << CHR_SIZE)
36+
| ((chr2 as u64) << IDX_SIZE)
3737
| (idx as u64) & IDX_MASK)
3838
}
3939

0 commit comments

Comments
 (0)