Skip to content

Commit

Permalink
use more concise unwrap_or() for default roll-pitch-yaw
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasw committed Sep 11, 2024
1 parent c7b6ade commit a3a73d9
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions tf_roslibrust/src/bin/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,9 @@ fn get_transforms(filename: &str) -> Result<tf2_msgs::TFMessage, anyhow::Error>
transform.transform.translation.z = z;
}

let roll = {
if let Some(roll) = tfr.roll {
roll
} else {
0.0
}
};
let pitch = {
if let Some(pitch) = tfr.pitch {
pitch
} else {
0.0
}
};
let yaw = {
if let Some(yaw) = tfr.yaw {
yaw
} else {
0.0
}
};
let roll = tfr.roll.unwrap_or(0.0);
let pitch = tfr.pitch.unwrap_or(0.0);
let yaw = tfr.yaw.unwrap_or(0.0);

let unit_quat = nalgebra::UnitQuaternion::from_euler_angles(roll, pitch, yaw);
let quat = unit_quat.quaternion();
Expand Down

0 comments on commit a3a73d9

Please sign in to comment.