robot_description_builder/link/
builder.rs

1use std::sync::Weak;
2
3use super::{Link, LinkShapeData};
4use crate::{
5	cluster_objects::{kinematic_data_tree::KinematicDataTree, KinematicTree},
6	joint::Joint,
7	utils::{ArcLock, WeakLock},
8};
9
10mod collision_builder;
11mod linkbuilder;
12mod visual_builder;
13
14pub use collision_builder::CollisionBuilder;
15pub use linkbuilder::LinkBuilder;
16pub use visual_builder::VisualBuilder;
17
18// FIXME: Split the trait into multiple traits, because it does not make sense in all situations
19pub(crate) trait BuildLink {
20	// TODO: THE BUILDER IS ALLOWED TO BUILD JOINTS FOR THIS BEAST, Maybe not for end users but might be usefull for cloning;
21	fn build(self, tree: &Weak<KinematicDataTree>) -> ArcLock<Link>;
22
23	fn build_tree(self) -> KinematicTree
24	where
25		Self: Sized,
26	{
27		let data = KinematicDataTree::new(self);
28		KinematicTree::new(data)
29	}
30
31	// TODO: Make internal
32	// TODO: Maybe move to `LinkChainBuilder`
33	/// Starts building the Kinematic Chain, the `tree` argument is not yet intitialized at this point.
34	fn start_building_chain(self, tree: &Weak<KinematicDataTree>) -> ArcLock<Link>;
35
36	fn build_chain(
37		self,
38		tree: &Weak<KinematicDataTree>,
39		parent_joint: &WeakLock<Joint>,
40	) -> ArcLock<Link>;
41
42	// TODO: Rename?
43	fn get_shape_data(&self) -> LinkShapeData;
44}
45
46impl<T: BuildLink> From<T> for KinematicTree {
47	fn from(value: T) -> Self {
48		value.build_tree()
49	}
50}