import json from pathlib import Path MODALITY = { "action": { "left_joints": {"start": 0, "end": 6, "original_key": "action.joints"}, "right_joints": {"start": 6, "end": 12, "original_key": "action.joints"}, "left_gripper": {"start": 0, "end": 2, "original_key": "action.gripper"}, "right_gripper": {"start": 2, "end": 4, "original_key": "action.gripper"}, "base_delta": {"start": 0, "end": 3, "original_key": "action.base_delta"} }, "state": { "left_joints": {"start": 0, "end": 6, "original_key": "state.joints"}, "right_joints": {"start": 6, "end": 12, "original_key": "state.joints"}, "left_gripper": {"start": 0, "end": 2, "original_key": "state.gripper"}, "right_gripper": {"start": 2, "end": 4, "original_key": "state.gripper"}, "base": {"start": 0, "end": 3, "original_key": "state.base"} }, "video": { "cam_high": {"original_key": "video.top_camera_view"}, "cam_left_wrist": {"original_key": "video.left_camera_view"}, "cam_right_wrist": {"original_key": "video.right_camera_view"} }, "annotation": { "human.action.task_description": {"original_key": "task_index"} } } ROOT = Path("teleop_tasks") for task_dir in ROOT.iterdir(): if not task_dir.is_dir(): continue meta_dir = task_dir / "meta" meta_dir.mkdir(parents=True, exist_ok=True) out_file = meta_dir / "modality.json" with open(out_file, "w", encoding="utf-8") as f: json.dump(MODALITY, f, indent=4, ensure_ascii=False) print(f"✓ written: {out_file}") ROOT = Path("long_horizon") for task_dir in ROOT.iterdir(): if not task_dir.is_dir(): continue meta_dir = task_dir / "meta" meta_dir.mkdir(parents=True, exist_ok=True) out_file = meta_dir / "modality.json" with open(out_file, "w", encoding="utf-8") as f: json.dump(MODALITY, f, indent=4, ensure_ascii=False) print(f"✓ written: {out_file}") ROOT = Path("simple_pnp") for task_dir in ROOT.iterdir(): if not task_dir.is_dir(): continue meta_dir = task_dir / "meta" meta_dir.mkdir(parents=True, exist_ok=True) out_file = meta_dir / "modality.json" with open(out_file, "w", encoding="utf-8") as f: json.dump(MODALITY, f, indent=4, ensure_ascii=False) print(f"✓ written: {out_file}")