Struct k::SerialChain

source ·
pub struct SerialChain<T: RealField> { /* private fields */ }
Expand description

Kinematic chain without any branch.

All joints are connected sequentially.

Implementations§

source§

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

source

pub fn new_unchecked(inner: Chain<T>) -> Self

Convert Chain into SerialChain without any check

If the input Chain has any branches it causes serious bugs.

source

pub fn try_new(inner: Chain<T>) -> Option<Self>

Convert Chain into SerialChain

If the input Chain has any branches it fails.

Examples
let node = k::NodeBuilder::<f32>::new().into_node();
let chain = k::Chain::from_root(node);
assert!(k::SerialChain::try_new(chain).is_some());
let node0 = k::NodeBuilder::<f32>::new().into_node();
let node1 = k::NodeBuilder::new().into_node();
let node2 = k::NodeBuilder::new().into_node();
node1.set_parent(&node0);
node2.set_parent(&node0);
let chain = k::Chain::from_root(node0);
assert!(k::SerialChain::try_new(chain).is_none());
source

pub fn from_end(end_joint: &Node<T>) -> SerialChain<T>

Create SerialChain from the end Node

Examples
let node = k::NodeBuilder::<f32>::new().into_node();
let s_chain = k::SerialChain::from_end(&node);
source

pub fn from_end_to_root( end_joint: &Node<T>, root_joint: &Node<T> ) -> SerialChain<T>

Create SerialChain from the end Node and root Node.

Examples
let node0 = k::NodeBuilder::<f32>::new().into_node();
let node1 = k::NodeBuilder::<f32>::new().into_node();
let node2 = k::NodeBuilder::<f32>::new().into_node();
let node3 = k::NodeBuilder::<f32>::new().into_node();
use k::connect;
connect![node0 => node1 => node2 => node3];
let s_chain = k::SerialChain::from_end_to_root(&node2, &node1);
assert_eq!(s_chain.iter().count(), 2);
source

pub fn unwrap(self) -> Chain<T>

Safely unwrap and returns inner Chain instance

source

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

Calculate transform of the end joint

Methods from Deref<Target = Chain<T>>§

source

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

Set the Chain’s origin

Examples
use k::*;

let l0 = Node::new(Joint::new("fixed0", JointType::Fixed));
let l1 = Node::new(Joint::new("fixed1", JointType::Fixed));
l1.set_parent(&l0);
let c = Chain::<f32>::from_end(&l1);
let mut o = c.origin();
assert!(o.translation.vector[0].abs() < 0.000001);
o.translation.vector[0] = 1.0;
c.set_origin(o);
assert!((o.translation.vector[0] - 1.0).abs() < 0.000001);
source

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

Get the Chain’s origin

source

pub fn iter(&self) -> impl Iterator<Item = &Node<T>>

Iterate for all joint nodes

The order is from parent to children. You can assume that parent is already iterated.

Examples
use k::*;

let l0 = Node::new(Joint::new("fixed0", JointType::Fixed));
let l1 = Node::new(Joint::new("fixed1", JointType::Fixed));
l1.set_parent(&l0);
let tree = Chain::<f64>::from_root(l0);
let names = tree.iter().map(|node| node.joint().name.to_owned()).collect::<Vec<_>>();
assert_eq!(names.len(), 2);
assert_eq!(names[0], "fixed0");
assert_eq!(names[1], "fixed1");
source

pub fn iter_joints(&self) -> impl Iterator<Item = JointRefGuard<'_, T>>

Iterate for movable joints

Fixed joints are ignored. If you want to manipulate on Fixed, use iter() instead of iter_joints()

Iterate for links

source

pub fn dof(&self) -> usize

Calculate the degree of freedom

Examples
use k::*;
let l0 = NodeBuilder::new()
    .joint_type(JointType::Fixed)
    .finalize()
    .into();
let l1 : Node<f64> = NodeBuilder::new()
    .joint_type(JointType::Rotational{axis: Vector3::y_axis()})
    .finalize()
    .into();
l1.set_parent(&l0);
let tree = Chain::from_root(l0);
assert_eq!(tree.dof(), 1);
source

pub fn find(&self, joint_name: &str) -> Option<&Node<T>>

Find the joint by name

Examples
use k::*;

let l0 = Node::new(NodeBuilder::new()
    .name("fixed")
    .finalize());
let l1 = Node::new(NodeBuilder::new()
    .name("pitch1")
    .translation(Translation3::new(0.0, 0.1, 0.0))
    .joint_type(JointType::Rotational{axis: Vector3::y_axis()})
    .finalize());
l1.set_parent(&l0);
let tree = Chain::from_root(l0);
let j = tree.find("pitch1").unwrap();
j.set_joint_position(0.5).unwrap();
assert_eq!(j.joint_position().unwrap(), 0.5);

Find the joint by link name

Examples
use k::*;

let l0 = Node::new(NodeBuilder::new()
    .name("fixed")
    .finalize());
l0.set_link(Some(link::LinkBuilder::new().name("link0").finalize()));
let mut l1 = Node::new(NodeBuilder::new()
    .name("pitch1")
    .translation(Translation3::new(0.0, 0.1, 0.0))
    .joint_type(JointType::Rotational{axis: Vector3::y_axis()})
    .finalize());
l1.set_parent(&l0);
l1.set_link(Some(link::LinkBuilder::new().name("link1").finalize()));
let tree = Chain::from_root(l0);
let joint_name = tree.find_link("link1").unwrap()
.joint().name.clone();
assert_eq!(joint_name, "pitch1");
source

pub fn joint_positions(&self) -> Vec<T>

Get the positions of the joints

FixedJoint is ignored. the length is the same with dof()

source

pub fn set_joint_positions(&self, positions_vec: &[T]) -> Result<(), Error>

Set the positions of the joints

FixedJoints are ignored. the input number must be equal with dof()

source

pub fn set_joint_positions_clamped(&self, positions_vec: &[T])

Set the clamped positions of the joints

This function is safe, in contrast to set_joint_positions_unchecked.

source

pub fn set_joint_positions_unchecked(&self, positions_vec: &[T])

Fast, but without check, dangerous set_joint_positions

source

pub fn update_transforms(&self) -> Vec<Isometry3<T>>

Update world_transform() of the joints

source

pub fn update_velocities(&self) -> Vec<Velocity<T>>

Update world_velocity() of the joints

Update transforms of the links

Trait Implementations§

source§

impl<T> Clone for SerialChain<T>where T: RealField + SubsetOf<f64>,

source§

fn clone(&self) -> Self

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 SerialChain<T>

source§

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

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

impl<T> Deref for SerialChain<T>where T: RealField,

§

type Target = Chain<T>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> Display for SerialChain<T>where T: RealField + SubsetOf<f64>,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for SerialChain<T>

§

impl<T> Send for SerialChain<T>

§

impl<T> Sync for SerialChain<T>

§

impl<T> Unpin for SerialChain<T>

§

impl<T> !UnwindSafe for SerialChain<T>

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