Skip to content

Commit 40a6fc2

Browse files
committed
fix animated_urdf (log full transforms, not just updates)
1 parent 068b0fc commit 40a6fc2

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ dependencies = [
281281
"anyhow",
282282
"clap",
283283
"emath",
284+
"glam",
284285
"rerun",
285286
]
286287

examples/rust/animated_urdf/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ rerun = { path = "../../../crates/top/rerun", features = ["clap", "data_loaders"
1212
anyhow.workspace = true
1313
clap = { workspace = true, features = ["derive"] }
1414
emath.workspace = true
15+
glam.workspace = true

examples/rust/animated_urdf/src/main.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,28 @@ fn run(rec: &rerun::RecordingStream, _args: &Args) -> anyhow::Result<()> {
4949
joint.limit.lower..=joint.limit.upper,
5050
);
5151

52+
// Compute the full rotation for this joint.
53+
// TODO(michael): we could make this a bit nicer with a better URDF utility.
54+
let rotation = glam::Quat::from_euler(
55+
glam::EulerRot::XYZ,
56+
joint.origin.rpy[0] as f32,
57+
joint.origin.rpy[1] as f32,
58+
joint.origin.rpy[2] as f32,
59+
) * glam::Quat::from_axis_angle(
60+
glam::Vec3::new(
61+
fixed_axis[0] as f32,
62+
fixed_axis[1] as f32,
63+
fixed_axis[2] as f32,
64+
),
65+
dynamic_angle as f32,
66+
);
67+
5268
// Rerun loads the URDF transforms with child/parent frame relations.
5369
// In order to move a joint, we just need to log a new transform between two of those frames.
5470
rec.log(
5571
"/transforms",
56-
&rerun::Transform3D::from_rotation(rerun::RotationAxisAngle::new(
57-
fixed_axis,
58-
dynamic_angle as f32,
72+
&rerun::Transform3D::from_rotation(rerun::Quaternion::from_xyzw(
73+
rotation.to_array(),
5974
))
6075
.with_translation(Translation3D::from(joint.origin.xyz.0))
6176
.with_parent_frame(joint.parent.link.clone())

0 commit comments

Comments
 (0)