[][src]Struct k::node::Node

pub struct Node<T: RealField>(_);

Parts of Chain

It contains joint, joint (transform), and parent/children.

Methods

impl<T> Node<T> where
    T: RealField
[src]

pub fn new(joint: Joint<T>) -> Self[src]

pub fn joint(&self) -> JointRefGuard<T>[src]

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

pub fn parent(&self) -> Option<Node<T>>[src]

pub fn children(&self) -> ChildrenRefGuard<T>[src]

Important traits for Ancestors<T>
pub fn iter_ancestors(&self) -> Ancestors<T>[src]

iter from the end to root, it contains nodes[id] itself

Important traits for Descendants<T>
pub fn iter_descendants(&self) -> Descendants<T>[src]

iter to the end, it contains nodes[id] itself

pub fn set_parent(&self, parent: &Node<T>)[src]

Set parent and child relations at same time

pub fn is_root(&self) -> bool[src]

Examples

use k::*;

let l0 = k::JointBuilder::<f32>::new().into_node();
let l1 = k::JointBuilder::new().into_node();
l1.set_parent(&l0);
assert!(l0.is_root());
assert!(!l1.is_root());

pub fn is_end(&self) -> bool[src]

Examples

let l0 = k::JointBuilder::<f64>::new().into_node();
let l1 = k::JointBuilder::new().into_node();
l1.set_parent(&l0);
assert!(!l0.is_end());
assert!(l1.is_end());

pub fn set_origin(&self, trans: Isometry3<T>)[src]

Set the origin transform of the joint

pub fn set_joint_position(&self, position: T) -> Result<(), JointError>[src]

Set the position (angle) of the joint

If position is out of limit, it returns Err.

Examples

use k::*;
let l0 = JointBuilder::new()
    .joint_type(JointType::Linear{axis: Vector3::z_axis()})
    .limits(Some((0.0..=2.0).into()))
    .into_node();
assert!(l0.set_joint_position(1.0).is_ok());
assert!(l0.set_joint_position(-1.0).is_err());

Setting position for Fixed joint is error.

use k::*;
let l0 = JointBuilder::new()
    .joint_type(JointType::Fixed)
    .into_node();
assert!(l0.set_joint_position(0.0).is_err());

k::joint::Mimic can be used to copy other joint's position.

use k::*;
let j0 = JointBuilder::new()
    .joint_type(JointType::Linear{axis: Vector3::z_axis()})
    .limits(Some((0.0..=2.0).into()))
    .into_node();
let j1 = JointBuilder::new()
    .joint_type(JointType::Linear{axis: Vector3::z_axis()})
    .limits(Some((0.0..=2.0).into()))
    .into_node();
j1.set_mimic_parent(&j0, k::joint::Mimic::new(1.5, 0.1));
assert_eq!(j0.joint_position().unwrap(), 0.0);
assert_eq!(j1.joint_position().unwrap(), 0.0);
assert!(j0.set_joint_position(1.0).is_ok());
assert_eq!(j0.joint_position().unwrap(), 1.0);
assert_eq!(j1.joint_position().unwrap(), 1.6);

pub fn set_joint_position_unchecked(&self, position: T)[src]

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

Get the calculated world transform. Call Chain::update_transforms() before using this method.

Examples

use k::*;
use k::prelude::*;

let l0 = JointBuilder::new()
    .translation(Translation3::new(0.0, 0.0, 0.2))
    .joint_type(JointType::Rotational{axis: Vector3::y_axis()})
    .into_node();
let l1 = JointBuilder::new()
    .translation(Translation3::new(0.0, 0.0, 1.0))
    .joint_type(JointType::Linear{axis: Vector3::z_axis()})
    .into_node();
l1.set_parent(&l0);
let tree = Chain::<f64>::from_root(l0);
tree.set_joint_positions(&vec![3.141592 * 0.5, 0.1]).unwrap();
assert!(l1.world_transform().is_none());
assert!(l1.world_transform().is_none());
let _poses = tree.update_transforms();
assert!((l1.world_transform().unwrap().translation.vector.x - 1.1).abs() < 0.0001);
assert!((l1.world_transform().unwrap().translation.vector.z - 0.2).abs() < 0.0001);

// _poses[0] is as same as l0.world_transform()
// _poses[1] is as same as l1.world_transform()

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

pub fn set_mimic_parent(&self, parent: &Node<T>, mimic: Mimic<T>)[src]

Trait Implementations

impl<T> Clone for Node<T> where
    T: RealField
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T> PartialEq<Node<T>> for Node<T> where
    T: RealField
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<T> From<Joint<T>> for Node<T> where
    T: RealField
[src]

impl<T: RealField> Display for Node<T>[src]

impl<T: Debug + RealField> Debug for Node<T>[src]

Auto Trait Implementations

impl<T> !Send for Node<T>

impl<T> !Sync for Node<T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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