File size: 8,703 Bytes
e7ca483
 
 
 
 
 
 
 
 
cc83ab5
e7ca483
 
 
 
 
 
 
cc83ab5
e7ca483
 
cc83ab5
 
 
e7ca483
 
 
 
cc83ab5
aca2e5f
e7ca483
 
 
cc83ab5
 
aca2e5f
cc83ab5
aca2e5f
 
cc83ab5
 
 
 
 
aca2e5f
 
 
cc83ab5
e7ca483
 
 
 
 
 
 
 
 
 
 
 
aca2e5f
 
cc83ab5
e7ca483
 
 
 
 
 
 
aca2e5f
 
 
 
 
 
 
 
10df2ce
10d7b67
 
aca2e5f
 
10df2ce
 
e7ca483
 
 
aca2e5f
 
 
 
e7ca483
10d7b67
10df2ce
e7ca483
 
aca2e5f
 
 
 
e7ca483
 
 
 
 
 
 
 
 
aca2e5f
 
 
 
 
 
cc83ab5
aca2e5f
10df2ce
aca2e5f
 
 
10d7b67
 
e7ca483
 
 
 
 
aca2e5f
 
10df2ce
10d7b67
 
aca2e5f
 
10df2ce
aca2e5f
cc83ab5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
license: apache-2.0
task_categories:
  - robotics
tags:
  - LeRobot
  - ur10
  - robotiq
  - tactile
  - depth
  - cluttered-grasping
  - imitation-learning
configs:
  - config_name: default
    data_files: data/*/*.parquet
---

# Cluttered Grasp (UR10 + Robotiq 2F-140 + tactile + depth)

Real-robot teleop demonstrations of cluttered grasping. Episodes are gated on
`gripper_tcp` height in `base_link` (record while low, pause while high), time-synced
to the RealSense **RGB master @ 30 Hz**, then converted to
[LeRobot](https://github.com/huggingface/lerobot) format.

| | |
|---|---|
| **Robot** | UR10 + Robotiq 2F-140 (`ur10_robotiq_2f140`) |
| **FPS** | **30** (RGB master timeline) |
| **Episodes / frames** | See `meta/info.json` (`total_episodes`, `total_frames`) |
| **Codebase** | LeRobot dataset v3.0 |
| **Task** | `cluttered grasping` |

## Sensors & resolutions

| Stream | Capture (ROS) | Dataset feature | Shape (H×W×C) | Notes |
|--------|---------------|-----------------|---------------|--------|
| Center RGB | RealSense color `1280×720@30` JPEG (`color/image_raw`) | `observation.images.center_cam` | **720×1280×3** | 16:9 color optical frame |
| Depth | RealSense depth module **`848×480@30` (W×H)**, **`/camera/camera/depth/image_rect_raw`****not** align-to-color | `observation.images.center_cam_depth` | **480×848×1** (uint16 mm, `video12`) | Unaligned native depth grid; **not** registered to RGB pixels |
| Tactile L | Fingertip cam JPEG (~90 Hz capture, hold-last to RGB) | `observation.images.tactile_L` | **240×320×3** | 4:3 |
| Tactile R | same | `observation.images.tactile_R` | **240×320×3** | 4:3 |

- **Master clock:** compressed RGB frames — one dataset row per RGB stamp (~30 Hz).
- **Sync:** nearest-neighbor within ~50 ms, then hold-last for depth/tactile/proprio.
- **Depth (logged & exported):** native D4xx depth at **848×480** from `depth/image_rect_raw` into bags → zarr `center_cam_depth` → LeRobot. Unit **millimetres** (uint16). **Not** the 1280×720 `aligned_depth_to_color` stream (that is used at runtime for ContactGraspNet only).
- **Depth vs RGB:** depth rows are time-synced to RGB but **not** pixel-aligned — fuse with extrinsics / reprojection, not naive `(u,v)` overlay on `center_cam`.
- Depth export for this dataset: **12-bit `gray12le` HEVC** (`video12`), log-quantized over **0.2–1.0 m**.

## Dataset structure

```text
cluttered_grasping/
├── meta/
│   ├── info.json          # schema, fps, totals, video codec info
│   ├── stats.json         # per-feature normalization stats
│   ├── tasks.parquet      # task prompts
│   └── episodes/          # per-episode metadata
├── data/
│   └── chunk-*/file-*.parquet   # state, action, indices
└── videos/
    ├── observation.images.center_cam/chunk-*/file-*.mp4        # AV1 1280×720 (W×H)
    ├── observation.images.center_cam_depth/chunk-*/file-*.mp4  # HEVC gray12le unaligned depth 848×480 (W×H)
    ├── observation.images.tactile_L/chunk-*/file-*.mp4         # AV1, 320×240
    └── observation.images.tactile_R/chunk-*/file-*.mp4
