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 .sdf files 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.md and references/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/sdf or 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 .sdf output.
- Read or create the design ledger.
- Read
references/frame-semantics.md before 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
1---2name: sdf3description: 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.4---5
6# SDF
7
8Provenance: maintained in [earthtojake/text-to-cad](https://github.com/earthtojake/text-to-cad).
9Use the installed local skill files as the runtime source of truth; the
10repository link is only for provenance and release review.
11
12Use 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.
13
14This skill is for **SDFormat**, not signed-distance-field geometry.
15
16## Core rules
17
181. Treat the Python file defining `gen_sdf()` as source of truth. Treat configured `.sdf` files as generated artifacts unless the user explicitly asks for direct XML editing.
192. Identify the target consumer before editing: Gazebo/libsdformat version, another simulator, visualization-only tooling, model package, or world handoff.
203. Decide document kind: model-level SDF, world-level SDF, or model-in-world. Prefer model-level SDF for reusable robot/object exports.
214. Use SI units unless the target explicitly requires otherwise: meters, kilograms, seconds, radians.
225. Prefer `version="1.12"` for new outputs unless the target consumer constrains the version.
236. Establish the design ledger before writing poses, frames, joint axes, mesh scales, inertials, sensors, or plugins. Use `references/design-ledger.md` and `references/llm-guardrails.md`.
247. 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.
258. Prefer helper functions and named constants over large XML string literals. Hidden numbers are a common SDF failure mode.
269. Generate only explicit targets with `scripts/sdf` or the repository's existing SDF launcher. Do not run directory-wide generation.
2710. Regenerate upstream geometry, mesh, robot-description, render, topology, or package assets with their owning workflows before regenerating SDF that references them.
2811. After generation, run available checks: bundled validation, optional `gz sdf --check`, simulator load, joint motion, and plugin/sensor startup.
2912. Report assumptions, skipped checks, unresolved resource paths, and target-specific compatibility risks.
30
31## Scope
32
33Use 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.
34
35## CAD Viewer Handoff
36
37After 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.
38
39## Workflow
40
411. Locate the `gen_sdf()` source and intended `.sdf` output.
422. Read or create the design ledger.
433. Read `references/frame-semantics.md` before editing any `<pose>`, `<frame>`, joint axis, `relative_to`, `expressed_in`, nested scope, sensor frame, or plugin frame.
444. Edit the generator source, not generated XML.
455. Use optional builder helpers when they make the generated structure clearer; raw ElementTree is still allowed.
466. Regenerate the explicit target.
477. Treat bundled validation as a guardrail, not simulator proof.
488. Run target-consumer smoke tests when available.
499. Report checks run, checks skipped, and assumptions. Static rendering does not execute SDF plugins or read file-authored motion metadata.
50
51## Commands
52
53Run 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.
54
55```bash
56python scripts/sdf path/to/source.py
57python scripts/sdf path/to/source.py -o path/to/output.sdf
58python scripts/sdf path/to/a.py=out/a.sdf path/to/b.py=out/b.sdf
59```
60
61Plain 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.
62
63If the runtime supports optional external checking:
64
65```bash
66python scripts/sdf path/to/source.py --gz-check auto
67python scripts/sdf path/to/source.py --gz-check required
68python scripts/sdf path/to/source.py --gz-check never
69```
70
71`gz sdf --check` is optional target-consumer validation. It should be reported as skipped when unavailable unless explicitly required.
72
73## Required report shape
74
75When finishing an SDF task, include a compact report:
76
77```text
78Generated: path/to/model.sdf from path/to/model.py
79Checks run:
80- bundled SDF validation: passed
81- gz sdf --check: skipped, gz not installed
82- simulator load: skipped, target simulator unavailable
83- viewer handoff: `$cad-viewer` link returned
84Assumptions:
85- Assumed mesh units are meters.
86- Assumed lidar frame is coincident with lidar_link.
87Risks:
88- Camera plugin filename was not verified in the target simulator environment.
89```
90
91## References
92
93- Generation command: `references/gen-sdf.md`
94- Generator contract: `references/generator-contract.md`
95- SDF workflow: `references/sdf-workflow.md`
96- Builder helpers: `references/builder-helpers.md`
97- LLM guardrails: `references/llm-guardrails.md`
98- Design ledger: `references/design-ledger.md`
99- Frame semantics: `references/frame-semantics.md`
100- Validation scope: `references/validation.md`
101- Smoke tests: `references/smoke-tests.md`
102- Interoperability notes: `references/interoperability.md`
103- Examples: `references/examples.md`
104- Runtime notes and current limitations: `references/implementation-notes.md`