119 lines
4.3 KiB
Markdown

# Camera Recorder
This recorder uses YOLO pose tracking from a camera or video source, then writes:
- `DataG1/<take>.jsonl`: replay-compatible G1 dataset with 29 joints
- `RawPose/<take>.pose.jsonl`: raw 2D pose keypoints and diagnostics
- `Models/yolo11n-pose.pt`: local bundled YOLO pose model
- `camera_recorder_config.json`: recorder defaults, runtime settings, and file locations
- `joint.json`: robot joint counts, waist indices, and joint limits
- `pose_mapping.json`: camera pose-to-joint mapping rules and gains
The generated G1 dataset is designed to work with the existing replay scripts in this project. Lower body joints stay at `arm_home.jsonl`, and the upper body is estimated from the visible 2D pose.
## Record From Camera
```bash
cd /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder
python3 g1_camera_pose_recorder.py --source ask --output hands_up_cam
```
Recorder defaults also come from `camera_recorder_config.json`. Right now the default output is `test_take`, and the default home pose is the local `DataG1/arm_home.jsonl`, so you can simply run:
```bash
cd /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder
python3 g1_camera_pose_recorder.py
```
The recorder asks for an `Enter` confirmation before it starts writing files. Use `--no-prompt` to skip that.
You can also use explicit aliases like `--output-file` and `--home-file`.
By default, the recorder now looks for `Models/yolo11n-pose.pt` first.
All operational defaults are now loaded from `camera_recorder_config.json`. CLI flags still work, but they override the JSON values for that run only. The mapper-specific data is split into `joint.json` and `pose_mapping.json`, which are referenced from `camera_recorder_config.json`.
Use a different config file:
```bash
python3 g1_camera_pose_recorder.py --config /path/to/camera_recorder_config.json --source 0 --output test_take
```
Fixed camera index:
```bash
python3 g1_camera_pose_recorder.py --source 0 --output hands_up_cam
```
Record for a fixed duration:
```bash
python3 g1_camera_pose_recorder.py --source 0 --output hands_up_cam --seconds 12
```
Skip the start confirmation prompt:
```bash
python3 g1_camera_pose_recorder.py --no-prompt
```
Use a custom YOLO model or custom home pose:
```bash
python3 g1_camera_pose_recorder.py \
--source 0 \
--output wave_cam \
--model /home/zedx/Robotics_workspace/AI/YOLO/yolo11n-pose.pt \
--home-pose /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Manual_Recorder/DataG1/arm_home.jsonl
```
## Replay The Recorded Dataset
Because the file is saved under `Camera_Recorder/DataG1`, pass the full path to replay:
```bash
python3 /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder/g1_camera_pose_replay.py \
enp3s0 \
--input /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder/DataG1/hands_up_cam.jsonl \
--home arm_home.jsonl
```
`g1_camera_pose_replay.py` also reads replay defaults from `camera_recorder_config.json`, so from inside `Camera_Recorder` you can run:
```bash
python3 g1_camera_pose_replay.py
```
Replay scripts also accept explicit aliases like `--iface`, `--input-file`, and `--home-file`.
Safer camera-aware replay:
```bash
python3 /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder/g1_camera_pose_replay_v2.py \
enp3s0 \
--input /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder/DataG1/hands_up_cam.jsonl \
--home arm_home.jsonl \
--speed 0.35
```
`g1_camera_pose_replay_v2.py` also reads replay defaults from `camera_recorder_config.json`. Right now those defaults are:
- `iface = enp3s0`
- `input = test_take.jsonl`
- `home = arm_home.jsonl`
So you can run:
```bash
cd /home/zedx/Robotics_workspace/yslootahtech/G1_Lootah/Camera_Recorder
python3 g1_camera_pose_replay_v2.py
```
## Notes
- `q` or `Esc` stops recording.
- `Ctrl+C` cleanly cancels camera selection or the start prompt, and stops recording if it is already running.
- Any joint that is not captured in a frame falls back to the `arm_home.jsonl` pose for that joint.
- The mapping is heuristic because a single 2D camera cannot recover full 3D shoulder and wrist orientation.
- On this machine, the default `python3` does not currently have `ultralytics`; run the recorder in the same Python environment you already use for `/home/zedx/Robotics_workspace/AI/YOLO/YOLO_Test_3.py`.