Robot¶
- class urdfgenpy.Robot(name)[source]¶
Bases:
objectRoot container that holds links, joints, and global materials.
- Build the robot by calling
:meth:’add_link’ :meth:’add_joint’ :meth:’add_material’,
- then export with
:meth:’save’ :meth:’to_urdf’, :meth:’to_xacro’.
- Parameters:
name (
str) – Robot name embedded in the <robot> tag.
- add_link(link)[source]¶
Register a :class:’Link’ and return ‘self’ for chaining.
- Parameters:
link (
Link) – The link to add.- Return type:
- Returns:
This – class:’Robot’ instance.
- Raises:
ValueError – If a link with the same name already exists.
- add_joint(joint)[source]¶
Register a :class:’Joint’ and return ‘self’ for chaining.
Both the parent and child links must already be registered before calling this method.
- Parameters:
joint (
Joint) – The joint to add.- Return type:
- Returns:
This – class:’Robot’ instance.
- Raises:
ValueError – If a joint with the same name already exists, or if the parent or child link has not been registered.
- to_xacro(output_path=None)[source]¶
Serialize the robot to a Xacro XML string.
The output includes standard inertia macros and an ‘INERTIA_MULTIPLY’ property, making the file easy to parameterise further.
- save(output_path)[source]¶
Write the robot to output_path, inferring format from the extension.
Uses :meth:’to_xacro’ for ‘.xacro’ files and :meth:’to_urdf’ for everything else.
- tree_string()[source]¶
Return the kinematic chain as a plain-text ASCII tree.
- Return type:
- Returns:
A multi-line string with the root link at the top and each child indented below its parent joint.