Skip to content

hylo.codeagents.robot_surface

Package: hylo-code-agents · Core contracts

robot_surface

The robot as typed tools (RFC-0007 part 2): what the tools.llm agent calls, built on the manipulation toolkit.

Read tools look, measure and compute; they never move the robot and several may share one model reply. Act tools are action proposals: each is bound to the observation step it was decided on, recorded (agent.tool.proposal), planned and executed through the kernel and the SafetyShield, and answered with a measured receipt (agent.tool.receipt): status (refused / arrived / stopped_short / episode_ended), steps, residual TCP error, hand state, holding. A refusal that moved nothing does not count as a decision. finish ends the episode with an outcome the agent states; the task's own success check stays the verdict and is never shown.

Frames and units: world frame, metres, +z up; orientations are quaternions in (x, y, z, w) order; the TCP follows hylo.core.robot (+x approach, +y closing axis). Targets and grasp options are named handles (t1, g3) valid for the observation they came from: after the robot moves they are stale and must be measured again.

NUM module-attribute

NUM = {'type': 'number', 'description': 'number'}

CALC_NUMPY module-attribute

CALC_NUMPY = {'array', 'dot', 'cross', 'sqrt', 'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', 'arctan2', 'deg2rad', 'rad2deg', 'radians', 'degrees', 'mean', 'median', 'min', 'max', 'abs', 'clip', 'sum', 'round', 'linspace', 'stack', 'concatenate', 'eye', 'zeros', 'ones', 'transpose', 'norm', 'linalg', 'inv', 'matmul', 'outer', 'hypot', 'sign', 'floor', 'ceil', 'argmin', 'argmax', 'pi', 'minimum', 'maximum'}

CALC_NODES module-attribute

CALC_NODES = (ast.Module, ast.Expr, ast.Assign, ast.Name, ast.Load, ast.Store, ast.Constant, ast.BinOp, ast.UnaryOp, ast.Call, ast.Attribute, ast.List, ast.Tuple, ast.Subscript, ast.Slice, ast.Compare, ast.BoolOp, ast.IfExp, ast.keyword, ast.Dict, ast.operator, ast.unaryop, ast.cmpop, ast.boolop)

CALC_HELPERS module-attribute

CALC_HELPERS: dict[str, Callable[..., Any]] = {'quat_to_matrix': lambda q: Rotation.from_quat(np.asarray(q, float)).as_matrix(), 'matrix_to_quat': lambda m: Rotation.from_matrix(np.asarray(m, float)).as_quat(), 'quat_from_axis_angle': lambda axis, deg: Rotation.from_rotvec(np.asarray(axis, float) / np.linalg.norm(axis) * math.radians(deg)).as_quat(), 'quat_multiply': lambda a, b: (Rotation.from_quat(np.asarray(a, float)) * Rotation.from_quat(np.asarray(b, float))).as_quat(), 'rotate': _rotate, 'euler_deg_to_quat': lambda r, p, y: Rotation.from_euler('xyz', [r, p, y], degrees=True).as_quat(), 'quat_to_euler_deg': lambda q: Rotation.from_quat(np.asarray(q, float)).as_euler('xyz', degrees=True), 'angle_deg': lambda a, b: math.degrees(math.acos(max(-1.0, min(1.0, float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))))))), 'dist': lambda a, b: float(np.linalg.norm(np.asarray(a, float) - np.asarray(b, float))), 'len': len, 'abs': abs, 'min': min, 'max': max, 'round': round, 'float': float, 'int': int}

RobotSurface

RobotSurface(tools: Any, *, emit: Callable[[str, Mapping[str, Any]], None] | None = None, finish: Callable[[str, str], Any] | None = None, overlay_camera: str | None = None, grasp_lift_m: float = 0.08, place_retreat_m: float = 0.08)

Typed tools over one robot for one episode. tools: a hylo.manip Tools; status: the episode status (step, max_steps); emit(type, payload): trace events; finish(outcome, reason): ends the episode.

spec instance-attribute

spec = tools.spec

overlay_camera instance-attribute

overlay_camera = overlay_camera

targets instance-attribute

targets: dict[str, dict[str, Any]] = {}

options instance-attribute

options: dict[str, dict[str, Any]] = {}

marks instance-attribute

marks: dict[str, dict[str, Any]] = {}

held instance-attribute

held: dict[str, dict[str, Any]] = {}

previous instance-attribute

previous: dict[str, ndarray] = {}

decisions instance-attribute

decisions = 0

refused instance-attribute

refused = 0

outcome instance-attribute

outcome: dict[str, Any] | None = None

issues instance-attribute

issues: list[str] = []

surface instance-attribute

surface = self._build()

emit

emit(type_: str, payload: Mapping[str, Any]) -> None

step

step() -> int

arms

arms() -> list[str]

view

view() -> tuple[Any, Any]

The latest view and table, measured once per observation step.

robot_state

robot_state(args: dict[str, Any]) -> dict[str, Any]

look

look(args: dict[str, Any]) -> ToolOutput

locate

locate(args: dict[str, Any]) -> ToolOutput

pixel_to_world

pixel_to_world(args: dict[str, Any]) -> dict[str, Any]

world_to_pixel

world_to_pixel(args: dict[str, Any]) -> dict[str, Any]

calc_tool

calc_tool(args: dict[str, Any]) -> dict[str, Any]

grasp_options

grasp_options(args: dict[str, Any]) -> dict[str, Any]

reach_check

reach_check(args: dict[str, Any]) -> dict[str, Any]

report_issue

report_issue(args: dict[str, Any]) -> dict[str, Any]

move_tcp

move_tcp(args: dict[str, Any]) -> dict[str, Any]

grasp

grasp(args: dict[str, Any]) -> dict[str, Any]

place

place(args: dict[str, Any]) -> dict[str, Any]

gripper

gripper(args: dict[str, Any]) -> dict[str, Any]

recover

recover(args: dict[str, Any]) -> dict[str, Any]

wait

wait(args: dict[str, Any]) -> dict[str, Any]

finish

finish(args: dict[str, Any]) -> dict[str, Any]

vec

vec(n: int, what: str) -> dict[str, Any]

calc

calc(code: str, bindings: Mapping[str, Any] | None = None, outputs: list[str] | None = None) -> dict[str, Any]

Evaluate assignments and expressions with numbers, numpy and the rotation helpers; no loops, imports or definitions. Returns the named outputs, else the value of the last expression.

project

project(cam: Any, pts: ndarray) -> tuple[np.ndarray, np.ndarray]

Pixels (N, 2) of world points in an OpenCV-frame camera and whether each is in front of it.