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

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

Parts of Chain

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

Implementations

impl<T> Node<T> where
    T: RealField + SubsetOf<f64>, 
[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]

pub fn iter_ancestors(&self) -> Ancestors<T>

Notable traits for Ancestors<T>

impl<T> Iterator for Ancestors<T> where
    T: RealField + SubsetOf<f64>, 
type Item = Node<T>;
[src]

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

pub fn iter_descendants(&self) -> Descendants<T>

Notable traits for Descendants<T>

impl<T> Iterator for Descendants<T> where
    T: RealField + SubsetOf<f64>, 
type Item = Node<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 remove_parent(&self, parent: &Node<T>)[src]

Remove parent and child relations at same time

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

Examples

use k::*;

let l0 = k::NodeBuilder::<f32>::new().into_node();
let l1 = k::NodeBuilder::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::NodeBuilder::<f64>::new().into_node();
let l1 = k::NodeBuilder::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 origin(&self) -> Isometry3<T>[src]

Get the origin transform of the joint

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

Set the position (angle) of the joint

If position is out of limit, it returns Err.

Examples

use k::*;
let l0 = NodeBuilder::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 = NodeBuilder::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 = NodeBuilder::new()
    .joint_type(JointType::Linear{axis: Vector3::z_axis()})
    .limits(Some((0.0..=2.0).into()))
    .into_node();
let j1 = NodeBuilder::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_clamped(&self, position: T)[src]

Set the clamped position (angle) of the joint

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

Examples

use k::*;
let l0 = NodeBuilder::new()
    .joint_type(JointType::Linear{axis: Vector3::z_axis()})
    .limits(Some((-1.0..=1.0).into()))
    .into_node();
l0.set_joint_position_clamped(2.0);
assert_eq!(l0.joint().joint_position(), Some(1.0));
l0.set_joint_position_clamped(-2.0);
assert_eq!(l0.joint().joint_position(), Some(-1.0));

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 = NodeBuilder::new()
    .translation(Translation3::new(0.0, 0.0, 0.2))
    .joint_type(JointType::Rotational{axis: Vector3::y_axis()})
    .into_node();
let l1 = NodeBuilder::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 mimic_parent(&self) -> Option<Node<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]

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

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

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

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

Auto Trait Implementations

impl<T> RefUnwindSafe for Node<T>

impl<T> Send for Node<T>

impl<T> Sync for Node<T>

impl<T> Unpin for Node<T>

impl<T> UnwindSafe for Node<T>

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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>, 
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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.