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())fn yank_joint(&self, name: &str) -> Option<Chained<JointBuilder>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.