Struct k::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

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);

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);

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);

Returns the position (angle)

Returns the velocity

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);

Get the result of forward kinematics

The value is updated by Chain::update_transforms

Clear caches defined in the world coordinate

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

Should always be Self

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

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

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

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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