Skip to content

hylo.codeagents.scene_free_check

Package: hylo-code-agents · Core contracts

scene_free_check

The checker for free-form scene programs (hylo.freescene/v0.1, env mujoco.free_scene).

report = check_free_scene("runs/scenes_free/cable/scene.py")
report.ok, report.text()

A free scene has no schema to validate against and no predicate language to reason about, so the checks are behavioural: build it, run it, and try to satisfy it. Stages, in order (later ones need the earlier ones to pass):

  1. program the source passes the scene-program allow-list (validate_scene_program, below) and defines ROBOT, INSTRUCTION, build(scene) and success(sim)
  2. load the environment builds the scene with the robot and compiles it (build errors, MuJoCo compiler errors, actuators or keyframes added, randomize errors come back with the program's own lines)
  3. physics per seed: no deep start overlaps (scene-scene, scene-table, scene-robot at its home posture); 2 s of doing nothing: the simulation does not diverge, nothing falls off the table, rigid bodies stay within 2 cm and 10 degrees, cable nodes and cloth vertices within 5 cm, joints stay put, and nothing is still moving at the end; success(sim) runs, returns a bool, is False at the start and stays False
  4. reach on the settled state, with hylo-manip's IK on the robot's RobotSpec: every movable thing (free body, cable, cloth, hinged or sliding part) has a point some arm reaches with a top-down or side approach and a pre-pose 8 cm back, and so does every point the program's targets(sim) names
  5. satisfiable demo(sim) runs with invisible hands (physics only, the robot holds still) and success(sim) becomes True during it or after the hands let go; every point a hand grabbed is reachable by an arm. Without a demo the stage is a warning ("unverified")

What it cannot verify: that the success function means what the instruction says (a demo that satisfies a wrong function passes), that a real gripper (rather than an invisible hand) can hold a thin cable or a cloth corner, and that both arms can act at once where a task needs two hands at the same time (each point is checked on its own).

FREE_ENV module-attribute

FREE_ENV = 'mujoco.free_scene'

STILL module-attribute

STILL = 0.005

DEMO_HANDS module-attribute

DEMO_HANDS = 4

SCENE_IMPORTS module-attribute

SCENE_IMPORTS = ALLOWED_IMPORTS | {'mujoco'}

SCENE_DENIED_ATTRS module-attribute

SCENE_DENIED_ATTRS = DENIED_ATTRS | {'from_file', 'to_file', 'from_zip', 'to_zip', 'from_xml_path', 'from_binary_path', 'mj_saveLastXML', 'mj_saveModel', 'mj_loadXML', 'mj_loadModel', 'mj_printModel', 'mj_printData', 'mj_printSchema', 'viewer', 'rollout', 'plugin_paths', 'mj_loadPluginLibrary', 'mj_loadAllPluginLibraries'}

FreeSceneChecker

FreeSceneChecker(seeds: Sequence[int] = (0, 1, 2), settle_s: float = 2.0, reach: bool = True, satisfiable: bool = True, timeout_s: float = 600.0, env_type: str = FREE_ENV)

Checks scene programs; one environment per program (built through the registry, cameras off).

close

close() -> None

check

check(source: str | Path) -> CheckReport

reachable_by

reachable_by(xyz: Sequence[float], back: float = 0.08) -> list[str]

The arms that reach xyz with a top-down or side TCP and the pre-pose back metres before it.

validate_scene_program

validate_scene_program(source: str, filename: str = 'scene.py') -> ast.Module

Parse and check a scene program; raises CodeRejected listing the problems.

scene_program_path

scene_program_path(source: str | Path) -> Path

program_declarations

program_declarations(source: str) -> tuple[dict[str, Any], list[Problem]]

The literal declarations and the defined functions of a scene program (without running it).

movable_points

movable_points(state: dict) -> dict[str, list[list[float]]]

Sample points of everything a robot could move: free bodies (centre and top), jointed parts (centre), cables (both ends and the middle), cloth / flex (corners of its extent and its centre).

motion_problems

motion_problems(start: dict, end: dict, mark: dict | None, tag: str, settle_s: float) -> list[Problem]

What moved, fell or drifted between two privileged states of a free scene.

summary

summary(state: dict) -> dict[str, Any]

A compact picture of the settled scene for the author: bodies (centre, extent), cable ends, flex extents, joint values.

check_free_scene

check_free_scene(source: str | Path, **kw: Any) -> CheckReport