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.
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.
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 ¶
Pixels (N, 2) of world points in an OpenCV-frame camera and whether each is in front of it.