pub struct Transform {
pub translation: Option<(f32, f32, f32)>,
pub rotation: Option<(f32, f32, f32)>,
}Expand description
A Transform type to represent the transform from the parent coordinate system to a new coordinate system.
A transform starts from the origin of the parent element and first translates to the origin of the child element,
after which a new coordinate system gets by rotating the parent coordinate system over the specified roll, pitch and yaw angles.
The translation is applied first and uses the axes of the parent coordinate system. The translation is specified in meters.
The rotation is applied next and rotates the parent axes with the specified roll, pitch and yaw angles in radians.
In URDF this element is often refered to as <origin>.
Fields§
§translation: Option<(f32, f32, f32)>The translation of origin of the new coordinate system in meters.
rotation: Option<(f32, f32, f32)>The rotation of the new coordinate system in radians.
Implementations§
Source§impl Transform
impl Transform
Sourcepub fn new(xyz: (f32, f32, f32), rpy: (f32, f32, f32)) -> Self
pub fn new(xyz: (f32, f32, f32), rpy: (f32, f32, f32)) -> Self
Creates a new Transform.
Creates a new Transform from a tuple of cartesian coordinates in meters as f32 and a tuple of roll-pitch-yaw angles in radians as f32.
§Example
use robot_description_builder::Transform;
use std::f32::consts::PI;
let transform = Transform::new((1., 1000., 0.), (0., PI, 0.));
assert_eq!(
transform,
Transform {
translation: Some((1., 1000., 0.)),
rotation: Some((0., PI, 0.)),
}
)Sourcepub fn new_translation(x: f32, y: f32, z: f32) -> Self
pub fn new_translation(x: f32, y: f32, z: f32) -> Self
Creates a new Transform from cartesian x, y and z coordinates.
Creates a new Transform from a tuple of cartesian coordinates in meters as f32 and leaves the other values at the default.
§Example
use robot_description_builder::Transform;
let transform = Transform::new_translation( -0.6, 10., 900.);
assert_eq!(
transform,
Transform {
translation: Some((-0.6, 10., 900.)),
rotation: None,
}
)Sourcepub fn new_rotation(r: f32, p: f32, y: f32) -> Self
pub fn new_rotation(r: f32, p: f32, y: f32) -> Self
Creates a new Transform from roll-pitch-yaw angles.
Creates a new Transform from the roll-pitch-yaw angles in radians as f32 and leaves the other values at the default.
§Example
use robot_description_builder::Transform;
use std::f32::consts::PI;
let transform = Transform::new_rotation( 0., PI, 0.);
assert_eq!(
transform,
Transform {
translation: None,
rotation: Some((0., PI, 0.)),
}
)Sourcepub fn contains_some(&self) -> bool
pub fn contains_some(&self) -> bool
A function to check if any of the fields are set.
It doesn’t check if the some fields have the default value, since it can be format depended.
§Example
assert!(Transform {
translation: Some((1., 2., 3.)),
rotation: Some((4., 5., 6.))
}
.contains_some());
assert!(Transform {
translation: Some((1., 2., 3.)),
..Default::default()
}
.contains_some());
assert!(Transform {
rotation: Some((4., 5., 6.)),
..Default::default()
}
.contains_some());
assert!(!Transform::default().contains_some())Trait Implementations§
impl Copy for Transform
impl StructuralPartialEq for Transform
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.