Official Codebase of 3DCodeVerse
Python
articulated/scene: three review-of-PR#3 fixes, each reproduced first
gaoypeng69bf30af990c
diff --git a/harness/codeverse/spatial/joints_sweep.py b/harness/codeverse/spatial/joints_sweep.pyindex 8796810e..2756efcc 100644--- a/harness/codeverse/spatial/joints_sweep.py+++ b/harness/codeverse/spatial/joints_sweep.py@@ -365,15 +365,21 @@ def motion_direction_check(robot: Robot, joint: str, expected: str, *, probe: flok = cos > 0.5suggested = Noneif not ok:+ # ``want``/``s`` are WORLD vectors, but URDF <axis> lives in the JOINT frame+ # (fk composes parent @ origin @ motion(q), so the axis acts after origin) —+ # express the suggestion there, or a rotated origin / rotated ancestor chain+ # makes the "exact" repair install a provably wrong axis (repro: a hinge with+ # rpy="0 0 1.57" kept its motion ERROR after installing the world-frame value).+ R_joint = fk(robot, {})[j.child][:3, :3] # motion(0) = I, so this is rot(parent @ origin)if j.type == "prismatic":- suggested = tuple(round(float(v), 3) for v in want)+ suggested = tuple(round(float(v), 3) for v in R_joint.T @ want)else:pivot = fk(robot, {})[j.child][:3, 3]r = c0 - pivots = np.cross(r, want)n_s = float(np.linalg.norm(s))if n_s > 1e-6:- suggested = tuple(round(float(v), 3) for v in s / n_s)+ suggested = tuple(round(float(v), 3) for v in R_joint.T @ (s / n_s))return MotionCheck(joint=joint, expected=expected, observed_dir=tuple(round(float(v), 4) for v in d), ok=ok,cos=round(cos, 4), suggested_axis=suggested,message=(f"{joint}: child '{j.child}' moves {tuple(round(float(v),3) for v in d)} for q={probe:+.3g}; "diff --git a/harness/codeverse/tracks/articulated_object.py b/harness/codeverse/tracks/articulated_object.pyindex 309140dc..5569cc7b 100644--- a/harness/codeverse/tracks/articulated_object.py+++ b/harness/codeverse/tracks/articulated_object.py@@ -287,10 +287,17 @@ def _set_axis_in_urdf_text(text: str, urdf_joint: str, axis: tuple[float, float,block = text[start:end]a0 = block.find("<axis")if a0 != -1:- close = block.find("/>", a0)- if close == -1:+ gt = block.find(">", a0)+ if gt == -1:return None- new_block = block[:a0] + f'<axis xyz="{xyz}"/>' + block[close + 2:]+ if block[gt - 1] == "/": # <axis .../>+ axis_end = gt + 1+ else: # <axis ...>...</axis> — "/>" never occurs+ close_pair = block.find("</axis>", gt) # in "</axis>", so searching for it would+ if close_pair == -1: # land on the NEXT self-closing tag and+ return None # splice away the joint's <limit/>+ axis_end = close_pair + len("</axis>")+ new_block = block[:a0] + f'<axis xyz="{xyz}"/>' + block[axis_end:]else:head_end = block.find(">")if head_end == -1:diff --git a/harness/codeverse/tracks/zone_layout.py b/harness/codeverse/tracks/zone_layout.pyindex 0415f852..74a77841 100644--- a/harness/codeverse/tracks/zone_layout.py+++ b/harness/codeverse/tracks/zone_layout.py@@ -78,7 +78,15 @@ def validate_layout(layout: ZoneLayout, zone: ZonePlan, plan: ScenePlan) -> str:# puts geometry inside the lens (fv_izakaya_night), and nothing downstream can fix itfoot = max(known[k].approx_size_m[0], known[k].approx_size_m[2])need = max(CAMERA_CLEAR_FLOOR_M, foot / 2 + p.spread_m / 2 + CAMERA_CLEAR_M)+ base = known[to_snake(p.support)].approx_size_m[1] if to_snake(p.support) in known else 0.0+ top = base + known[k].approx_size_m[1]for cam in plan.cameras:+ if cam.position[1] > top + CAMERA_CLEAR_M:+ # the check is 2D by design (clusters stand on the floor), so an aerial /+ # establishing camera must escape it vertically: a lens this far above the+ # cluster's top cannot be inside it, and rejecting every large placement+ # under a high camera dropped the whole zone's layout (review of PR #3)+ continuedist = math.hypot(x - cam.position[0], z - cam.position[2])if dist < need:problems.append(f"{p.asset} cluster ({x:.1f}, {z:.1f}) reaches camera {cam.name} "diff --git a/harness/tests/orchestrator_tracks/test_zone_layout.py b/harness/tests/orchestrator_tracks/test_zone_layout.pyindex 1bc347b3..cb292c67 100644--- a/harness/tests/orchestrator_tracks/test_zone_layout.py+++ b/harness/tests/orchestrator_tracks/test_zone_layout.py@@ -42,6 +42,21 @@ def test_validator_accepts_a_buildable_layout_and_names_every_problem():assert "no placement for planned contents: FishingBoat" in complaint+def test_an_aerial_camera_does_not_reject_the_placements_beneath_it():+ """PR #3 review: the clearance check is 2D, so an establishing camera 8 m up+ rejected every large cluster under it and the zone lost its whole layout.+ A lens above the cluster top (+ margin) cannot be inside the geometry; a lens+ AT stall height directly above the cluster is still rejected."""+ plan = _plan()+ plan.cameras = [CameraPlan(name="aerial", position=(10, 8, 0), look_at=(10, 0, 0), fov=50, purpose="p")]+ under = _layout(placements=[{"asset": "Stall", "count": 4, "cluster": (10.0, 0.0), "spread_m": 3.0}],+ zone="Market")+ assert validate_layout(under, plan.zones[1], plan) == ""+ plan.cameras = [CameraPlan(name="low", position=(10, 2.0, 0), look_at=(10, 0, 0), fov=50, purpose="p")]+ complaint = validate_layout(under, plan.zones[1], plan)+ assert "camera low" in complaint, "a lens at stall height above the cluster is still inside its reach"++def test_validator_rejects_a_cluster_that_swallows_a_camera():"""fv_izakaya_night: BarCounter 0.7 m from the PotDetail camera — the lens sat insidethe counter and camera_in_geometry capped all three rounds. The camera list is andiff --git a/harness/tests/urdf_joints/test_axis_repair.py b/harness/tests/urdf_joints/test_axis_repair.pyindex ea3980f8..af75b5ed 100644--- a/harness/tests/urdf_joints/test_axis_repair.py+++ b/harness/tests/urdf_joints/test_axis_repair.py@@ -93,3 +93,49 @@ def test_artifacts_copy_is_kept_in_step(tmp_path):(ws.artifacts / "robot.urdf").write_text(URDF)assert repair_motion_axes(ws, _report(_finding("Hinge", cos=-1.0))) == ["Hinge"]assert (ws.artifacts / "robot.urdf").read_text() == (ws.src / "robot.urdf").read_text()+++def test_a_paired_axis_tag_keeps_the_joints_limit():+ """PR #3 review: '/>' never occurs inside '</axis>', so the old splice searched past+ the paired tag, landed on the NEXT self-closing element and deleted the joint's+ <limit/> — an invalid revolute joint shipped to src/ and artifacts/."""+ from codeverse.tracks.articulated_object import _set_axis_in_urdf_text++ for axis_form in ('<axis xyz="1 0 0"></axis>', '<axis xyz="1 0 0"/>'):+ urdf = ('<robot name="r"><joint name="h" type="revolute">\n'+ '<parent link="a"/><child link="b"/>\n' + axis_form + '\n'+ '<limit lower="0" upper="1.57" effort="10" velocity="1"/>\n</joint></robot>')+ out = _set_axis_in_urdf_text(urdf, "h", (0.0, 0.0, 1.0))+ assert out is not None and '<axis xyz="0 0 1"/>' in out+ assert "<limit" in out, f"the splice ate the limit for {axis_form!r}"+++def test_suggested_axis_is_expressed_in_the_joint_frame(tmp_path):+ """PR #3 review: the suggestion was a WORLD vector written into the JOINT-frame+ <axis>; with a rotated joint origin the 'exact' repair installed a provably wrong+ axis and the motion gate kept its ERROR every round. The suggestion must FIX the+ motion when installed."""+ import numpy as np++ from codeverse.spatial.joints_model import load_urdf+ from codeverse.spatial.joints_sweep import motion_direction_check++ urdf = tmp_path / "r.urdf"+ urdf.write_text(+ '<robot name="r">\n'+ ' <link name="base"><visual><geometry><box size="0.2 0.2 0.2"/></geometry></visual>\n'+ ' <collision><geometry><box size="0.2 0.2 0.2"/></geometry></collision></link>\n'+ ' <link name="door"><visual><origin xyz="0.3 0 0"/><geometry><box size="0.6 0.05 0.4"/></geometry></visual>\n'+ ' <collision><origin xyz="0.3 0 0"/><geometry><box size="0.6 0.05 0.4"/></geometry></collision></link>\n'+ ' <joint name="hinge" type="revolute">\n'+ ' <parent link="base"/><child link="door"/>\n'+ ' <origin xyz="0.1 0 0" rpy="0 0 1.5708"/>\n'+ ' <axis xyz="1 0 0"/>\n'+ ' <limit lower="0" upper="1.57" effort="10" velocity="1"/>\n'+ ' </joint>\n</robot>')+ robot = load_urdf(urdf, load_meshes=True)+ chk = motion_direction_check(robot, "hinge", "up")+ assert not chk.ok and chk.suggested_axis is not None+ robot.joints["hinge"].axis = np.asarray(chk.suggested_axis, dtype=float)+ after = motion_direction_check(robot, "hinge", "up")+ assert after.ok and after.cos > 0.9, "installing the suggestion must actually fix the motion"