pub struct SerialChain<T: Real> { /* fields omitted */ }
Kinematic chain without any branch.
All joints are connected sequentially.
Convert Chain into SerialChain without any check
If the input Chain has any branches it causes serious bugs.
Convert Chain into SerialChain
If the input Chain has any branches it fails.
let node = k::JointBuilder::<f32>::new().into_node();
let chain = k::Chain::from_root(node);
assert!(k::SerialChain::try_new(chain).is_some());
let node0 = k::JointBuilder::<f32>::new().into_node();
let node1 = k::JointBuilder::new().into_node();
let node2 = k::JointBuilder::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());
Create SerialChain from the end Node
let node = k::JointBuilder::<f32>::new().into_node();
let s_chain = k::SerialChain::from_end(&node);
Safely unwrap and returns inner Chain
instance
Calculate transform of the end joint
Iterate for all joint nodes
The order is from parent to children. You can assume that parent is already iterated.
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");
Iterate for movable joints
Fixed joints are ignored. If you want to manipulate on Fixed,
use iter()
instead of iter_joints()
Calculate the degree of freedom
use k::*;
let l0 = JointBuilder::new()
.joint_type(JointType::Fixed)
.finalize()
.into();
let l1 : Node<f64> = JointBuilder::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);
Find the joint by name
use k::*;
let l0 = Node::new(JointBuilder::new()
.name("fixed")
.finalize());
let l1 = Node::new(JointBuilder::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);
Get the positions of the joints
FixedJoint
is ignored. the length is the same with dof()
Set the positions of the joints
FixedJoints
are ignored. the input number must be equal with dof()
Fast, but without check, dangerous set_joint_positions
Update world_transform() of the joints
Update world_velocity() of the joints
Update transforms of the links
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Converts the given value to a String
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<SS, SP> SupersetOf for SP where SS: SubsetOf<SP>, | |
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.