A folder that still has an adapter changes in five places, so that the policy does its work: the benchmark builds
the arm, and the policy reads that arm’s observations as the benchmark gives them and answers in its actions.
pi05-libero had one at v13 and reads LIBERO’s own
observation since v29; the Python below is its v30’s. The changes need sequence-ai 0.68.0 or later
(pip install -U sequence-ai).
Read the observation in the policy
Move the function that turned the benchmark’s observation into the policy’s into
policy.py, and call it in infer on each observation. pi05-libero’s
to_policy is now _libero_inputs, which reads LIBERO’s observation as its benchmark
hands one from v21 on; _is_libero tells that from a robot’s by its keys, and
_inputs reads a robot’s.
@seq.infer def infer(self, obs: dict, *, seed: list[int | None]) -> dict | list: ... rows = _rows(obs) ... libero = _is_libero(rows[0]) natives = [_libero_inputs(o) if libero else _inputs(o) for o in rows]
It returns the pictures as arrays, with no sequence_ai.Video around them:
def _libero_inputs(obs: dict) -> dict: ... quat, fingers = _as_panda(obs) pos = [float(v) for v in np.asarray(obs["robot0_eef_pos"], dtype=float).reshape(-1)] return {"observation/image": _frame(obs["agentview_image"]), "observation/wrist_image": _frame(obs["robot0_eye_in_hand_image"]), "observation/state": np.asarray(pos + _quat2axisangle(quat) + fingers, dtype=np.float32), "prompt": str(obs["instruction"])}
Read another arm as the one it learned
Move along the function that read another arm’s observation as the one the policy learned.
pi05-libero’s _as_panda reads Panda’s as it is; another arm’s hand quaternion it puts
in the half of the sphere Panda’s start is in, and its gripper’s opening on Panda’s two fingers.
LIBERO’s observation says which arm it is of (robot) and how far its gripper is open
(robot0_gripper_open).
_PANDA_HAND = (0.9996, 0.0002, -0.0284, 0.0) _PANDA_FINGERS = ((0.0397, -0.0397), (0.0005, -0.0005)) ... def _as_panda(obs: dict) -> tuple[list[float], list[float]]: ... quat = [float(q) for q in np.asarray(obs["robot0_eef_quat"], dtype=float).reshape(-1)] if obs.get("robot", "Panda") == "Panda": return quat, [float(v) for v in np.asarray(obs["robot0_gripper_qpos"], dtype=float).reshape(-1)][:2] if sum(a * b for a, b in zip(quat, _PANDA_HAND)) < 0: quat = [-q for q in quat] f = float(obs["robot0_gripper_open"]) (o1, o2), (c1, c2) = _PANDA_FINGERS return quat, [c1 + f * (o1 - c1), c2 + f * (o2 - c2)]
Answer in the benchmark’s actions
Move the function that turned the policy’s answer into the benchmark’s actions to the end of
infer, which answers a list of actions, one a step. pi05-libero’s to_benchmark is
now these lines: on LIBERO’s observation the 10 actions as a list, each 7 numbers; on a robot’s, the
answer as before.
if libero: return [[[float(v) for v in row[:7]] for row in a] for a in actions] return {"actions": actions}
Say the arms it takes
Where @seq.policy says robot, say arm: the arm’s id, as
seq arm ls prints it, or a list of the arms the policy takes, each once. pi05-libero v29 says
arm="franka-panda"; v30 names six of LIBERO’s, Panda first.
@seq.policy(
name="pi05-libero",
arm=["franka-panda", "ur5e", "kinova3", "kuka-iiwa7", "sawyer", "jaco"],
...
Delete the file
Delete the file the class was in: nothing names it any more.