diff --git a/Cargo.lock b/Cargo.lock index 8eb10b39..ad34a625 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -747,6 +747,7 @@ dependencies = [ "deku", "nalgebra 0.30.1", "nalgebra 0.31.4", + "nalgebra 0.32.1", ] [[package]] @@ -1367,11 +1368,11 @@ checksum = "4fb2d0de08694bed883320212c18ee3008576bfe8c306f4c3c4a58b4876998be" dependencies = [ "approx", "matrixmultiply", - "nalgebra-macros", + "nalgebra-macros 0.1.0", "num-complex", "num-rational", "num-traits", - "simba", + "simba 0.7.3", "typenum", ] @@ -1383,11 +1384,27 @@ checksum = "20bd243ab3dbb395b39ee730402d2e5405e448c75133ec49cc977762c4cba3d1" dependencies = [ "approx", "matrixmultiply", - "nalgebra-macros", + "nalgebra-macros 0.1.0", "num-complex", "num-rational", "num-traits", - "simba", + "simba 0.7.3", + "typenum", +] + +[[package]] +name = "nalgebra" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6515c882ebfddccaa73ead7320ca28036c4bc84c9bcca3cc0cbba8efe89223a" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros 0.2.0", + "num-complex", + "num-rational", + "num-traits", + "simba 0.8.0", "typenum", ] @@ -1402,6 +1419,17 @@ dependencies = [ "syn", ] +[[package]] +name = "nalgebra-macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -2126,6 +2154,19 @@ dependencies = [ "wide", ] +[[package]] +name = "simba" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + [[package]] name = "skeletal_model" version = "0.0.0" diff --git a/networking/firmware_protocol/Cargo.toml b/networking/firmware_protocol/Cargo.toml index 6087bb41..70dfac57 100644 --- a/networking/firmware_protocol/Cargo.toml +++ b/networking/firmware_protocol/Cargo.toml @@ -7,9 +7,11 @@ edition = "2021" [dependencies] deku = { version = "0.15", default-features = false, features = ["alloc"] } # We support multiple versions of nalgebra since it changes so much. +nalgebra032 = { package = "nalgebra", version = "0.32", default-features = false, optional = true } nalgebra031 = { package = "nalgebra", version = "0.31", default-features = false, optional = true } nalgebra030 = { package = "nalgebra", version = "0.30", default-features = false, optional = true } [dev-dependencies] +nalgebra032 = { package = "nalgebra", version = "0.32" } nalgebra031 = { package = "nalgebra", version = "0.31" } nalgebra030 = { package = "nalgebra", version = "0.30" } diff --git a/networking/firmware_protocol/src/lib.rs b/networking/firmware_protocol/src/lib.rs index 81c3affa..83d7ff74 100644 --- a/networking/firmware_protocol/src/lib.rs +++ b/networking/firmware_protocol/src/lib.rs @@ -26,47 +26,42 @@ pub struct SlimeQuaternion { pub w: f32, } -#[cfg(any(test, feature = "nalgebra031"))] -mod nalgebra031_impls { - use super::*; - use nalgebra031::Quaternion; - - impl From> for SlimeQuaternion { - fn from(q: Quaternion) -> Self { - Self { - i: q.i as _, - j: q.j as _, - k: q.k as _, - w: q.w as _, +#[allow(unused_macros)] +macro_rules! impl_Nalgebra { + () => { + use super::*; + impl From> for SlimeQuaternion { + fn from(q: Quaternion) -> Self { + Self { + i: q.i, + j: q.j, + k: q.k, + w: q.w, + } } } - } - impl From for Quaternion { - fn from(q: SlimeQuaternion) -> Self { - Self::new(q.w as _, q.i as _, q.j as _, q.k as _) + impl From for Quaternion { + fn from(q: SlimeQuaternion) -> Self { + Self::new(q.w, q.i, q.j, q.k) + } } - } + }; +} + +#[cfg(any(test, feature = "nalgebra032"))] +mod nalgebra032_impls { + use nalgebra032::Quaternion; + impl_Nalgebra!(); +} +#[cfg(any(test, feature = "nalgebra031"))] +mod nalgebra031_impls { + use nalgebra031::Quaternion; + impl_Nalgebra!(); } #[cfg(any(test, feature = "nalgebra030"))] mod nalgebra030_impls { - use super::*; use nalgebra030::Quaternion; - - impl From> for SlimeQuaternion { - fn from(q: Quaternion) -> Self { - Self { - i: q.i as _, - j: q.j as _, - k: q.k as _, - w: q.w as _, - } - } - } - impl From for Quaternion { - fn from(q: SlimeQuaternion) -> Self { - Self::new(q.w as _, q.i as _, q.j as _, q.k as _) - } - } + impl_Nalgebra!(); } #[derive(PartialEq, Eq, Debug, DekuRead, DekuWrite)]