| name | regenerate-model |
| description | Regenerate the committed MJCF snapshot models/stackchan/stackchan.xml from params.py after physical parameters change, then show the diff. Use after editing params.py or model.py. |
Regenerate the MJCF snapshot
models/stackchan/stackchan.xml is a committed snapshot of the default profile,
generated from params.py via model.write_model(...). It is NOT hand-edited
(a PreToolUse hook blocks manual edits). Whenever params.py or model.py
changes in a way that affects the default profile, regenerate the snapshot so it
stays in sync with the single source of truth.
Steps
-
Regenerate the default snapshot (default profile = report, servo =
SCS0009, written with meshdir="meshes"). The package is not installed
into the venv, so add src to the path (mirrors how scripts/ and
tests/conftest.py import it):
uv run python -c "import sys; sys.path.insert(0, 'src'); from stackchan_sim import model; print(model.write_model('models/stackchan/stackchan.xml'))"
To regenerate a non-default profile/servo, pass them explicitly:
uv run python -c "import sys; sys.path.insert(0, 'src'); from stackchan_sim import model; model.write_model('models/stackchan/stackchan.xml', profile='report', servo='SCS0009')"
-
Show what changed so the diff can be reviewed before committing:
git diff -- models/stackchan/stackchan.xml
-
Sanity-check that the model still loads and the tests pass:
uv run pytest -q
Notes
- The one-liners add
src to sys.path because the package is not installed
into the venv (run uv sync first if MuJoCo/numpy imports fail).
- If the diff is empty, the snapshot was already up to date — nothing to commit.
- Report the diff summary and test result; do not commit unless asked.