Skip to content

hylo.codeagents.fakes

Package: hylo-code-agents · Core contracts

fakes

Test doubles for code agents: a toy manipulation environment and a toolkit with the hylo.manip Tools signatures.

Not an evaluation environment (the real ones are hylo-bench's mujoco/manip-v0). The toy robot is Cartesian: its three "joints" are the TCP position, so a plan is a straight line and no kinematics are needed; the hand is a parallel gripper that stops half closed on a block (so holding works as on a real hand). Blocks and a bin lie on a table at z = 0; the task is "put the block in the bin". The toy observation carries object positions in extra["objects"] (perception for the fake toolkit), so programs written against the toolkit verbs run unchanged.

env:       {type: "hylo.codeagents.fakes:ToyManipEnv"}
benchmark: {type: "hylo.codeagents.fakes:toy_benchmark", params: {protocol: rsi}}
tools:     {type: "hylo.codeagents.fakes:FakeTools"}          (code.llm / code.program params)

HOME module-attribute

HOME = (0.0, 0.0, 0.3)

BLOCK module-attribute

BLOCK = 0.04

BIN module-attribute

BIN = 0.06

SPEED module-attribute

SPEED = 0.05

IMG module-attribute

IMG = 48

COLOURS module-attribute

COLOURS = {'red': (220, 40, 40), 'blue': (40, 80, 220), 'yellow': (230, 200, 40)}

TOY_SOLUTION module-attribute

TOY_SOLUTION = '\ndef solve(robot):\n    status = robot.status()\n    words = status["instruction"].split()\n    colour = words[words.index("block") - 1]\n    view = robot.look()\n    table = robot.table(view)\n    block = robot.objects(view, robot.find(view, [colour + " block"]), table)[0]\n    target = robot.objects(view, robot.find(view, ["bin"]), table)[0]\n    grasp = robot.plan(robot.grasps("arm", block.points, table), table=table)\n    robot.run(grasp)\n    xy = target.points.mean(axis=0)[:2]\n    robot.run(robot.plan(robot.place_at("arm", np.eye(4), block.points, xy, table=table), table=table))\n    home = robot.Goal("home", "arm", joints=np.array([0.0, 0.0, 0.3]))\n    robot.run(robot.plan(home, table=table))\n    print("placed", colour, "at", np.round(xy, 3))\n'.strip('\n')

ToyManipEnv

ToyManipEnv(terminate_on_success: bool = False)

terminate_on_success instance-attribute

terminate_on_success = terminate_on_success

spec

spec() -> EnvSpec

reset

reset(task: TaskInstance) -> Observation

step

step(action: Action) -> StepResult

privileged_state

privileged_state() -> dict[str, Any]

close

close() -> None

FakeTools

FakeTools(spec: RobotSpec, executor: Executor, *, segmenter: Any | None = None, control_hz: float = 20.0, show: Callable[[ndarray, str], None] | None = None, max_vel: float | Sequence[float] = 1.0, max_acc: float | Sequence[float] = 2.0, seed: int = 0)

Bases: Tools

The toolkit's verbs over the toy environment (perception from extra["objects"], straight-line plans).

status

status() -> dict[str, Any]

look

look() -> View

find

find(view: View, labels: str | Sequence[str]) -> list[Mask]

table

table(view: View) -> Table

objects

objects(view: View, masks: Sequence[Mask], table: Table) -> list[Detection]

box

box(points: ndarray, table: Table | None = None) -> Box

grasps

grasps(arm: str, points: ndarray, table: Table, scene: ndarray | None = None) -> list[Goal]

grasp_at

grasp_at(arm: str, tcp: ndarray, hand: Sequence[float] | None = None) -> Goal

place_at

place_at(arm: str, obj_in_tcp: ndarray, obj_points: ndarray, xy: Sequence[float], yaw: float | None = None, table: Table | None = None, hover: float = 0.03) -> Goal

plan

plan(goals: Goal | Sequence[Goal], table: Table | None = None, scene: ndarray | None = None) -> Plan | None

run

run(plan: Plan) -> dict[str, Any]

holding

holding(arm: str) -> bool | None

carried

carried(view: View, points: ndarray, tcp_before: ndarray, tcp_now: ndarray, table: Table) -> dict[str, Any]

show

show(image: View | ndarray, note: str = '') -> None

toy_robot

toy_robot() -> RobotSpec

toy_tasks

toy_tasks(max_steps: int = 300) -> tuple[TaskSpec, ...]

toy_benchmark

toy_benchmark(protocol: str = 'rsi', n_states: int = 40, bounds: Sequence[int] = (6, 12, 26), max_steps: int = 300) -> Benchmark