Spaces:
Running on Zero
Running on Zero
Normalize with median new-calibration SO-101 dataset stats; sim joints in LeRobot degrees directly
Browse files
app.py
CHANGED
|
@@ -60,7 +60,20 @@ CAM_W, CAM_H = 320, 240
|
|
| 60 |
VIDEO_W, VIDEO_H = 480, 360
|
| 61 |
VIDEO_STRIDE = 2
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
policy = load_policy(REPO).to("cuda")
|
|
|
|
|
|
|
| 64 |
SNAPSHOTS = [0, N_OBS - 1]
|
| 65 |
|
| 66 |
MESH_MANIFEST = viewer.export_meshes(sim.build_model(next(iter(sim.SCENES))))
|
|
@@ -146,7 +159,7 @@ def rollout_gpu(prompt, scene, n_chunks, seed, make_video):
|
|
| 146 |
r0 = time.perf_counter()
|
| 147 |
cams = (env.render("scene"), env.render("wrist")) if _needs_cams(tick) else (None, None)
|
| 148 |
stats["cam_render"] += time.perf_counter() - r0
|
| 149 |
-
state =
|
| 150 |
command = state if last_command is None else last_command
|
| 151 |
entry = (cams[0], cams[1], state, command)
|
| 152 |
for _ in range(N_OBS if not history else 1):
|
|
@@ -161,7 +174,7 @@ def rollout_gpu(prompt, scene, n_chunks, seed, make_video):
|
|
| 161 |
action = np.asarray(chunk[tick % N_EXEC], dtype=np.float64)
|
| 162 |
last_command = action
|
| 163 |
p0 = time.perf_counter()
|
| 164 |
-
env.step(
|
| 165 |
stats["physics"] += time.perf_counter() - p0
|
| 166 |
q0 = time.perf_counter()
|
| 167 |
poses.append(viewer.body_poses(env.data, bodies))
|
|
|
|
| 60 |
VIDEO_W, VIDEO_H = 480, 360
|
| 61 |
VIDEO_STRIDE = 2
|
| 62 |
|
| 63 |
+
NORMALIZATION = {
|
| 64 |
+
"state": {
|
| 65 |
+
"q01": [-37.969, -99.316, -45.78, 22.987, -68.712, 0.45],
|
| 66 |
+
"q99": [35.288, 43.076, 90.308, 95.704, 17.753, 40.324],
|
| 67 |
+
},
|
| 68 |
+
"action": {
|
| 69 |
+
"q01": [-1.652, -3.235, -3.147, -2.198, -1.708, 0.0],
|
| 70 |
+
"q99": [1.701, 3.487, 3.307, 2.072, 1.699, 40.733],
|
| 71 |
+
},
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
policy = load_policy(REPO).to("cuda")
|
| 75 |
+
policy.config.state_normalization = NORMALIZATION["state"]
|
| 76 |
+
policy.config.action_normalization = NORMALIZATION["action"]
|
| 77 |
SNAPSHOTS = [0, N_OBS - 1]
|
| 78 |
|
| 79 |
MESH_MANIFEST = viewer.export_meshes(sim.build_model(next(iter(sim.SCENES))))
|
|
|
|
| 159 |
r0 = time.perf_counter()
|
| 160 |
cams = (env.render("scene"), env.render("wrist")) if _needs_cams(tick) else (None, None)
|
| 161 |
stats["cam_render"] += time.perf_counter() - r0
|
| 162 |
+
state = env.state_deg()
|
| 163 |
command = state if last_command is None else last_command
|
| 164 |
entry = (cams[0], cams[1], state, command)
|
| 165 |
for _ in range(N_OBS if not history else 1):
|
|
|
|
| 174 |
action = np.asarray(chunk[tick % N_EXEC], dtype=np.float64)
|
| 175 |
last_command = action
|
| 176 |
p0 = time.perf_counter()
|
| 177 |
+
env.step(action)
|
| 178 |
stats["physics"] += time.perf_counter() - p0
|
| 179 |
q0 = time.perf_counter()
|
| 180 |
poses.append(viewer.body_poses(env.data, bodies))
|
sim.py
CHANGED
|
@@ -139,18 +139,6 @@ def q_to_deg(q):
|
|
| 139 |
return np.concatenate([deg, [g]])
|
| 140 |
|
| 141 |
|
| 142 |
-
MODEL_SIGN = np.array([1.0, -1.0, 1.0, 1.0, 1.0, 1.0])
|
| 143 |
-
MODEL_OFFSET = np.array([0.0, 90.0, 90.0, 0.0, -90.0, 0.0])
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
def lerobot_to_model(deg, sign=MODEL_SIGN, offset=MODEL_OFFSET):
|
| 147 |
-
return np.asarray(deg, dtype=np.float64) * sign + offset
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
def model_to_lerobot(val, sign=MODEL_SIGN, offset=MODEL_OFFSET):
|
| 151 |
-
return (np.asarray(val, dtype=np.float64) - offset) / sign
|
| 152 |
-
|
| 153 |
-
|
| 154 |
@dataclass
|
| 155 |
class Sim:
|
| 156 |
scene: str = "Cubes and tray"
|
|
|
|
| 139 |
return np.concatenate([deg, [g]])
|
| 140 |
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
@dataclass
|
| 143 |
class Sim:
|
| 144 |
scene: str = "Cubes and tray"
|