```

### Features (per frame)

| Key | Type | Shape | Description |
|-----|------|-------|-------------|
| `observation.state` | float32 | (8,) | `eef_x/y/z`, `eef_qx/qy/qz/qw` (xyzw), **measured** `gripper` at observation `t` |
| `action` | float32 | (7,) | `delta_x/y/z`, `delta_roll/pitch/yaw` (world, `t→t+1`) + gripper **mode** `{-1,0,+1}` at `t` (last frame dropped) |
| `observation.joint_state` | float32 | (7,) | `joint_0..5`, measured `gripper` at `t` (gripper redundant with `observation.state`) |
| `observation.joint_action` | float32 | (7,) | `joint_0..5` absolute at `t+1` + gripper mode at `t` (same mode as `action`) |
| `observation.gripper_setpoint` | float32 | (1,) | Absolute finger_joint command at `t` (under-the-hood; not the discrete action) |
| `observation.cgn_grasp_pose` | float32 | (7,) | Constant CGN TCP target in `base_link` (xyz + quat xyzw); broadcast every frame |
| `episode_state` | int64 | (1,) | Trajectory phase: `0` reach (home→CGN pose), `1` grasp_lift |
| `intervention` | int64 | (1,) | Sticky `1` after human teleop starts this episode (else `0`) |
| `grasp_state` | int64 | (1,) | Exclusive grasp phase at observation `t`: `0` no_contact, `1` contact, `2` closure, `3` lift, `4` success |
| `next.success` | float32 | (1,) | `1.0` on the **last exported frame** when terminal `grasp_state` is `success`; else `0` |
| `next.done` | float32 | (1,) | `1.0` on the **last exported frame** of every episode; else `0` |
| `observation.images.center_cam` | video (AV1) | 720×1280×3 | Scene RealSense RGB (1280×720 capture) |
| `observation.images.center_cam_depth` | video (HEVC gray12le) | 480×848×1 | Unaligned native depth **848×480** capture (H×W×C storage); mm; `is_depth_map` |
| `observation.images.tactile_L` | video (AV1) | 240×320×3 | Left fingertip tactile (`/tactile1`) |
| `observation.images.tactile_R` | video (AV1) | 240×320×3 | Right fingertip tactile (`/tactile2`) |
| `timestamp` | float32 | (1,) | Time within episode (s) |
| `frame_index` / `episode_index` / `index` / `task_index` | int64 | (1,) | LeRobot indices |

`observation.state` EE pose is `gripper_tcp` in `base_link`.  
`action` pose delta: `delta_xyz = pos[t+1]-pos[t]`; `delta_rpy = euler_xyz(R[t+1] @ R[t].T)` (world/fixed-frame).  
Gripper on both action channels is discrete **mode** (`-1` open, `0` hold, `+1` close), not absolute position. Under the hood teleop/CGN ramp a setpoint (logged in zarr as `gripper_setpoint`) with the same controller.  
Wrist force/torque is **not** exported to LeRobot (still present in upstream zarr if needed).

**Label example:** terminal phases `… success, success``next.done = 1` on the last exported frame; `next.success = 1` on that frame too. Failed episodes still get `next.done = 1` on the last frame; `next.success = 0`.

### Episode definition

- **Start:** `cgn_teleop_trial` accepts a grasp preview and calls `begin_episode` (bag warm-up at home, then approach).
- **End:** EE reaches lift handoff (`LIFT_Z` for teleop, or after auto lift); `end_episode` then place/home are **not** recorded.
- No recording between trials.
- Fully automated vs human: check `intervention` max / zarr attr `intervention_used`.

## Load

```python
from lerobot.datasets.lerobot_dataset import LeRobotDataset

ds = LeRobotDataset("benudavis/cluttered_grasp")
print(ds)
frame = ds[0]
# EE state / action:
#   frame["observation.state"]         # (8,) eef xyz+quat + gripper
#   frame["action"]                   # (7,) delta_xyz + delta_rpy + abs gripper next
#   frame["observation.joint_state"]  # (7,) joints + gripper
#   frame["observation.joint_action"] # (7,) next joints + gripper
#   frame["observation.cgn_grasp_pose"]  # (7,) constant CGN target
# RGB / tactile: frame["observation.images.center_cam"], ...
# Depth: frame["observation.images.center_cam_depth"]  # 480×848×1 mm, unaligned 848×480 capture
# Phases / returns:
#   frame["episode_state"]    # 0 reach / 1 grasp_lift
#   frame["intervention"]     # 1 if teleop used
#   frame["grasp_state"]      # int64 phase id (contact labels)
#   frame["next.success"]     # 1.0 on last exported frame if episode ends in success
#   frame["next.done"]        # 1.0 on last exported frame (every episode)
```

## Collection / conversion notes

- ROS bags → one zarr episode per bag (`bag2dataset` under `~/venvs/clutter`, zarr≥3).
- Episodes are service-gated by `cgn_teleop_trial` (begin after preview Enter with warm-up; end at lift handoff).
- Offline rebuild: `scripts/zarr_to_lerobot.py --fps 30 --depth-mode video12` over `~/EDG_Experiment/clutter/**/*.zarr` (skips `clutter/old/`).
- Phase labels: `scripts/label_grasp_states.py` (Streamlit) writes `data/obs/policy/grasp_state` and, on **Save** / **Save all**, derived `next_success` / `next_done` on each episode zarr.
- Converter sets `next.done` / `next.success` with the same terminal-frame rules as
  the labeler (last frame; success from terminal `grasp_state`).
- Trial stats: `python scripts/plot_trial_outcomes.py --zarr-root … --out …` (or `zarr_to_lerobot.py --trial-stats-out …`).
- Bag convert also skips leading frames with empty tactile / NaN policy before writing zarr.
- Auto-label may set contact/success from tactile blob area; only terminal success runs (touching episode end) stay `success`.
- Actions: EE delta pose + absolute next gripper; joint absolute next (see `scripts/lerobot_convert/actions.py`).
- Upload: `scripts/upload_lerobot_hf.py` (copies this card to the dataset root as `README.md`).