Skip to content

hylo.codeagents.scene_check

Package: hylo-code-agents · Core contracts

scene_check

The scene checker (RFC-0006 part 8): is a hylo.scene/v0.1 file a fair task for the robot?

report = check_scene("scene.json")           # env "mujoco.panda_scene", seeds (0, 1)
report.ok, [p.message for p in report.problems]

Checks, in order (later ones need the earlier ones to pass):

  1. schema the file parses and validates against hylo.core.scene.Scene
  2. static names and labels unique, references resolve, no attachment cycles, the predicate can hold at all (hylo.core.scene.scene_problems)
  3. physics per seed, through the Environment contract with privileged observations: the scene loads; start poses fit (no free position in a region, overlaps deeper than 3 mm); after settling 2 s nothing fell off, nothing moved more than 2 cm or tilted more than 10 degrees, joints stayed put, nothing penetrates (objects, table, robot); the success predicate is false at the start and stays false while settling
  4. reach on the settled state, with hylo-manip's IK on the env's RobotSpec: every movable object has a top-down (or side) grasp the arm reaches, with a pre-grasp 10 cm back, and fits the open hand; every jointed part is reachable at its centre and at the end of its travel; every place target (b of on / inside / above, inside regions, near points) is reachable 5 cm above its top

Problems are hylo.core.scene.Problem records (code, message, objects, severity); warnings do not fail a scene.

DEFAULT_ENV module-attribute

DEFAULT_ENV = 'mujoco.panda_scene'

GRASP_MARGIN module-attribute

GRASP_MARGIN = 0.01

CheckReport

Bases: Contract

ok instance-attribute

ok: bool

problems class-attribute instance-attribute

problems: tuple[Problem, ...] = ()

warnings class-attribute instance-attribute

warnings: tuple[Problem, ...] = ()

stages class-attribute instance-attribute

stages: tuple[str, ...] = ()

settled class-attribute instance-attribute

settled: dict[str, Any] = {}

text

text(limit: int = 30) -> str

The problems as a numbered list, for a model or a terminal.

SceneChecker

SceneChecker(env_type: str = DEFAULT_ENV, seeds: Sequence[int] = (0, 1), settle_s: float = 2.0, reach: bool = True, satisfiable: bool = True)

Runs the checks; holds one environment (built through the registry, cameras off, privileged on).

satisfiable instance-attribute

satisfiable = satisfiable

env

env() -> Any

close

close() -> None

check

check(source: str | Path | dict | Scene, path: str | Path | None = None) -> CheckReport

Check a scene. The physics stages need it on disk: path (default: source when it is a path).

problem

problem(code: str, message: str, *objects: str, severity: str = 'error') -> Problem

A checker Problem (shared by the fixed-format and the free checker).

parse_scene

parse_scene(source: str | Path | dict | Scene) -> tuple[Scene | None, list[Problem]]

A Scene from a path, JSON text, a mapping or a Scene; or the schema problems.

quat_matrix

quat_matrix(q: Sequence[float]) -> np.ndarray

Rotation matrix of a (w, x, y, z) quaternion.

tilt_deg

tilt_deg(q0: Sequence[float], q1: Sequence[float]) -> float

The angle (degrees) between two orientations given as (w, x, y, z) quaternions.

leaves

leaves(terms: Sequence[Any]) -> list[Any]

The atomic terms an arrangement aims at (all_of flattened, the first option of any_of).

arrangement

arrangement(terms: Sequence[Any], objs: dict[str, Any], scene: Scene, skip: set[str] = frozenset()) -> tuple[dict, dict] | None

Poses {name: (pos, quat)} and joint values that should make terms hold, from the settled state objs (privileged objects). None when a term cannot be arranged (lifted, not, a non-movable subject).

dedupe

dedupe(problems: list[Problem]) -> list[Problem]

The problems without repeats (the same code and message on another seed counts as a repeat).

check_scene

check_scene(source: str | Path | dict | Scene, path: str | Path | None = None, **kw: Any) -> CheckReport