Skip to content

Commit

Permalink
Make urdf-rs dependency optional for rmf_site_format
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Sep 12, 2024
1 parent 29f290a commit ef513f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions rmf_site_format/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ thiserror = "*"
glam = { version = "0.24", features = ["serde"] }
uuid = { version = "1.1", features = ["v4", "serde"] }
# add features=["bevy"] to a dependent Cargo.toml to get the bevy-related features
# We depend on a bugfix released specifically in 0.7.3
bevy = { version = "0.12", optional = true }
sdformat_rs = { git = "https://github.com/open-rmf/sdf_rust_experimental", rev = "9fc35f2"}
yaserde = "0.7"
urdf-rs = "0.7.3"
# We depend on a bugfix released specifically in 0.7.3
urdf-rs = { version = "0.7.3", optional = true }
# Used for lazy initialization of static variable when they are non const
once_cell = "1"
pathdiff = "*"

[dev-dependencies]
float_eq = "1.0"

[features]
urdf = ["dep:urdf-rs"]
6 changes: 4 additions & 2 deletions rmf_site_format/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::RefTrait;
#[cfg(feature = "bevy")]
use bevy::prelude::*;
use glam::{EulerRot, Quat, Vec2, Vec3};
use glam::{Quat, Vec2, Vec3};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

Expand Down Expand Up @@ -353,14 +353,15 @@ impl Default for Pose {
}
}

#[cfg(feature = "urdf")]
impl From<Pose> for urdf_rs::Pose {
fn from(pose: Pose) -> Self {
urdf_rs::Pose {
rpy: match pose.rot {
Rotation::EulerExtrinsicXYZ(arr) => urdf_rs::Vec3(arr.map(|v| v.radians().into())),
Rotation::Yaw(v) => urdf_rs::Vec3([0.0, 0.0, v.radians().into()]),
Rotation::Quat([x, y, z, w]) => {
let (z, y, x) = glam::quat(x, y, z, w).to_euler(EulerRot::ZYX);
let (z, y, x) = glam::quat(x, y, z, w).to_euler(glam::EulerRot::ZYX);
urdf_rs::Vec3([x as f64, y as f64, z as f64])
}
},
Expand All @@ -369,6 +370,7 @@ impl From<Pose> for urdf_rs::Pose {
}
}

#[cfg(feature = "urdf")]
impl From<&urdf_rs::Pose> for Pose {
fn from(pose: &urdf_rs::Pose) -> Self {
Pose {
Expand Down

0 comments on commit ef513f9

Please sign in to comment.