2.6 KiB
SDF generation command
Use the SDF launcher to regenerate explicit SDFormat outputs from Python sources with top-level gen_sdf() functions.
python scripts/sdf path/to/model.py
python scripts/sdf path/to/model.py -o path/to/robot.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. Use SOURCE.py=OUTPUT.sdf pairs for custom multi-target destinations.
Relative source targets and CLI output paths resolve from the current working directory. When running from outside the skill directory, prefix the launcher path so source and target files still resolve from the intended workspace.
What the command does
The tool should:
- import the target Python source;
- call top-level zero-argument
gen_sdf(); - normalize the returned SDF XML or envelope;
- parse the generated XML;
- run bundled dependency-light validation;
- optionally run external
gz sdf --checkif requested and available; - write the requested
.sdfonly after required checks pass; - print structured warnings and assumptions.
The command does not regenerate geometry, meshes, GLB/topology outputs, render assets, robot-description files, planning metadata, or simulator resource packages. Regenerate those with their owning workflows before regenerating SDF that references them.
Optional external check
If implemented, the recommended flag is:
python scripts/sdf path/to/model.py --gz-check auto
python scripts/sdf path/to/model.py --gz-check required
python scripts/sdf path/to/model.py --gz-check never
python scripts/sdf path/to/model.py --strict
auto: rungz sdf --checkwhengzis available; otherwise report the check as skipped and continue.required: fail ifgzis unavailable or ifgz sdf --checkexits nonzero.never: skip external checking.
If the external checker requires a path, write to a temporary file first. Do not overwrite the target until bundled validation and all required external checks pass.
Failure behavior
If validation fails, the newly generated payload is not written. Existing output files may be stale; fix the Python source and regenerate.
Errors should be blocking. Warnings and assumptions should be reported but should not fail generation unless the user or CI explicitly requests strict behavior.
Execution safety
The launcher imports generator modules. Top-level Python code in generator files may execute. Use this command only for trusted project sources. A future subprocess runner may reduce accidental side effects, but it cannot make untrusted Python safe.