Instructions to use ReasoningKingdom/LITOperator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use ReasoningKingdom/LITOperator with LeRobot:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Keep only the real+sim simulation showcase
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144#!/usr/bin/env python3"""render_arm_3d.py — the pretrained tree in a pure 3D orthographic view.
Picks an episode from the tree with a wide base-yaw sweep (q0) and a lowjerk, then renders the arm in a real x/y/z frame: base yaw q0 around z,q1..q4 the pitch chain. No 2D panel, no random counterfactual ghost;only the smooth tree path.
python demo/render_arm_3d.py # -> demo/lit_arm_control_3d.mp4"""import argparseimport osimport sys
import numpy as np
HERE = os.path.dirname(os.path.abspath(__file__))sys.path.insert(0, HERE)
from tree_io import (CKPT, LINK, REPO, SUB, chain_from, # noqa: E402 children_map, load_snapshot)
OUT = os.path.join(HERE, "lit_arm_control_3d.mp4")# episode 21 of the first subdataset: q0 range 92.7 deg, jerk 0.28START_NODE = 22601BG, FG, GRID = "#0d1117", "#c9d1d9", "#30363d"ARM, TRAIL = "#ff7b39", "#58a6ff"
def fk3(a): """3D arm: yaw q0 around z, pitch chain q1..q4.""" q = np.radians(np.asarray(a[:5], dtype=np.float64)) yaw = q[0] if len(q) > 0 else 0.0 ang = q[1] if len(q) > 1 else 0.0 r, z = 0.0, 0.02 pts = [(0.0, 0.0, z)] for i in range(4): if i > 0 and i + 1 < len(q): ang += q[i + 1] r += LINK[i] * np.cos(ang) z += LINK[i] * np.sin(ang) pts.append((r * np.cos(yaw), r * np.sin(yaw), z)) return np.asarray(pts)
def draw_arm(ax, a): pts = fk3(a) ax.plot(pts[:, 0], pts[:, 1], pts[:, 2], "-", color=ARM, linewidth=3.2, zorder=5) tip = pts[-1] d = pts[-1] - pts[-2] side = np.array([-d[1], d[0], 0.0]) side = side / (np.linalg.norm(side) + 1e-9) q5 = float(a[5]) if len(a) > 5 else 0.0 spread = 0.018 if q5 > 0.5 else 0.007 for s in (-1, 1): ax.plot([tip[0], tip[0] + s * spread * side[0]], [tip[1], tip[1] + s * spread * side[1]], [tip[2], tip[2] + s * spread * side[2]], "-", color=FG, linewidth=2, zorder=5)
def main(): p = argparse.ArgumentParser(description=__doc__) p.add_argument("--start-node", type=int, default=START_NODE) args = p.parse_args()
import shutil tmp = "/tmp/lit_ckpt_3d.safetensors" shutil.copyfile(CKPT, tmp) snap = load_snapshot(tmp) parent, g = snap["parent"], snap["g"] act_id, act_x = snap["act_id"], snap["act_x"] children = children_map(parent) path = chain_from(children, g, args.start_node) print("tree nodes", len(parent), "start", args.start_node, "path", len(path))
from lit_stream import make_codec codec, _info = make_codec(REPO, SUB)
def code(i): return int(act_id[i]) | (int(act_x[i]) << 32)
acts = np.array([codec.action_vec(code(i)) for i in path]) eef = np.array([fk3(a)[-1] for a in acts]) print("q0 range %.1f deg jerk %.2f" % (acts[:, 0].max() - acts[:, 0].min(), np.abs(np.diff(acts[:, 1:5], axis=0)).mean()))
import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt from matplotlib.animation import FFMpegWriter
stride = max(1, len(path) // 240) frames = list(range(0, len(path), stride)) fig = plt.figure(figsize=(8, 8)) fig.patch.set_facecolor(BG) fig.subplots_adjust(left=0.04, right=0.96, bottom=0.04, top=0.88) ax = fig.add_subplot(111, projection="3d") title = fig.text(0.5, 0.975, "", ha="center", va="top", color=FG, fontsize=10)
def update(k): ax.cla() ax.set_facecolor(BG) ax.set_proj_type("ortho") ax.view_init(elev=30, azim=-125) ax.set_xlim(-0.40, 0.40) ax.set_ylim(-0.40, 0.40) ax.set_zlim(0.0, 0.50) try: ax.set_box_aspect((1, 1, 1.15), zoom=1.2) except TypeError: ax.set_box_aspect((1, 1, 1.15)) for axis in (ax.xaxis, ax.yaxis, ax.zaxis): axis.pane.fill = False axis.pane.set_edgecolor(BG) axis.line.set_color(GRID) ax.tick_params(colors=FG, labelsize=8) for axis in (ax.xaxis, ax.yaxis, ax.zaxis): axis.label.set_color(FG) ax.grid(True, color=GRID, alpha=0.5) ax.plot([0], [0], [0], "o", color=FG, markersize=5, zorder=5) ax.plot(eef[:k + 1, 0], eef[:k + 1, 1], eef[:k + 1, 2], "-", color=TRAIL, linewidth=1.1, alpha=0.55) draw_arm(ax, acts[k]) title.set_text("LITOperator — SO-100 / pretrained tree\n" "3D orthographic frame %d/%d" % (k, len(path) - 1)) return []
anim = matplotlib.animation.FuncAnimation( fig, update, frames=frames, interval=1000 // 30, blit=False) anim.save(OUT, writer=FFMpegWriter(fps=30, bitrate=2400), dpi=110, savefig_kwargs={"facecolor": BG}) print("saved", OUT, os.path.getsize(OUT)) return 0
if __name__ == "__main__": raise SystemExit(main())demo/render_arm_3d.pyDeleted-144