Struct k::joint::Joint

source ·
pub struct Joint<T: RealField> {
    pub name: String,
    pub joint_type: JointType<T>,
    pub limits: Option<Range<T>>,
    /* private fields */
}
Expand description

Joint with type

Fields§

§name: String

Name of this joint

§joint_type: JointType<T>

Type of this joint

§limits: Option<Range<T>>

Limits of this joint

Implementations§

source§

impl<T> Joint<T>where T: RealField + SubsetOf<f64>,

source

pub fn new(name: &str, joint_type: JointType<T>) -> Joint<T>

Create new Joint with name and type

Examples
use nalgebra as na;

// create fixed joint
let fixed = k::Joint::<f32>::new("f0", k::JointType::Fixed);
assert!(fixed.joint_position().is_none());

// create rotational joint with Y-axis
let rot = k::Joint::<f64>::new("r0", k::JointType::Rotational { axis: na::Vector3::y_axis() });
assert_eq!(rot.joint_position().unwrap(), 0.0);
source

pub fn set_joint_position(&mut self, position: T) -> Result<(), Error>

Set the position of the joint

It returns Err if it is out of the limits, or this is fixed joint.

Examples
use nalgebra as na;

// Create fixed joint
let mut fixed = k::Joint::<f32>::new("f0", k::JointType::Fixed);
// Set position to fixed joint always fails
assert!(fixed.set_joint_position(1.0).is_err());

// Create rotational joint with Y-axis
let mut rot = k::Joint::<f64>::new("r0", k::JointType::Rotational { axis: na::Vector3::y_axis() });
// As default, it has not limit

// Initial position is 0.0
assert_eq!(rot.joint_position().unwrap(), 0.0);
// If it has no limits, set_joint_position always succeeds.
rot.set_joint_position(0.2).unwrap();
assert_eq!(rot.joint_position().unwrap(), 0.2);
source

pub fn set_joint_position_clamped(&mut self, position: T)

Set the clamped position of the joint

It refers to the joint limit and clamps the argument. This function does nothing if this is fixed joint.

Examples
use nalgebra as na;

// Create rotational joint with Y-axis
let mut rot = k::Joint::<f64>::new("r0", k::JointType::Rotational { axis: na::Vector3::y_axis() });

let limits = k::joint::Range::new(-1.0, 1.0);
rot.limits = Some(limits);

// Initial position is 0.0
assert_eq!(rot.joint_position().unwrap(), 0.0);
rot.set_joint_position_clamped(2.0);
assert_eq!(rot.joint_position().unwrap(), 1.0);
rot.set_joint_position_clamped(-2.0);
assert_eq!(rot.joint_position().unwrap(), -1.0);
source

pub fn set_joint_position_unchecked(&mut self, position: T)

source

pub fn joint_position(&self) -> Option<T>

Returns the position (angle)

source

pub fn origin(&self) -> &Isometry3<T>

source

pub fn set_origin(&mut self, origin: Isometry3<T>)

source

pub fn set_joint_velocity(&mut self, velocity: T) -> Result<(), Error>

source

pub fn joint_velocity(&self) -> Option<T>

Returns the velocity

source

pub fn local_transform(&self) -> Isometry3<T>

Calculate and returns the transform of the end of this joint

Examples
use nalgebra as na;

// Create linear joint with X-axis
let mut lin = k::Joint::<f64>::new("l0", k::JointType::Linear { axis: na::Vector3::x_axis() });
assert_eq!(lin.local_transform().translation.vector.x, 0.0);
lin.set_joint_position(-1.0).unwrap();
assert_eq!(lin.local_transform().translation.vector.x, -1.0);
source

pub fn world_transform(&self) -> Option<Isometry3<T>>

Get the result of forward kinematics

The value is updated by Chain::update_transforms

source

pub fn world_velocity(&self) -> Option<Velocity<T>>

source

pub fn is_movable(&self) -> bool

source

pub fn clear_caches(&self)

Clear caches defined in the world coordinate

Trait Implementations§

source§

impl<T: Clone + RealField> Clone for Joint<T>

source§

fn clone(&self) -> Joint<T>

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<T: Debug + RealField> Debug for Joint<T>

source§

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

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

impl<T: RealField> Display for Joint<T>

source§

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

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

impl<'a, T> From<&'a Joint> for Joint<T>where T: RealField + SubsetOf<f64>,

source§

fn from(joint: &Joint) -> Joint<T>

Converts to this type from the input type.
source§

impl<T> From<Joint<T>> for Node<T>where T: RealField + SubsetOf<f64>,

source§

fn from(joint: Joint<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Joint<T>

§

impl<T> Send for Joint<T>

§

impl<T> !Sync for Joint<T>

§

impl<T> Unpin for Joint<T>where T: Unpin,

§

impl<T> UnwindSafe for Joint<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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
source§

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

source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

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

impl<T> ToOwned for Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more