File size: 2,218 Bytes
0d4f91f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a4e2cc4
 
 
 
 
 
 
0d4f91f
 
 
 
 
 
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
#!/usr/bin/env python3
"""Verify the full online GWAM final graph path on a live RoboCasa env."""
from __future__ import annotations

import argparse
import json
import subprocess
import sys
import tempfile
from pathlib import Path


def main() -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument('--package-root', type=Path, default=Path(__file__).resolve().parents[1])
    ap.add_argument('--task', default='OpenDrawer')
    ap.add_argument('--robots', default='PandaOmron')
    ap.add_argument('--device', default='cuda')
    ap.add_argument('--visual-backend', choices=['sam2', 'fake'], default='sam2')
    args = ap.parse_args()
    example = args.package_root / 'examples/realtime_env_graph_eval_loop.py'
    with tempfile.TemporaryDirectory(prefix='gwam-final-graph-verify-') as td:
        out = Path(td) / 'summary.json'
        cmd = [
            sys.executable,
            str(example),
            '--task', args.task,
            '--robots', args.robots,
            '--steps', '1',
            '--visual-backend', args.visual_backend,
            '--device', args.device,
            '--json-output', str(out),
        ]
        subprocess.run(cmd, check=True)
        data = json.loads(out.read_text())
        row = data['summaries'][0]
        assert row['final_graph'] is True, row
        assert row['N_real'] > 1, row
        assert row['D_node'] == 342, row
        assert row['D_edge'] == 8, row
        assert row['first_slots'][0] == 0, row
        assert row['visual_features_written'] >= 0, row
        assert row['invalid_visible_pairs'] >= 0, row
        # Example summaries expose the underlying snapshot['rgb_frames'] and
        # snapshot['rgb_frame_cameras'] alignment contract as these JSON fields.
        assert row['rgb_view_count'] == 3, row
        assert row['rgb_aligned_with_view_ids'] is True, row
        assert row['rgb_cameras'] == ['robot0_agentview_right', 'robot0_agentview_left', 'robot0_eye_in_hand'], row
        for shape in row['rgb_shapes'].values():
            assert shape == [256, 256, 3], row
        print('verify_realtime_final_graph_ok', json.dumps(row, sort_keys=True))
    return 0


if __name__ == '__main__':
    raise SystemExit(main())