Multi-task video release: README + ReactVideoDataset loader
Browse files- README.md +1 -1
- 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
|
| 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="
|
| 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.
|
| 116 |
-
#
|
| 117 |
-
#
|
| 118 |
-
# horizontal coordinate.
|
| 119 |
#
|
| 120 |
-
#
|
| 121 |
-
#
|
| 122 |
-
#
|
| 123 |
-
#
|
| 124 |
-
# convention this dataset is in.
|
| 125 |
if up_axis not in ("y", "z"):
|
| 126 |
-
raise ValueError(f"up_axis must be '
|
|
|
|
| 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
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
def _convert_pose(self, arr):
|
| 179 |
-
|
|
|
|
| 180 |
return arr
|
| 181 |
from react_toolbox.frames import convert_poses
|
| 182 |
-
return convert_poses(arr,
|
| 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("/")
|