pub trait KinematicInterface: Sized {
Show 14 methods
// Required methods
fn get_root_link(&self) -> Arc<RwLock<Link>>;
fn get_newest_link(&self) -> Arc<RwLock<Link>>;
fn get_links(&self) -> Arc<RwLock<HashMap<String, Weak<RwLock<Link>>>>>;
fn get_joints(&self) -> Arc<RwLock<HashMap<String, Weak<RwLock<Joint>>>>>;
fn get_materials(
&self
) -> Arc<RwLock<HashMap<String, Arc<RwLock<MaterialData>>>>>;
fn get_link(&self, name: &str) -> Option<Arc<RwLock<Link>>>;
fn get_joint(&self, name: &str) -> Option<Arc<RwLock<Joint>>>;
fn get_material(&self, name: &str) -> Option<Material>;
fn purge_links(&self);
fn purge_joints(&self);
fn purge_materials(
&self
) -> Result<(), PoisonError<RwLockWriteGuard<'_, HashMap<String, Arc<RwLock<MaterialData>>>>>>;
// Provided methods
fn yank_link(&self, name: &str) -> Option<Chained<LinkBuilder>> { ... }
fn yank_root(self) -> Result<Chained<LinkBuilder>, YankLinkError> { ... }
fn yank_joint(&self, name: &str) -> Option<Chained<JointBuilder>> { ... }
}
Expand description
A trait which allows for the existance of multiple different Kinematic Structures, such as Robot
and KinematicTree
.
Required Methods§
sourcefn get_root_link(&self) -> Arc<RwLock<Link>>
fn get_root_link(&self) -> Arc<RwLock<Link>>
Returns the root link of the Kinematic Tree
Example
let tree = Link::builder("the root link").build_tree();
/// This is equivalent to `get_root_link` in this case, since this is a new tree/Link.
tree.get_newest_link().try_write().unwrap().try_attach_child(
JointBuilder::new("just a joint", JointType::Fixed),
LinkBuilder::new("his one and only child")
).unwrap();
assert_eq!(tree.get_root_link().try_read().unwrap().name(), "the root link")
sourcefn get_newest_link(&self) -> Arc<RwLock<Link>>
fn get_newest_link(&self) -> Arc<RwLock<Link>>
Returns the newest link of the Kinematic Tree
Example
let tree = Link::builder("the root link").build_tree();
assert_eq!(tree.get_newest_link().try_read().unwrap().name(), "the root link");
tree.get_newest_link().try_write().unwrap().try_attach_child(
JointBuilder::new("just a joint", JointType::Fixed),
LinkBuilder::new("his one and only child")
).unwrap();
assert_eq!(tree.get_newest_link().try_read().unwrap().name(), "his one and only child");
let long_sub_tree = LinkBuilder::new("the other child").build_tree();
long_sub_tree.get_newest_link().try_write().unwrap().try_attach_child(
JointBuilder::new("second joint", JointType::Fixed),
Link::builder("the latest child")
).unwrap();
tree.get_root_link().try_write().unwrap().try_attach_child(
JointBuilder::new("third joint", JointType::Fixed),
long_sub_tree
).unwrap();
assert_eq!(tree.get_newest_link().try_read().unwrap().name(), "the latest child");
sourcefn get_links(&self) -> Arc<RwLock<HashMap<String, Weak<RwLock<Link>>>>>
fn get_links(&self) -> Arc<RwLock<HashMap<String, Weak<RwLock<Link>>>>>
Retrieves the Link
-index of the Kinematic structure.
sourcefn get_joints(&self) -> Arc<RwLock<HashMap<String, Weak<RwLock<Joint>>>>>
fn get_joints(&self) -> Arc<RwLock<HashMap<String, Weak<RwLock<Joint>>>>>
Retrieves the Joint
-index of the Kinematic structure.
fn get_materials( &self ) -> Arc<RwLock<HashMap<String, Arc<RwLock<MaterialData>>>>>
sourcefn get_link(&self, name: &str) -> Option<Arc<RwLock<Link>>>
fn get_link(&self, name: &str) -> Option<Arc<RwLock<Link>>>
Get the Link
with the specified name
.
If the Link
does not exist None
is returned.
sourcefn get_joint(&self, name: &str) -> Option<Arc<RwLock<Joint>>>
fn get_joint(&self, name: &str) -> Option<Arc<RwLock<Joint>>>
Get the Joint
with the specified name
.
If the Joint
does not exist None
is returned.
sourcefn get_material(&self, name: &str) -> Option<Material>
fn get_material(&self, name: &str) -> Option<Material>
Get the Material
with the specified name
.
If the Material
does not exist None
is returned.
sourcefn purge_links(&self)
fn purge_links(&self)
Cleans up orphaned/broken Link
entries from the links
HashMap.
This mostly happens automatically, but is exposed for use in other methods.
TODO: DOCTEST/EXAMPLE
sourcefn purge_joints(&self)
fn purge_joints(&self)
Cleans up orphaned/broken Joint
entries from the joints
HashMap.
This mostly happens automatically, but is exposed for use in other methods.
TODO: DOCTEST/EXAMPLE
sourcefn purge_materials(
&self
) -> Result<(), PoisonError<RwLockWriteGuard<'_, HashMap<String, Arc<RwLock<MaterialData>>>>>>
fn purge_materials( &self ) -> Result<(), PoisonError<RwLockWriteGuard<'_, HashMap<String, Arc<RwLock<MaterialData>>>>>>
Cleans up orphaned/unused Material
entries from material_index
HashMap
Provided Methods§
fn yank_link(&self, name: &str) -> Option<Chained<LinkBuilder>>
sourcefn yank_root(self) -> Result<Chained<LinkBuilder>, YankLinkError>
fn yank_root(self) -> Result<Chained<LinkBuilder>, YankLinkError>
Cosumes the KinematicInterface
implementor and creates a Chained<LinkBuilder>
to rebuild it.
This has the same result as yanking the root_link
, with the additional effect that the current tree is consumed.
Example
let builder = Link::builder("root-link");
assert_eq!(*builder.clone().build_tree().yank_root().unwrap(), builder);
/// It is equivalent to yanking the "root_link"
assert_eq!(builder.clone().build_tree().yank_root().unwrap(), builder.build_tree().yank_link("root-link").unwrap())