Shubham-Rasal Claude Sonnet 4.6 commited on
Commit
073a3e5
·
1 Parent(s): 654b826

Fix row-count mismatch in extract_episode for PhAIL signals

Browse files

robot_state.q and robot_commands.pose have different sampling rates,
producing arrays with incompatible row counts. Truncate both to
min(rows) before computing tracking effort.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -42,9 +42,11 @@ def extract_episode(states, actions):
42
  actions = np.array(actions, dtype=float)
43
  dq = np.diff(states, axis=0)
44
  speed = np.linalg.norm(dq, axis=1) * FS
45
- # align dims before subtracting — state and action may differ (e.g. Franka 13 vs 15)
46
- min_dim = min(states.shape[1], actions.shape[1])
47
- effort = np.linalg.norm(actions[:, :min_dim] - states[:, :min_dim], axis=1)
 
 
48
  raw_z = states[:, 1]
49
  z = (raw_z - raw_z.min()) / (raw_z.max() - raw_z.min() + 1e-9)
50
  return speed, effort, z
 
42
  actions = np.array(actions, dtype=float)
43
  dq = np.diff(states, axis=0)
44
  speed = np.linalg.norm(dq, axis=1) * FS
45
+ # align both rows and dims before subtracting
46
+ min_rows = min(len(states), len(actions))
47
+ min_dim = min(states.shape[1], actions.shape[1])
48
+ effort = np.linalg.norm(
49
+ actions[:min_rows, :min_dim] - states[:min_rows, :min_dim], axis=1)
50
  raw_z = states[:, 1]
51
  z = (raw_z - raw_z.min()) / (raw_z.max() - raw_z.min() + 1e-9)
52
  return speed, effort, z