File size: 5,132 Bytes
b62ef52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
task_categories:
  - robotics
tags:
  - behavior-cloning
  - diffusion-policy
  - pusht
  - bimodal
  - mode-editing
size_categories:
  - n<1K
---

# Push-T Controlled Bimodal Teleop Dataset

100 human-teleoperated Push-T demonstrations (50 LEFT-wrap + 50 RIGHT-wrap), collected
under a **controlled fixed initial state** so the two modes have kinematically equivalent
costs. Intended for downstream bimodal behavior-cloning and mode-editing experiments.

All demos reach `coverage >= 0.95` shapely-IoU success threshold (env-defined). Demos
were collected at 10 Hz mouse-driven teleop on the 2D pygame Push-T env from the
Diffusion Policy paper (Chi et al., RSS 2023).

## What "LEFT" vs "RIGHT" means

T starts at lower-left `(185, 327, π/4)` and must translate up-right to the green goal
silhouette at `(256, 256, π/4)`. The agent (blue circle) spawns upper-right of the T
at `(327, 185) ± 15 px`. Two equal-cost wrap paths exist:

- **LEFT** — agent wraps the **upper-left** side of the T (counter-clockwise about T's center)
- **RIGHT** — agent wraps the **lower-right** side of the T (clockwise about T's center)

Modes alternate by seed parity: even seed → LEFT, odd seed → RIGHT.

![Trajectory overlay](pusht_controlled_mixed_paths.png)

## Files

| File | Purpose |
|------|---------|
| `pusht_controlled_mixed.zarr/` | The dataset (zarr v2 directory store, 100 episodes / 8060 steps) |
| `pusht_controlled_mixed_paths.png` | All 100 agent paths, split by mode (visual sanity check) |
| `demo_pusht.py` | The patched collection script used to generate this dataset |

## Zarr layout

```
pusht_controlled_mixed.zarr/
├── data/                                  # 8060 timesteps total, 10 Hz
│   ├── state        (8060, 5)  float32    # [agent_x, agent_y, T_x, T_y, T_angle]
│   ├── action       (8060, 2)  float32    # teleop mouse-target action
│   ├── img          (8060, 96, 96, 3) uint8   # 96×96 RGB env render
│   ├── keypoint     (8060, 9, 2)  float32     # 9 T-block keypoints
│   └── n_contacts   (8060, 1)  float32
└── meta/                                  # 100 episodes
    ├── episode_ends       (100,) int64    # cumulative end-indices (DP standard)
    ├── episode_modes      (100,) int8     # 0 = LEFT, 1 = RIGHT  ← extra
    └── episode_coverages  (100,) float32  # final IoU coverage    ← extra
```

The `data/*` arrays and `meta/episode_ends` follow the **same layout** as the canonical
`pusht_cchi_v7_replay.zarr` from the DP repo. The two extra `meta/*` arrays are
additions for mode-editing work; the original DP training code ignores them.

## Loading

```python
import zarr, numpy as np
from huggingface_hub import snapshot_download

local_dir = snapshot_download(
    repo_id='haohw/pusht-controlled-mixed',
    repo_type='dataset',
)
r = zarr.open(f'{local_dir}/pusht_controlled_mixed.zarr', mode='r')

ends   = np.asarray(r['meta/episode_ends'])
modes  = np.asarray(r['meta/episode_modes'])    # 0=LEFT, 1=RIGHT
covs   = np.asarray(r['meta/episode_coverages'])
state  = np.asarray(r['data/state'])
action = np.asarray(r['data/action'])

# Per-episode iteration
starts = np.concatenate([[0], ends[:-1]])
for s, e, m in zip(starts, ends, modes):
    ep_state  = state[s:e]
    ep_action = action[s:e]
    mode_name = 'LEFT' if m == 0 else 'RIGHT'
    ...
```

For fast pulls on a cluster, set `HF_HUB_ENABLE_HF_TRANSFER=1` and install `hf_transfer`.

## Splitting into per-mode zarrs

If downstream code expects two single-mode zarr files
(`pusht_controlled_left.zarr` + `pusht_controlled_right.zarr`), the split is just a
filter on `meta/episode_modes`. The original DP collection guide's two-file format
can be reconstructed from this single mixed file at training time.

## Collection spec

**Env**: `PushTKeypointsEnv` from `diffusion_policy.env.pusht.pusht_keypoints_env`,
render_size=96, control_hz=10.

**Per-episode init** (overrides env's random init via `env.reset_to_state`):

| Object | Position | Angle |
|--------|----------|-------|
| T block | fixed `(185, 327)` | fixed `π/4` |
| Goal   | fixed `(256, 256)` (env default) | fixed `π/4` |
| Agent  | `(327, 185) + uniform(-15, +15)` (seeded by episode index) | — |

**Success**: shapely-IoU between current T polygon and goal T polygon `>= 0.95`.
DP paper reports continuous max-coverage per episode (clipped at 0.95), not binary
success rate — so 95% is the env's done flag, not the eval metric.

## Episode-length stats

Mean 80.6 steps (≈8.1 s @ 10 Hz), median 78, min 60, max 141.

## Reproducing

See `demo_pusht.py`. Key changes from the stock DP script:

1. Controlled init via `env.reset_to_state` (T fixed, agent perturbed ±15 px)
2. Mode auto-assigned by seed parity, displayed in-window (red/blue overlay + IoU bar)
3. Extra `meta/episode_modes` and `meta/episode_coverages` saved per episode
4. `S` key to save partial demos before 95%, `C` key to cancel and restart same seed

## License

MIT. Re-uses geometry / env from
[real-stanford/diffusion_policy](https://github.com/real-stanford/diffusion_policy).