yxma commited on
Commit
5ba0871
·
verified ·
1 Parent(s): c15e112

Multi-task video release: README + ReactVideoDataset loader

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. examples/react_video_dataset.py +18 -15
README.md CHANGED
@@ -65,7 +65,7 @@ data/<task>/
65
  | `episode` / `episode_index` | str / int | source episode key and its 0-based index within the task |
66
  | `task` / `task_index` | str / int | task name and index (0=motherboard, 1=pushT) |
67
  | `timestamp` | float64 | camera clock (s) |
68
- | `sensor_left_pose`, `sensor_right_pose` | list[7] | OptiTrack world pose of each GelSight (xyz + quat wxyz) |
69
  | `object_pose` | list[7] | OptiTrack world pose of the manipulated object (NaN where the object body was not tracked — e.g. all pushT) |
70
  | `tactile_{L,R}_{intensity,area,mixed}` | float32 | contact metrics (computed at full 640×480) |
71
  | `source_h5_frame` | int | index into the original recording |
 
65
  | `episode` / `episode_index` | str / int | source episode key and its 0-based index within the task |
66
  | `task` / `task_index` | str / int | task name and index (0=motherboard, 1=pushT) |
67
  | `timestamp` | float64 | camera clock (s) |
68
+ | `sensor_left_pose`, `sensor_right_pose` | list[7] | OptiTrack world pose of each GelSight (xyz metres + quat **xyzw**, scalar-LAST — `scipy...Rotation.from_quat` takes it as-is) |
69
  | `object_pose` | list[7] | OptiTrack world pose of the manipulated object (NaN where the object body was not tracked — e.g. all pushT) |
70
  | `tactile_{L,R}_{intensity,area,mixed}` | float32 | contact metrics (computed at full 640×480) |
71
  | `source_h5_frame` | int | index into the original recording |
examples/react_video_dataset.py CHANGED
@@ -81,7 +81,7 @@ class ReactVideoDataset:
81
  def __init__(self, task_root, window_length=16, stride=1, window_step=None,
82
  mode="segment", streams=ALL_STREAMS, skip_bad=True,
83
  which_sensors="any", load_depth=False, tactile_latency=0,
84
- split="all", splits_file="splits.json", up_axis="y"):
85
  self.root = Path(task_root)
86
  self.W = window_length
87
  self.stride = stride
@@ -112,18 +112,17 @@ class ReactVideoDataset:
112
  # contains its frames, so `splits.json` carries a guard of
113
  # max_train_window - 1 and this loader REFUSES a longer window instead
114
  # of leaking — a leak here leaves no trace in any metric.
115
- # UP AXIS. OptiTrack records Y-up, right-handed measured, the table
116
- # normal sits 4.4 deg off +y. Robotics code overwhelmingly assumes
117
- # Z-up, and a reader taking pose[2] as height silently gets a
118
- # horizontal coordinate.
119
  #
120
- # `up_axis="z"` converts the poses this loader yields. It does NOT
121
- # convert your calibration, and converting one without the other moves
122
- # every projection by up to 165 px with nothing raised — so use
123
- # `.calibration()` below, which returns the extrinsics in whichever
124
- # convention this dataset is in.
125
  if up_axis not in ("y", "z"):
126
- raise ValueError(f"up_axis must be 'y' (as recorded) or 'z', got {up_axis!r}")
 
127
  self.up_axis = up_axis
128
 
129
  self.split = split
@@ -157,7 +156,7 @@ class ReactVideoDataset:
157
  """
158
  import shutil as _sh, tempfile as _tf
159
  from react_toolbox.calibration import load_calibration
160
- from react_toolbox.frames import convert_calibration
161
  root = Path(calib_dir) if calib_dir else self.root
162
  if not (root / "calibration").is_dir():
163
  # The published release ships <task>/calibration/. A working tree
@@ -173,13 +172,17 @@ class ReactVideoDataset:
173
  raise FileNotFoundError(
174
  f"no gel calibration under {root}; the published release ships "
175
  f"it at <task>/calibration/. Pass calib_dir= or set REACT_CALIB.")
176
- return cal if self.up_axis == "y" else convert_calibration(cal, True)
 
 
 
177
 
178
  def _convert_pose(self, arr):
179
- if self.up_axis == "y":
 
180
  return arr
181
  from react_toolbox.frames import convert_poses
182
- return convert_poses(arr, True)
183
 
184
  def _video_dir(self, ep_key):
185
  date, ep = ep_key.split("/")
 
81
  def __init__(self, task_root, window_length=16, stride=1, window_step=None,
82
  mode="segment", streams=ALL_STREAMS, skip_bad=True,
83
  which_sensors="any", load_depth=False, tactile_latency=0,
84
+ split="all", splits_file="splits.json", up_axis="z"):
85
  self.root = Path(task_root)
86
  self.W = window_length
87
  self.stride = stride
 
112
  # contains its frames, so `splits.json` carries a guard of
113
  # max_train_window - 1 and this loader REFUSES a longer window instead
114
  # of leaking — a leak here leaves no trace in any metric.
115
+ # UP AXIS. The release ships Z-up (table normal 4.4 deg off +z), which
116
+ # is what robotics code assumes. OptiTrack itself records Y-up; that is
117
+ # available as `up_axis="y"` for anything that wants the raw convention.
 
118
  #
119
+ # Either way, take the calibration from `.calibration()` below rather
120
+ # than loading it yourself: this is a rotation of the world frame, so
121
+ # poses and `T_mocap_to_cam` must move together. One without the other
122
+ # shifts every projection by up to 165 px and raises nothing.
 
123
  if up_axis not in ("y", "z"):
124
+ raise ValueError(f"up_axis must be 'z' (as published) or 'y' (raw "
125
+ f"OptiTrack), got {up_axis!r}")
126
  self.up_axis = up_axis
127
 
128
  self.split = split
 
156
  """
157
  import shutil as _sh, tempfile as _tf
158
  from react_toolbox.calibration import load_calibration
159
+ from react_toolbox.frames import as_up_axis
160
  root = Path(calib_dir) if calib_dir else self.root
161
  if not (root / "calibration").is_dir():
162
  # The published release ships <task>/calibration/. A working tree
 
172
  raise FileNotFoundError(
173
  f"no gel calibration under {root}; the published release ships "
174
  f"it at <task>/calibration/. Pass calib_dir= or set REACT_CALIB.")
175
+ # Whatever tree got staged above may be in either convention, so
176
+ # CONVERT to the one this dataset is serving rather than assuming
177
+ # the source was Z-up. The staged epoch directory is Y-up.
178
+ return as_up_axis(cal, self.up_axis)
179
 
180
  def _convert_pose(self, arr):
181
+ # the published data is Z-up; "y" converts BACK to raw OptiTrack.
182
+ if self.up_axis == "z":
183
  return arr
184
  from react_toolbox.frames import convert_poses
185
+ return convert_poses(arr, to_zup=False)
186
 
187
  def _video_dir(self, ep_key):
188
  date, ep = ep_key.split("/")