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

source

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.)),
    }
)
source

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,
    }
)
source

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.)),
    }
)
source

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 Clone for Transform

source§

fn clone(&self) -> Transform

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Transform

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Transform

source§

fn default() -> Transform

Returns the “default value” for a type. Read more
source§

impl PartialEq for Transform

source§

fn eq(&self, other: &Transform) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToURDF for Transform

source§

fn to_urdf( &self, writer: &mut Writer<Cursor<Vec<u8>>>, _urdf_config: &URDFConfig ) -> Result<(), Error>

Represents the element as in URDF format.
source§

impl Copy for Transform

source§

impl StructuralPartialEq for Transform

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,