Skip to content

Commit

Permalink
convert quaternion to roll-pitch-yaw in tf_echo
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasw committed Sep 16, 2024
1 parent c7ef97f commit 67272bd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tf_roslibrust/src/bin/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ async fn main() -> Result<(), anyhow::Error> {
println!("- Translation: [{:.3} {:.3} {:.3}]", xyz.x, xyz.y, xyz.z);
let quat = tf.transform.rotation;
println!(
"- Rotation: [{:.3} {:.3} {:.3} {:.3}]",
"- Rotation: in Quaternion [{:.6} {:.6} {:.6} {:.6}]",
quat.x, quat.y, quat.z, quat.w
);

// nalgebra documentation ought to say what components are in what place in this
// constructor
let unit_quat = nalgebra::UnitQuaternion::from_quaternion(
nalgebra::Quaternion::new(quat.w, quat.x, quat.y, quat.z),
);
let (roll, pitch, yaw) = unit_quat.euler_angles();
println!(" in RPY (radian) [{roll:.6} {pitch:.6} {yaw:.6}]",);
}
Err(err) => {
println!("{t1:?} {err:?}");
Expand Down

0 comments on commit 67272bd

Please sign in to comment.