# data_recording_stuff

Record synchronized camera + calibrated servo states for a task.

```
cd ~/Projects/robotics_testing/claude_feetech_controller/data_recording_stuff
/opt/homebrew/bin/python3.11 record.py <task_name> --config gripper
```

Camera defaults to index 0 (the Continuity Camera). Torque is disabled so you can
back-drive/teleoperate while recording. Stop with `q` in the preview window or Ctrl-C.

## Output — `datasets/<task_name>/`
- `frames/000000.jpg` … — one image per tick (`--png` for lossless)
- `states/000000.npy` … — `float32` array of **calibrated joint radians**, one row per
  frame, paired by index with the frame of the same number. Columns are listed in
  `meta.json` (`state_columns`, ordered by servo id).
- `timestamps.npy` — `(N,)` wall-clock time per frame
- `meta.json` — config, servo ids, joint names, signs, fps, frame count, duration

## Load a dataset
```python
import json, glob, numpy as np, cv2
d = "datasets/my_task"
meta = json.load(open(f"{d}/meta.json"))
states = np.stack([np.load(p) for p in sorted(glob.glob(f"{d}/states/*.npy"))])   # (N, n_servos)
frames = sorted(glob.glob(f"{d}/frames/*"))                                        # paths, index-aligned
img0 = cv2.imread(frames[0])
```

Flags: `--camera N`, `--fps F`, `--png`, `--no-preview`, `--overwrite`, `--port /dev/tty...`.
