Skip to content

Official Codebase of 3DCodeVerse

Python

urdf: the build collides the rest pose only — every pose is the round's joint_sweep gate

gaoypeng96f6bd548fad
diff --git a/harness/codeverse3d/languages/urdf/__init__.py b/harness/codeverse3d/languages/urdf/__init__.py
index 09346e36..3843e5fe 100644
--- a/harness/codeverse3d/languages/urdf/__init__.py
+++ b/harness/codeverse3d/languages/urdf/__init__.py
@@ -5,7 +5,6 @@ from __future__ import annotations
import ast
import contextlib
-import json
import math
import os
import re
@@ -36,7 +35,6 @@ from codeverse3d.proc import run_subprocess
from codeverse3d.spatial.joints import (
UrdfError,
load_urdf,
- pose_samples,
sweep_collisions,
sweep_findings,
urdf_to_glb,
@@ -749,7 +747,7 @@ FK_TOL_M = 0.001
#: every canonical artifact this build owns — staged together so a failed build
#: can never leave a previous round's output looking current
-STAGED_OUTPUTS = ("build.json", "census.json", "meshes", "robot.urdf", "articulation.json", "object.glb")
+STAGED_OUTPUTS = ("build.json", "census.json", "meshes", "robot.urdf", "object.glb")
class UrdfBlenderRuntime(RuntimeLayout):
@@ -769,7 +767,7 @@ class UrdfBlenderRuntime(RuntimeLayout):
# ------------------------------------------------------------ build
def build(self, ws: Workspace, *, timeout_s: int | None = None) -> BuildResult:
- """All six canonical outputs go through one :class:`ArtifactStage`: entering
+ """All five canonical outputs go through one :class:`ArtifactStage`: entering
it invalidates them BEFORE any early return can leak a previous round's
files, everything is written to staging, and only an ``ok=True`` build
promotes the full set. Every exit path publishes the FINAL BuildResult as
@@ -846,17 +844,10 @@ class UrdfBlenderRuntime(RuntimeLayout):
msg = "\n".join(f"- {f.as_line()}" for f in fk_findings)
return fail("FkInconsistent", f"URDF frames do not reproduce the authored geometry:\n{msg}", census=census)
- # 5. pose sweep
- report = sweep_collisions(robot, pose_samples(robot, n_random=8, seed=0))
+ # 5. the rest pose — the only pose that decides the build (D17); every other pose is
+ # the round's joint_sweep gate (spatial.joints.sweep_gate), which the tool reports too
+ report = sweep_collisions(robot, [{}], volumes=False)
findings = sweep_findings(report, rest_max_m=REST_PENETRATION_MAX_M)
- stage.path("articulation.json").write_text(json.dumps({"report": report.model_dump(mode="json"),
- "findings": [f.model_dump(mode="json") for f in findings]}, indent=1))
- extra["articulation"] = str(art / "articulation.json")
- for name, n in report.summary.link_islands.items():
- census.setdefault("links", {}).setdefault(name, {})["islands"] = n
- census["articulation"] = {"summary": report.summary.model_dump(mode="json"),
- "findings": [f.model_dump(mode="json") for f in findings],
- "n_joints": len(robot.joints), "movable_joints": [j.name for j in robot.movable_joints()]}
# 6. canonical GLB at rest
urdf_to_glb(robot, stage.path("object.glb"), None)
@@ -865,7 +856,7 @@ class UrdfBlenderRuntime(RuntimeLayout):
stdout_tail=wrapped.stdout_tail, stderr_tail=wrapped.stderr_tail,
duration_ms=int((time.time() - t0) * 1000), census=census)
if report.summary.rest_max_penetration_m > REST_PENETRATION_MAX_M:
- worst = [f for f in findings if f.data.get("pose") == {} and f.severity == "error"]
+ worst = [f for f in findings if f.severity == "error"]
res.ok = False
res.error_type = "RestPenetration"
res.error_file = "src/model.py"
diff --git a/harness/codeverse3d/skills/c3d-urdf-joints/SKILL.md b/harness/codeverse3d/skills/c3d-urdf-joints/SKILL.md
index 8e1ed1f4..6a41a60a 100644
--- a/harness/codeverse3d/skills/c3d-urdf-joints/SKILL.md
+++ b/harness/codeverse3d/skills/c3d-urdf-joints/SKILL.md
@@ -151,8 +151,9 @@ names no joint, names itself, or closes a loop is a lint ERROR.
## Finish
-`build` (runs the FK check and the sweep) then `joint_sweep` and look at the lower/mid/upper
-renders for every joint, then `check_connectivity`, then `check_contract`.
+`build` (runs the FK check and the rest-pose check) then `joint_sweep` (the round's own gate)
+and look at the lower/mid/upper renders for every joint, then `check_connectivity`, then
+`check_contract`.
Worked repairs, the full finding catalogue with real messages, and clearance numbers per
mechanism: `references/sweep-and-motion.md`.
diff --git a/harness/codeverse3d/skills/c3d-urdf-joints/references/sweep-and-motion.md b/harness/codeverse3d/skills/c3d-urdf-joints/references/sweep-and-motion.md
index 566c38f1..300b4696 100644
--- a/harness/codeverse3d/skills/c3d-urdf-joints/references/sweep-and-motion.md
+++ b/harness/codeverse3d/skills/c3d-urdf-joints/references/sweep-and-motion.md
@@ -18,7 +18,7 @@ Read out of the live harness on 2026-08-25: `codeverse3d/spatial/joints_sweep.py
| `hinge_clearance_m` | 0.010 m | `joints_sweep` | a moving child must be this close to its parent |
| ERROR on attachment | gap over 0.030 m | `joints_sweep.sweep_findings` | `hinge_clearance_m * 3` |
| depth rounding | 0.1 mm | `joints_sweep` | float32 mesh coordinates carry no finer meaning |
-| random poses | 8, seed 0 | `languages/urdf/__init__.py` | only when more than one joint moves |
+| random poses | 8, seed 0 | `joints_poses.pose_samples` | only when more than one joint moves |
| motion probe | limit of larger magnitude, capped at 0.35 rad | `joints_sweep.motion_direction_check` | prismatic uses the full limit |
| motion pass test | `cos(observed, expected) > 0.5` | same | a 60 degree cone |
diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.md
index 30f4a656..f76976e8 100644
--- a/harness/docs/ARCHITECTURE.md
+++ b/harness/docs/ARCHITECTURE.md
@@ -300,7 +300,7 @@ runs/<slug>/
alias; runs before 2026-08-23 have the root file only)
run_state.json status + stages; extra carries budget_snapshot and spec_fingerprint only — the round
history is rounds/rNN.json + each round's commit alone (no copy since 2026-09-22)
- artifacts/ object.glb object.stl|step robot.urdf meshes/ articulation.json build.json census.json
+ artifacts/ object.glb object.stl|step robot.urdf meshes/ build.json census.json
measurement.json … — the LAST round's build; graphics: frames/fNN_tT.png frames_sheet.png
preview.gif metrics.json; texturing (a pick's --texture): object_textured.glb
textures/{<id>.png, texture_plan.json, texturing.json, gate/}
@@ -348,8 +348,10 @@ summary:
`rpy="0 0 0"`, visual AND collision `<origin xyz>` = −pivot (root `0 0 0`) —
verified by the FK-consistency check; URDF limits = plan lower−rest .. upper−rest.
Link name `world` is reserved. Harness exports `meshes/<link>.glb` (raw Z-up link
- frames), sweeps poses for collisions (deterministic; python-fcl), builds
- hierarchical `object.glb`, and gates motion direction against the plan text.
+ frames), fails the build on a rest-pose penetration > 5 mm (D17; the rest pose is the
+ only one the build collides), builds hierarchical `object.glb`; the round's
+ `joint_sweep` gate sweeps every pose (deterministic; python-fcl) and a gate checks
+ motion direction against the plan text.
* **scene_threejs**: `src/scene.js` `createScene({THREE, renderer, loaders}) → {scene, cameras, update(t,dt)}`;
`src/env.js`, `src/zones/*.js`, `src/assets/*.js`, `src/shaders/*.js`; GLBs at
`public/assets/<name>.glb`. The harness assembles `scene.js` deterministically.
diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.md
index 1214cc37..917688b0 100644
--- a/harness/docs/INTERFACES.md
+++ b/harness/docs/INTERFACES.md
@@ -233,7 +233,7 @@ BuildResult.error_type spellings (languages/_common.py): MISSING_ENTRY = "Missin
| `BlenderRuntime` | `src/model.py`, `src/parts/*.py` | **Δ multi-file**: `part_file(name) -> "src/parts/<snake>.py"` (`def build_<snake>()`); lint = `layout.lint_workspace` over every src/*.py; skeleton writes model.py + per-part files; object.glb/stl, build.json, census.json |
| `CadQueryRuntime` | `src/model.py` | trailing selector on the stack → parent solid exported + warning (ExportError when no solid exists); helper-module errors map to `src/<file>.py:line`; object.glb/stl/step |
| `ThreeJsRuntime` | `src/object.js`, `src/parts/*.js` | **Δ export as authored** (census `placement_offset`); InstancedMesh baked to `<Name>_<i>` meshes (`instanced_meshes_baked`); exported `selfcheck(THREE, root)` is called (throw → SelfCheckError); NaN geometry errors name mesh/part → routed to `src/parts/<snake>.js` |
-| `UrdfBlenderRuntime` | `src/model.py`, `src/robot.urdf` | object.glb (Y-up, node=link, joint extras), meshes/<link>.glb (raw Z-up link frames); link name `world` is reserved (lint ERROR + UrdfError); robot GLB root gets `__root` suffix on name clash |
+| `UrdfBlenderRuntime` | `src/model.py`, `src/robot.urdf` | object.glb (Y-up, node=link, joint extras), meshes/<link>.glb (raw Z-up link frames); link name `world` is reserved (lint ERROR + UrdfError); robot GLB root gets `__root` suffix on name clash; the build collides the REST pose only (RestPenetration > 5 mm, D17) — every pose is the round's `joint_sweep` gate — and writes no articulation.json / census.articulation (Δ 2026-09-22) |
| `SceneThreeJsRuntime` | `src/scene.js`, `src/zones/*.js`, `src/assets/*.js`, `src/env.js`, `src/shaders/*.js` | glb_path=None; ok iff `probe_and_preflight(ws, *, timeout_s=None) -> (scene_probe, shader_preflight, census)` (one `probe_scene.mjs --compile` boot) passes both; both reports ride `BuildResult.gates`, and the `shader_probe` tool reports the same call |
| `GlslShaderRuntime` | `src/shader.frag`, `src/common.glsl`, `src/buffer_a.frag` (+ the harness-owned `src/recipes.glsl` when seeded) | harness owns `#version`/uniforms/`out` (wrap.HEADER: u_time/u_resolution/u_mouse/u_frame/u_prev/u_noise + iTime/iChannel* aliases); `wrap.compose(shader, common, recipes_src=…)` pastes header < recipes < common < shader; build renders judge frames via GlHost; compile errors → GlslCompileError at mapped src file:line (recipes.glsl included); lint ERROR `redefines_recipe` when an agent file defines a recipes.glsl name; artifacts frames/, frames_sheet.png, preview.gif, metrics.json |
| `OpenGLPythonRuntime` | `src/program.py`, `src/*.glsl` | `setup(ctx,w,h)->state` + `render(ctx,state,t,frame,fbo)` run in a moderngl subprocess (`wrappers/run_gl.py`); exceptions map to src/program.py:line, in-string GLSL errors carry both line numbers |
diff --git a/harness/docs/RUN_LAYOUT.md b/harness/docs/RUN_LAYOUT.md
index 24f932bc..307a892b 100644
--- a/harness/docs/RUN_LAYOUT.md
+++ b/harness/docs/RUN_LAYOUT.md
@@ -7,7 +7,7 @@ three separate buckets:
| bucket | question | contents |
|---|---|---|
| `deliverable/` | **what did I get?** | ONE round, the one a pick chose (`3dcode pick`; `3dcode make` picks by score after the run): its code snapshot, its artifact (`object.glb` / `robot.urdf` + `meshes/` / `frames/` + `preview.gif` / the scene bundle), its contact sheet, `captions.json`, `manifest.json` |
-| `evidence/` (= `artifacts/`) | **why should I believe it?** | every round's own build (`rNN/`), `renders/rNN/`, `gates/rNN/`, `judge/rNN.json`, `measurement.json`, `articulation.json`, `census.json`, `textures/`, `tool_renders/` |
+| `evidence/` (= `artifacts/`) | **why should I believe it?** | every round's own build (`rNN/`), `renders/rNN/`, `gates/rNN/`, `judge/rNN.json`, `measurement.json`, `census.json`, `textures/`, `tool_renders/` |
| `telemetry/` | **what did it cost and how was it configured?** | `settings.json`, `cost.json`, `usage.jsonl`, plus `events.jsonl`, `run_state.json`, `stages/`, `trajectories/` |
The run's **identity** stays at the root, where every tool has always looked for it:
diff --git a/harness/tests/prompts/test_snippets_run.py b/harness/tests/prompts/test_snippets_run.py
index b230a65a..6ac477db 100644
--- a/harness/tests/prompts/test_snippets_run.py
+++ b/harness/tests/prompts/test_snippets_run.py
@@ -88,9 +88,11 @@ def test_urdf_cookbook_runs(tmp_path) -> None:
def _build_urdf_example(tmp_path, tag: str, model_py: str, urdf: str):
"""Run a doc example through the REAL urdf_blender pipeline (lint → Blender export →
- FK consistency → collision sweep) — the build the agent's own files go through."""
+ FK consistency → rest-pose check) and the round's joint_sweep gate — what the agent's
+ own files go through."""
from codeverse3d.config import get_settings
from codeverse3d.languages.urdf import UrdfBlenderRuntime
+ from codeverse3d.spatial.joints import sweep_gate
from codeverse3d.workspace import Workspace
if not get_settings().resolve_blender():
@@ -103,8 +105,8 @@ def _build_urdf_example(tmp_path, tag: str, model_py: str, urdf: str):
assert res.ok, f"{tag}: {res.error_type}: {res.error_message}"
warns = [f["message"] for f in res.census["lint"] if f["severity"] != "info"]
assert warns == [], f"{tag}: lint warnings {warns}"
- summary = res.census["articulation"]["summary"]
- assert summary["max_penetration_m"] == 0.0 and summary["floating_links"] == [], f"{tag}: {summary}"
+ gate, _ = sweep_gate(ws)
+ assert not gate.findings, f"{tag}: {[f.message for f in gate.findings]}"
return ws, res
diff --git a/harness/tests/urdf_joints/test_live_blender.py b/harness/tests/urdf_joints/test_live_blender.py
index 4803eadc..196eac1d 100644
--- a/harness/tests/urdf_joints/test_live_blender.py
+++ b/harness/tests/urdf_joints/test_live_blender.py
@@ -7,7 +7,13 @@ import pytest
from codeverse3d.config import get_settings
from codeverse3d.languages.urdf import UrdfBlenderRuntime
-from codeverse3d.spatial.joints import fk, link_world_meshes, load_urdf, motion_direction_check
+from codeverse3d.spatial.joints import (
+ fk,
+ link_world_meshes,
+ load_urdf,
+ motion_direction_check,
+ sweep_gate,
+)
from codeverse3d.workspace import Workspace
pytestmark = pytest.mark.blender
@@ -29,8 +35,8 @@ def test_cabinet_door_end_to_end(tmp_path, cabinet_plan):
wm = link_world_meshes(r, {"hinge": 1.57})
assert wm["door"].centroid[1] < -0.4 and wm["handle"].centroid[1] < -0.4
assert motion_direction_check(r, "hinge", "front").ok
- art = res.census["articulation"]["summary"]
- assert art["max_penetration_m"] == 0.0 and art["floating_links"] == []
+ gate, _ = sweep_gate(ws) # the round's joint_sweep gate on this build
+ assert gate.passed and not gate.findings, [f.message for f in gate.findings]
# loads in yourdfpy with the same FK
yourdfpy = pytest.importorskip("yourdfpy")
u = yourdfpy.URDF.load(str(ws.artifacts / "robot.urdf"), load_meshes=True)
@@ -56,7 +62,7 @@ def test_rest_shifted_skeleton_builds_clean(tmp_path, drawer_plan):
r = load_urdf(ws.artifacts / "robot.urdf", ws.artifacts / "meshes")
closed = link_world_meshes(r, {"slide": -0.1})["drawer"].bounds
assert np.isclose(closed[1][1], -0.20, atol=1e-6) # back face of the panel flush with the carcass front
- assert res.census["articulation"]["summary"]["max_penetration_m"] == 0.0
+ assert not [f for f in sweep_gate(ws)[0].findings if f.data.get("kind") == "penetration"]
@needs_blender
@@ -70,7 +76,7 @@ def test_drawer_prismatic(tmp_path, drawer_plan):
c0 = link_world_meshes(r)["drawer"].centroid
c1 = link_world_meshes(r, {"slide": 0.3})["drawer"].centroid
assert np.allclose(c1 - c0, [0, -0.3, 0], atol=1e-6)
- assert res.census["articulation"]["summary"]["max_penetration_m"] == 0.0
+ assert not [f for f in sweep_gate(ws)[0].findings if f.data.get("kind") == "penetration"]
@needs_blender
@@ -83,10 +89,10 @@ def test_bad_pivot_is_caught(tmp_path, cabinet_plan):
u.write_text(u.read_text().replace('<origin xyz="-0.29 -0.2 0" rpy="0 0 0"/> <!-- pivot', '<origin xyz="0 -0.2 0" rpy="0 0 0"/> <!-- pivot')
.replace('xyz="0.29 0.2 0"', 'xyz="0 0.2 0"').replace('xyz="0.49 -0.04 0.4"', 'xyz="0.2 -0.04 0.4"'))
res = rt.build(ws)
- assert res.ok # rest pose is still fine; the sweep reports the defect for the gate layer
- art = res.census["articulation"]
- assert art["summary"]["max_penetration_m"] > 0.05 and "hinge@upper" in art["summary"]["overlapping_poses"]
- assert any(f["severity"] == "error" and "body|door" in f["target"] for f in art["findings"])
+ assert res.ok # rest pose is still fine; the round's joint_sweep gate reports the defect
+ gate, _ = sweep_gate(ws)
+ pen = next(f for f in gate.errors if f.target == "body|door")
+ assert pen.data["max_depth_m"] > 0.05 and {"hinge": 1.57} in pen.data["poses"]
@needs_blender
diff --git a/harness/tests/urdf_joints/test_runtime_offline.py b/harness/tests/urdf_joints/test_runtime_offline.py
index bfb2a18b..cef2e2d1 100644
--- a/harness/tests/urdf_joints/test_runtime_offline.py
+++ b/harness/tests/urdf_joints/test_runtime_offline.py
@@ -13,6 +13,7 @@ from codeverse3d.languages import get_runtime
from codeverse3d.languages.urdf import UrdfBlenderRuntime
from codeverse3d.proc import ProcResult
from codeverse3d.prompts.catalog import language_text
+from codeverse3d.spatial.joints import sweep_gate
from codeverse3d.workspace import Workspace
from tests.urdf_joints.conftest import box_glb
@@ -71,11 +72,10 @@ def test_build_ok(tmp_path, cabinet_plan, fake_blender):
ws = _ws(tmp_path, cabinet_plan)
res = UrdfBlenderRuntime().build(ws)
assert res.ok, res.error_message
- assert res.glb_path and (ws.artifacts / "object.glb").is_file()
- assert (ws.artifacts / "robot.urdf").is_file() and (ws.artifacts / "articulation.json").is_file()
- art = res.census["articulation"]
- assert art["summary"]["max_penetration_m"] == 0.0 and art["movable_joints"] == ["hinge"]
- assert res.census["links"]["door"]["islands"] == 1
+ assert res.glb_path and (ws.artifacts / "object.glb").is_file() and (ws.artifacts / "robot.urdf").is_file()
+ # the build checks the rest pose only; every pose is the round's joint_sweep gate
+ assert "articulation" not in res.census and not (ws.artifacts / "articulation.json").exists()
+ assert sweep_gate(ws)[0].passed
assert res.stdout_tail == "built" # proc.tail joins lines: same shape as blender/cadquery
@@ -110,10 +110,10 @@ def test_build_rest_penetration_fails_and_publishes_nothing(tmp_path, cabinet_pl
ws = _ws(tmp_path, cabinet_plan)
res = UrdfBlenderRuntime().build(ws)
assert not res.ok and res.error_type == "RestPenetration"
- assert res.census["articulation"]["summary"]["rest_max_penetration_m"] > 0.005
+ assert "at the rest pose (max 5 mm)" in res.error_message and "'body' and 'door' overlap" in res.error_message
# a failed build publishes NOTHING but its status: the fresh GLB stays unshipped
assert res.glb_path is None and res.extra_paths == {}
- for name in ("object.glb", "robot.urdf", "articulation.json"):
+ for name in ("object.glb", "robot.urdf"):
assert not (ws.artifacts / name).exists(), name
assert not (ws.artifacts / "meshes").exists()
assert json.loads((ws.artifacts / "build.json").read_text())["ok"] is False
@@ -125,13 +125,13 @@ def test_build_failure_invalidates_previous_success(tmp_path, cabinet_plan, fake
ws = _ws(tmp_path, cabinet_plan)
rt = UrdfBlenderRuntime()
assert rt.build(ws).ok
- for name in ("object.glb", "robot.urdf", "articulation.json", "census.json", "meshes"):
+ for name in ("object.glb", "robot.urdf", "census.json", "meshes"):
assert (ws.artifacts / name).exists(), name
fake_blender["error"] = {"error_type": "NameError", "error_message": "boom",
"error_file": "src/model.py", "error_line": 3}
res = rt.build(ws)
assert not res.ok and res.error_type == "NameError"
- for name in ("object.glb", "robot.urdf", "articulation.json"):
+ for name in ("object.glb", "robot.urdf"):
assert not (ws.artifacts / name).exists(), name
assert not (ws.artifacts / "meshes").exists()
disk = json.loads((ws.artifacts / "build.json").read_text())