urdf_export
ROS URDF export for walker mechanisms.
URDF export for walking linkages.
Converts a Walker (hypergraph topology + dimensions) into a
URDF XML string or file, suitable for
visualization and simulation in ROS, Gazebo, RViz, MuJoCo, and other
robotics tools.
Mapping from leggedsnake concepts to URDF:
URDF link — each edge (binary rigid bar) or hyperedge (rigid body group) becomes a URDF
<link>with a cylinder visual/collision and computed inertial properties.URDF joint — each non-ground node becomes a revolute
<joint>connecting two URDF links. Ground nodes producefixedjoints attaching to the base frame. Driver nodes producecontinuous(actuated) joints.Base link — the ground/chassis frame. All ground nodes are fixed to this link.
Example:
from leggedsnake import Walker
from leggedsnake.urdf_export import to_urdf
walker = ... # build or load a Walker
urdf_string = to_urdf(walker)
with open("walker.urdf", "w") as f:
f.write(urdf_string)
- class leggedsnake.urdf_export.URDFConfig(link_radius: float = 0.02, density: float = 1000.0, base_link_name: str = 'base_link', effort_limit: float = 1000.0, velocity_limit: float = 10.0, mesh_color: tuple[float, float, float, float] = (0.7, 0.7, 0.7, 1.0))
Bases:
objectParameters controlling URDF generation.
- Variables:
link_radius (float) – Radius of cylinder geometry for each link (m).
density (float) – Material density for inertia computation (kg/m^3).
base_link_name (str) – Name of the root/chassis URDF link.
effort_limit (float) – Maximum joint effort for actuated (driver) joints (N*m).
velocity_limit (float) – Maximum joint velocity for actuated joints (rad/s).
mesh_color (tuple[float, float, float, float]) – RGBA color for visual elements.
- __init__(link_radius: float = 0.02, density: float = 1000.0, base_link_name: str = 'base_link', effort_limit: float = 1000.0, velocity_limit: float = 10.0, mesh_color: tuple[float, float, float, float] = (0.7, 0.7, 0.7, 1.0)) None
- base_link_name: str = 'base_link'
- density: float = 1000.0
- effort_limit: float = 1000.0
- link_radius: float = 0.02
- mesh_color: tuple[float, float, float, float] = (0.7, 0.7, 0.7, 1.0)
- velocity_limit: float = 10.0
- leggedsnake.urdf_export.to_urdf(walker: Walker, config: URDFConfig | None = None) str
Convert a Walker to a URDF XML string.
- Parameters:
walker (Walker) – The walking linkage to export.
config (URDFConfig | None) – Export parameters. Uses defaults if None.
- Returns:
A complete URDF XML document as a string.
- Return type:
str
- leggedsnake.urdf_export.to_urdf_file(walker: Walker, path: str, config: URDFConfig | None = None) None
Write a Walker as a URDF file.
- Parameters:
walker (Walker) – The walking linkage to export.
path (str) – Output file path.
config (URDFConfig | None) – Export parameters.