API Referenceο
Complete API documentation for LinkForge.
- LinkForge Composer API
- Data Models
- SRDF β Semantic Robot Description
- Parsers
- Generators
- Physics Calculations
- Validation
- Validation Checks
- Kinematic Graph
- Blender Integration
- Exceptions
ValidationErrorCodeLinkForgeErrorRobotModelErrorRobotGeneratorErrorRobotParserErrorRobotParserIOErrorRobotParserXMLRootErrorRobotParserUnexpectedErrorRobotPhysicsErrorRobotValidationErrorRobotSecurityErrorRobotMathErrorRobotXacroErrorRobotXacroRecursionErrorRobotXacroExpressionErrorXacroDetectedError
Overviewο
LinkForge is organized into two main layers:
Core Layer (linkforge.core)ο
Platform-independent robot modeling and URDF/XACRO processing.
Composer:
RobotBuilderandLinkBuilderβ the programmatic robot building APIModels: Data structures (
Robot,Link,Joint,Sensor,SemanticRobotDescription, etc.)Parsers: URDF/XACRO/SRDF β Python objects
Generators: Python objects β URDF/XACRO/SRDF
Physics: Inertia calculations
Validation: Modular check registry and security
Graph: Kinematic tree utilities
Blender Layer (linkforge.blender)ο
Blender-specific integration.
Operators: User actions (export, create, etc.)
Panels: UI panels
Properties: Blender scene properties
Utils: Blender-specific utilities
Quick Referenceο
Building a Robot Programmaticallyο
The RobotBuilder Composer is the recommended way to build robots in Python.
It handles validation, prefixing, and SRDF generation automatically.
from linkforge.core import RobotBuilder, box, cylinder
builder = RobotBuilder("my_robot")
builder.link("base_link").visual(box(0.5, 0.5, 0.1)).mass(5.0).root()
builder.link("arm", parent="base_link") \
.visual(cylinder(0.05, 0.5)) \
.mass(2.0) \
.revolute(axis=(0, 0, 1), limits=(-1.57, 1.57), effort=10, velocity=1) \
.commit()
urdf = builder.export_urdf()
See the Composer reference for the full API, including macro-assembly and SRDF export.
Parsing URDFο
from linkforge.core import URDFParser
from pathlib import Path
# Parse URDF file
robot = URDFParser().parse(Path("robot.urdf"))
# Access components
print(f"Robot: {robot.name}")
print(f"Links: {len(robot.links)}")
print(f"Joints: {len(robot.joints)}")
# Iterate over links
for link in robot.links:
print(f" Link: {link.name}, Mass: {link.inertial.mass if link.inertial else 'N/A'}")
Calculating Inertiaο
from linkforge.core import Box, Cylinder, Vector3, calculate_inertia
# Box inertia
box = Box(size=Vector3(1.0, 0.5, 0.3))
inertia = calculate_inertia(box, mass=10.0)
# Cylinder inertia
cylinder = Cylinder(radius=0.1, length=0.5)
inertia = calculate_inertia(cylinder, mass=5.0)
Validationο
from linkforge.core import validate_robot
# Validate robot
result = validate_robot(robot)
if result.is_valid:
print(" Robot is valid!")
else:
print(" Validation errors:")
for error in result.errors:
print(f" - {error.message}")