Struct robot_description_builder::Transform
source · 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§
source§impl PartialEq for Transform
impl PartialEq for Transform
impl Copy for Transform
impl StructuralPartialEq for Transform
Auto Trait Implementations§
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.