hylo.codeagents.replay_geom¶
Package: hylo-code-agents · Core contracts
replay_geom ¶
Geometry, checks, video and the simulation client of replay-to-sim (RFC-0006 part 8), all without MuJoCo.
MuJoCo runs in the isolated worker replay_sim.py (uv run --script, like the hylo-tools and motion workers), so
it never enters the agent's process. SimClient writes the objects' meshes, sends one request per call (build the
scene, kinematic replay, physics replay) and reads the arrays back. Here: meshes (OBJ I/O, convex hulls, boxes,
extrusion to the table), pose and size errors, event checks of the simulation, final-state success and the
side-by-side video.
SceneObject
dataclass
¶
SceneObject(name: str, label: str, parts: list[tuple[ndarray, ndarray]], visual: tuple[ndarray, ndarray] | None, pose0: ndarray, rgba: tuple[float, float, float, float] = (0.7, 0.7, 0.7, 1.0), dynamic: bool = True, mass: float = 0.1, info: dict[str, Any] = dict())
rgba
class-attribute
instance-attribute
¶
SimClient ¶
Runs replay_sim.py in its own uv environment. One call = one request with ops run in order.
call ¶
call(ops: list[str], params: dict[str, Any], arrays: dict[str, ndarray] | None = None) -> dict[str, Any]
build ¶
build(*, table_z: float, table_extent: ndarray, objects: list[SceneObject], agent: str, arm_model: str | None = None, base: ndarray | None = None, camera: dict[str, Any] | None = None, gripper_T0: ndarray | None = None, image_size: tuple[int, int] = (640, 480), hand: dict[str, Any] | None = None) -> dict[str, Any]
replay ¶
replay(*, time: ndarray, q: ndarray | None, tcp: ndarray | None, opening: ndarray, hand_cmd: ndarray, obj_poses: dict[str, ndarray], held: dict[int, str] | None = None, ops: Sequence[str] = ('kinematic', 'physics'), fingers: ndarray | None = None) -> dict[str, Any]
Kinematic replay (recorded motion into qpos) and physics replay in one worker call. fingers: (T, n) finger joint targets of a multi-finger hand (agent "hand").
box_mesh ¶
box_mesh(size: Sequence[float], yaw: float, centre: Sequence[float]) -> tuple[np.ndarray, np.ndarray]
An oriented box (world frame) as a triangle mesh.
column_parts ¶
column_parts(points: ndarray, table_z: float, cell: float = 0.015, min_pts: int = 3) -> list[tuple[np.ndarray, np.ndarray]]
A 2.5D height field of observed points as box columns standing on the table (one convex part per cell, height = the cell's 95th-percentile point). Keeps the concavity of a container seen from above (a bowl's floor is lower than its rim), which a convex hull would fill.
ground_mesh ¶
Points of a mesh extended down to the table (its footprint projected onto the plane) when the mesh floats
less than max_gap above it: single-view meshes miss the hidden lower part of objects resting on the table.
pose_errors ¶
Translation (m) and rotation (deg) error per frame and summarised.
size_error ¶
Axis-agnostic: sorted extents compared.
sim_events ¶
sim_events(time: ndarray, phys: dict[str, Any], table_z: float, hand_cmd: ndarray) -> list[dict[str, Any]]
Events of the physics replay with the same detector as the recording (closed intervals from the command, since the simulated hand opening is a measurement of the same command), plus finger contact on grasps.
final_state ¶
final_state(ref_final: dict[str, ndarray], sim_final: dict[str, ndarray], moved: Sequence[str], tol: float = 0.03) -> dict[str, Any]
side_by_side ¶
side_by_side(original: ndarray, sim_video: str | Path | None, out: str | Path, fps: float, *, height: int = 360, max_bytes: int = 4000000, labels: tuple[str, str] = ('recording', 'simulation'), sim_frames: ndarray | None = None) -> dict[str, Any]
original | simulation as one MP4 (H.264), re-encoded at a lower bitrate until it fits max_bytes.
write_video ¶
write_video(frames: Sequence[ndarray], out: str | Path, fps: float, max_bytes: int = 4000000) -> dict[str, Any]
Frames (same size, even dimensions after padding) as one H.264 MP4, re-encoded at a lower bitrate until it fits max_bytes.