sdf
earthtojake/text-to-cad
Generate, validate, and hand off SDFormat models and worlds for Gazebo and other simulators.
What is sdf?
This skill creates and edits SDFormat (SDF) documents for robot models, worlds, and simulator configuration. Use it when you need to generate `.sdf` files, work with Python `gen_sdf()` sources, or prepare models for simulator handoff with proper frames, joints, inertials, sensors, and physics.
- Generate SDFormat models and worlds from Python source files using `gen_sdf()` functions
- Validate SDF structure and compatibility with target simulators like Gazebo
- Define robot structure: links, joints, poses, frames, inertials, and spatial transforms
- Configure visual and collision geometry, mesh URIs, and sensor/light placement
- Manage simulator-specific metadata, physics parameters, plugins, and includes
- Hand off completed SDF files to CAD Viewer for inspection
How to install sdf
npx skills add https://github.com/earthtojake/text-to-cad --skill sdf- Python environment with the skill installed via `npx skills add`
- Upstream geometry, mesh, and robot-description assets finalized before SDF generation
- Optional: Gazebo/libsdformat installed for `gz sdf --check` validation
How to use sdf
- 1.Locate or create the Python `gen_sdf()` source file and identify the target `.sdf` output path
- 2.Read the design ledger and frame-semantics reference to establish spatial assumptions
- 3.Edit the generator source (not the generated XML) to define models, links, joints, poses, and simulator metadata
- 4.Run `python scripts/sdf path/to/source.py` or `python scripts/sdf path/to/source.py -o path/to/output.sdf` to generate the SDF file
- 5.Run bundled validation and optional `gz sdf --check` to verify structure and simulator compatibility
- 6.Hand off the generated `.sdf` file path to `$cad-viewer` for visual inspection
- 7.Report checks run, assumptions made, and any unresolved resource paths or compatibility risks
Use cases
- Export a robot description from Python to a reusable SDFormat model for Gazebo simulation
- Create a world file that positions multiple models and configures physics and lighting
- Validate that joint axes, frame transforms, and inertial properties are correctly specified before simulator load
- Generate sensor and plugin configurations for a robot model with proper frame references
- Prepare a model package with correct mesh paths and SDFormat version for a specific simulator target
- Roboticists and simulation engineers working with Gazebo or libsdformat
- Developers building robot description pipelines that output to SDFormat
- Anyone preparing models for physics simulation or multi-robot world setup
sdf FAQ
Treat the Python `gen_sdf()` source as the source of truth. Edit the generator source, not the generated XML, to avoid losing changes on regeneration. Use this skill for reproducible, maintainable SDF pipelines.
Use SI units by default: meters for distance, kilograms for mass, seconds for time, and radians for angles. Only deviate if your target simulator explicitly requires different units.
Read `references/frame-semantics.md` before editing any pose, frame, joint axis, or relative_to attribute. Derive transforms from upstream source data, drawings, or measured values—never infer from visual impression alone.
Report the generated file path, which checks were run (bundled validation, gz sdf --check, simulator load) and which were skipped, any assumptions about mesh units or frame placement, and compatibility risks for the target simulator.
No. This skill is for SDFormat documents only, not signed-distance-field (SDF) geometry. Use other geometry generation tools for implicit surface modeling.
Full instructions (SKILL.md)
Source of truth, from earthtojake/text-to-cad.
name: sdf
description: SDFormat/SDF model and world generation, validation, and simulator handoff. Use for .sdf files, SDFormat XML, Python gen_sdf() sources, models, worlds, links, joints, poses, frames, inertials, visual/collision geometry, mesh URIs, sensors, lights, physics, plugins, includes, Gazebo, static SDF review, or simulator-specific metadata. Do not use for signed-distance-field geometry.
SDF
Provenance: maintained in earthtojake/text-to-cad. Use the installed local skill files as the runtime source of truth; the repository link is only for provenance and release review.
Use this skill when the deliverable is an SDFormat document or a Python gen_sdf() source. SDFormat describes simulator and world behavior: models, worlds, frames, poses, links, joints, inertials, visuals, collisions, sensors, lights, physics, plugins, includes, and simulator metadata.
This skill is for SDFormat, not signed-distance-field geometry.
Core rules
- Treat the Python file defining
gen_sdf()as source of truth. Treat configured.sdffiles as generated artifacts unless the user explicitly asks for direct XML editing. - Identify the target consumer before editing: Gazebo/libsdformat version, another simulator, visualization-only tooling, model package, or world handoff.
- Decide document kind: model-level SDF, world-level SDF, or model-in-world. Prefer model-level SDF for reusable robot/object exports.
- Use SI units unless the target explicitly requires otherwise: meters, kilograms, seconds, radians.
- Prefer
version="1.12"for new outputs unless the target consumer constrains the version. - Establish the design ledger before writing poses, frames, joint axes, mesh scales, inertials, sensors, or plugins. Use
references/design-ledger.mdandreferences/llm-guardrails.md. - Do not infer spatial transforms from visual impression alone. Derive poses, axes, scale, mass, inertia, and frame names from upstream source data, drawings, simulator documentation, measured values, or explicit assumptions.
- Prefer helper functions and named constants over large XML string literals. Hidden numbers are a common SDF failure mode.
- Generate only explicit targets with
scripts/sdfor the repository's existing SDF launcher. Do not run directory-wide generation. - Regenerate upstream geometry, mesh, robot-description, render, topology, or package assets with their owning workflows before regenerating SDF that references them.
- After generation, run available checks: bundled validation, optional
gz sdf --check, simulator load, joint motion, and plugin/sensor startup. - Report assumptions, skipped checks, unresolved resource paths, and target-specific compatibility risks.
Scope
Use this skill for SDFormat outputs and generators. Do not use it for signed-distance-field modeling, raw geometry generation, planning semantics, or to paper over incorrect upstream robot/source data unless the task is explicitly simulator-only.
CAD Viewer Handoff
After completing SDF work that creates or modifies a .sdf, you must ALWAYS hand the explicit file path to $cad-viewer when that skill is installed. $cad-viewer must start CAD Viewer if it is not already running and return link(s) to the relevant created or updated file(s); if $cad-viewer is unavailable or startup fails, report that instead of silently omitting the handoff.
Workflow
- Locate the
gen_sdf()source and intended.sdfoutput. - Read or create the design ledger.
- Read
references/frame-semantics.mdbefore editing any<pose>,<frame>, joint axis,relative_to,expressed_in, nested scope, sensor frame, or plugin frame. - Edit the generator source, not generated XML.
- Use optional builder helpers when they make the generated structure clearer; raw ElementTree is still allowed.
- Regenerate the explicit target.
- Treat bundled validation as a guardrail, not simulator proof.
- Run target-consumer smoke tests when available.
- Report checks run, checks skipped, and assumptions. Static rendering does not execute SDF plugins or read file-authored motion metadata.
Commands
Run with the project or workspace Python environment. Treat python in examples as an interpreter placeholder; if bare python is unavailable, substitute python3, a project virtualenv interpreter, or the configured interpreter path.
python scripts/sdf path/to/source.py
python scripts/sdf path/to/source.py -o path/to/output.sdf
python scripts/sdf path/to/a.py=out/a.sdf path/to/b.py=out/b.sdf
Plain Python targets write sibling .sdf files beside their sources. -o / --output is valid only with one plain target. SOURCE.py=OUTPUT.sdf supports custom multi-target destinations.
If the runtime supports optional external checking:
python scripts/sdf path/to/source.py --gz-check auto
python scripts/sdf path/to/source.py --gz-check required
python scripts/sdf path/to/source.py --gz-check never
gz sdf --check is optional target-consumer validation. It should be reported as skipped when unavailable unless explicitly required.
Required report shape
When finishing an SDF task, include a compact report:
Generated: path/to/model.sdf from path/to/model.py
Checks run:
- bundled SDF validation: passed
- gz sdf --check: skipped, gz not installed
- simulator load: skipped, target simulator unavailable
- viewer handoff: `$cad-viewer` link returned
Assumptions:
- Assumed mesh units are meters.
- Assumed lidar frame is coincident with lidar_link.
Risks:
- Camera plugin filename was not verified in the target simulator environment.
References
- Generation command:
references/gen-sdf.md - Generator contract:
references/generator-contract.md - SDF workflow:
references/sdf-workflow.md - Builder helpers:
references/builder-helpers.md - LLM guardrails:
references/llm-guardrails.md - Design ledger:
references/design-ledger.md - Frame semantics:
references/frame-semantics.md - Validation scope:
references/validation.md - Smoke tests:
references/smoke-tests.md - Interoperability notes:
references/interoperability.md - Examples:
references/examples.md - Runtime notes and current limitations:
references/implementation-notes.md
Related skills
More from earthtojake/text-to-cad and the wider catalog.
cad
Create, modify, and validate parametric CAD parts and assemblies from natural language, technical drawings, or STEP files.
step-parts
Search and download off-the-shelf CAD parts from step.parts catalog—actuators, motors, connectors, fasteners, and more.
urdf
Generate and validate URDF robot descriptions from Python sources with frame-aware kinematic modeling.
srdf
MoveIt2 SRDF generation, validation, and planning-semantics workflow for robot manipulation.
sendcutsend
Preflight validation for SendCutSend.com DXF and STEP/STP orders against official specs and ordering rules.
cad-viewer
Start a local CAD Viewer and generate review links for STEP, STL, implicit CAD, G-code, URDF, and other model files.