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 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)
COLOURS
module-attribute
¶
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 ¶
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).
grasps ¶
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
carried ¶
carried(view: View, points: ndarray, tcp_before: ndarray, tcp_now: ndarray, table: Table) -> dict[str, Any]
toy_benchmark ¶
toy_benchmark(protocol: str = 'rsi', n_states: int = 40, bounds: Sequence[int] = (6, 12, 26), max_steps: int = 300) -> Benchmark