From a2faa1a77405720079960652e2a74cdd1764eda4 Mon Sep 17 00:00:00 2001 From: liyang <836021389@qq.com> Date: Tue, 27 Oct 2026 15:06:01 +0800 Subject: [PATCH] Fix portable paths, optional dependencies and project documentation --- .gitignore | 4 ++ README.md | 6 +-- assets/hand_adapter/cad_measurements.json | 7 +-- assets/l20_left_mj.urdf | 2 +- assets/l20_right_mj.urdf | 2 +- assets/retarget/l20_left_scene_with_tips.urdf | 2 +- config/l20_left_scene_position.yml | 2 +- config/local.env.example | 5 ++ config/measured_layout.json | 11 +++-- data/cup_model_20260928/cup_model.json | 2 +- .../grasp_l20_cup_0.json | 2 +- .../grasp_l20_cup_1.json | 2 +- .../grasp_l20_cup_2.json | 2 +- data/cup_workcell/escape_report.json | 2 +- docs/INSTALL.md | 47 +++++++++++++++++++ docs/cup_workcell.md | 2 +- docs/elbow_trajectory_supervisor.md | 2 +- docs/left_hand_fist_restore.md | 4 +- docs/real_grasp_deploy.md | 8 ++-- docs/table_contact_escape.md | 4 +- requirements-cad.txt | 2 + requirements-camera.txt | 2 + requirements-controller.txt | 3 ++ requirements-demo.txt | 5 ++ requirements-geometry.txt | 2 + requirements-retarget.txt | 5 ++ scene/build_measured_layout.py | 4 +- scene/build_real_assembly.py | 4 +- scene/build_scene.py | 7 ++- scene/cup_workcell.json | 27 ++++++----- scene/measured_layout.json | 23 ++++----- scene/real_assembly.json | 8 ++-- scripts/audit_adapter_geometry.py | 2 +- scripts/audit_cup_coordinates.py | 5 +- scripts/check_index_board_hover.py | 3 +- scripts/g20_left_lookup.py | 3 +- scripts/hand_mapper.py | 3 +- scripts/hug_infer_point.py | 9 ++-- scripts/hug_to_l20.py | 15 ++++-- scripts/inspect_hand_adapter.py | 3 +- scripts/joint_follow_adapter.py | 3 +- scripts/live_demo.py | 9 ++-- scripts/measure_workcell_cup.py | 2 +- scripts/plan_workcell_escape.py | 2 +- scripts/prepare_snapshot.py | 21 ++++----- scripts/project_paths.py | 10 ++++ scripts/real_grasp.py | 5 +- scripts/real_grasp_manual.py | 7 +-- scripts/real_raise.py | 4 +- scripts/run_pipeline.sh | 38 ++++++++------- scripts/test_real_assembly.py | 2 +- scripts/verify_saved_cup_offline.py | 2 +- 52 files changed, 231 insertions(+), 127 deletions(-) create mode 100644 config/local.env.example create mode 100644 docs/INSTALL.md create mode 100644 requirements-cad.txt create mode 100644 requirements-camera.txt create mode 100644 requirements-controller.txt create mode 100644 requirements-demo.txt create mode 100644 requirements-geometry.txt create mode 100644 requirements-retarget.txt create mode 100644 scripts/project_paths.py diff --git a/.gitignore b/.gitignore index dfbba72..0c2aecf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ __pycache__/ out/ *.mp4 backup/ + +external/ +.retarget/ +config/local.env diff --git a/README.md b/README.md index 6ea741f..2eb7666 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## 快速查看 -Python 3.12 + venv(不使用conda): +Python 3.12 + venv: ```bash python3.12 -m venv .venv @@ -14,7 +14,7 @@ python3 scripts/prepare_snapshot.py .venv/bin/python scripts/view_cup_approach.py --middle --dynamic ``` -需要桌面显示环境;鼠标自由转动,空格暂停,R重播。第一条查看接近路径,第二条查看最新动力学试抓。场景主文件 `scene/cup_workcell.xml`,试抓场景 `data/cup_middle_search/dynamic_scene.xml`。几何文件已随仓库打包,路径为相对路径;prepare_snapshot仅重定位记录中的本地项目路径。 +需要桌面显示环境;鼠标自由转动,空格暂停,R重播。第一条查看接近路径,第二条查看最新动力学试抓。场景主文件 `scene/cup_workcell.xml`,试抓场景 `data/cup_middle_search/dynamic_scene.xml`。prepare_snapshot 检查必要模型资源。 ## 当前流程 @@ -25,7 +25,7 @@ D405 RGB-D → 杯子尺寸/位置 → 仿真相机 → 杯子感知 → HUG候 CUP_TRIAL_DIR=data/cup_middle_search .venv/bin/python scripts/test_cup_dynamic_grasp.py ``` -搜索复用已保存的HUG候选,无需模型权重。完整重新生成HUG候选另外需要HUG及其权重、MANO授权资产;重定向需要dex-retargeting/Pinocchio以及 `~/do-as-i-do/retargeting/l20/retarget_l20_v2.py`。这些环境/权重未包含,也不影响已保存场景回放及中段搜索。D405采集另需pyrealsense2和相机。历史脚本保留供参考,不代表全部外部依赖都已打包。 +搜索复用已保存的HUG候选,无需模型权重。完整重新生成HUG候选另外需要HUG及其权重、MANO授权资产;重定向需要dex-retargeting/Pinocchio以及 `retarget_l20_v2.py`。这些环境/权重未包含,也不影响已保存场景回放及中段搜索。D405采集另需pyrealsense2和相机。可选工具的安装与配置见 [环境配置](docs/INSTALL.md)。 ## 场景与当前结果 diff --git a/assets/hand_adapter/cad_measurements.json b/assets/hand_adapter/cad_measurements.json index fee2cf5..45815c4 100644 --- a/assets/hand_adapter/cad_measurements.json +++ b/assets/hand_adapter/cad_measurements.json @@ -1,5 +1,5 @@ { - "source": "/home/timessage/\u6587\u6863/A7V2-L20\u94fe\u63a5\u6cd5\u5170 .STEP", + "source": "A7V2-L20链接法兰 .STEP", "bbox_mm": [ -30.0000001, -30.0000001, @@ -1639,5 +1639,6 @@ } ], "mesh_units": "m", - "assembly_transform_verified": false -} \ No newline at end of file + "assembly_transform_verified": false, + "historical_external_sources": "Photo/STEP names are provenance only; original external files are not bundled." +} diff --git a/assets/l20_left_mj.urdf b/assets/l20_left_mj.urdf index f480f15..51aba88 100644 --- a/assets/l20_left_mj.urdf +++ b/assets/l20_left_mj.urdf @@ -6,7 +6,7 @@ name="linkerhand_g20_left.urdf"> - + diff --git a/assets/l20_right_mj.urdf b/assets/l20_right_mj.urdf index fe2484f..9db8de7 100644 --- a/assets/l20_right_mj.urdf +++ b/assets/l20_right_mj.urdf @@ -6,7 +6,7 @@ name="linkerhand_L25NS_right.urdf"> - + diff --git a/assets/retarget/l20_left_scene_with_tips.urdf b/assets/retarget/l20_left_scene_with_tips.urdf index b25c9ce..d680075 100644 --- a/assets/retarget/l20_left_scene_with_tips.urdf +++ b/assets/retarget/l20_left_scene_with_tips.urdf @@ -1,6 +1,6 @@ - + diff --git a/config/l20_left_scene_position.yml b/config/l20_left_scene_position.yml index cd678bf..930e99a 100644 --- a/config/l20_left_scene_position.yml +++ b/config/l20_left_scene_position.yml @@ -1,6 +1,6 @@ retargeting: type: position - urdf_path: /home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/assets/retarget/l20_left_scene_with_tips.urdf + urdf_path: assets/retarget/l20_left_scene_with_tips.urdf target_joint_names: - thumb_cmc_yaw - thumb_cmc_roll diff --git a/config/local.env.example b/config/local.env.example new file mode 100644 index 0000000..06cd850 --- /dev/null +++ b/config/local.env.example @@ -0,0 +1,5 @@ +# Copy to local.env, edit and source before using optional tools. +# export HUG_ROOT="external/hug" +# export RETARGETING_ROOT="external/retargeting" +# export RETARGET_PYTHON=".retarget/bin/python" +# export A7_SDK_LIBRARY="external/a7_sdk/liblbot_api_cpp.so.1.0.5" diff --git a/config/measured_layout.json b/config/measured_layout.json index a1288c8..fa9acc3 100644 --- a/config/measured_layout.json +++ b/config/measured_layout.json @@ -26,10 +26,10 @@ "table_near": "User measured column front face to desk near edge: 0.205m. Corrected column depth 0.09m gives near x=0.09/2+0.205=0.25m. Assumes desk edge parallel to column front.", "unmeasured": "Desk width/depth, caster/deck height, exact column center relative to CAD base and desk yaw are display estimates. Deck center is 8cm forward of column to reproduce its visible extension underneath desk; desk yaw zero.", "photos": [ - "/home/timessage/图片/a7/IMG20260928115533.jpg", - "/home/timessage/图片/a7/IMG20260928115542.jpg", - "/home/timessage/图片/a7/IMG20260928115548.jpg", - "/home/timessage/图片/a7/IMG20260928115553.jpg" + "IMG20260928115533.jpg", + "IMG20260928115542.jpg", + "IMG20260928115548.jpg", + "IMG20260928115553.jpg" ], "assembly": "Preserve scene/real_assembly.xml bodies, hand adapter transform and keyframes exactly; only translate the assembly to floor coordinates. No hardware actions." }, @@ -39,5 +39,6 @@ "clearance_m": 0.0, "note": "Fit freshly subscribed arm pose to nominal desktop contact. Finger angles remain model zero, not measured. Pure offline display alignment." }, - "snapshot_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json" + "snapshot_file": "data/layout_joint_read_20260928T052840Z/arm_snapshot.json", + "historical_external_sources": "Photo/STEP names are provenance only; original external files are not bundled." } diff --git a/data/cup_model_20260928/cup_model.json b/data/cup_model_20260928/cup_model.json index b10608f..07f8f13 100644 --- a/data/cup_model_20260928/cup_model.json +++ b/data/cup_model_20260928/cup_model.json @@ -99,5 +99,5 @@ "dimension_uncertainty": "not independently quantified; residual is NOT absolute accuracy", "table_margin_m": 0.005, "physical_execution_authorized": false, - "position_capture": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/cup_moved_capture_20260928" + "position_capture": "data/cup_moved_capture_20260928" } \ No newline at end of file diff --git a/data/cup_sim_capture_20260928/grasp_l20_cup_0.json b/data/cup_sim_capture_20260928/grasp_l20_cup_0.json index eab68df..cea5cb3 100644 --- a/data/cup_sim_capture_20260928/grasp_l20_cup_0.json +++ b/data/cup_sim_capture_20260928/grasp_l20_cup_0.json @@ -3,7 +3,7 @@ "source": "data/cup_sim_capture_20260928/hug_cup.npz", "hand_side": "left", "human_landmarks_mirrored": true, - "retarget_config": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/config/l20_left_scene_position.yml", + "retarget_config": "config/l20_left_scene_position.yml", "sample": 5, "wrist_pos": [ 0.25767, diff --git a/data/cup_sim_capture_20260928/grasp_l20_cup_1.json b/data/cup_sim_capture_20260928/grasp_l20_cup_1.json index cf9c7c4..808cd50 100644 --- a/data/cup_sim_capture_20260928/grasp_l20_cup_1.json +++ b/data/cup_sim_capture_20260928/grasp_l20_cup_1.json @@ -3,7 +3,7 @@ "source": "data/cup_sim_capture_20260928/hug_cup.npz", "hand_side": "left", "human_landmarks_mirrored": true, - "retarget_config": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/config/l20_left_scene_position.yml", + "retarget_config": "config/l20_left_scene_position.yml", "sample": 4, "wrist_pos": [ 0.25392, diff --git a/data/cup_sim_capture_20260928/grasp_l20_cup_2.json b/data/cup_sim_capture_20260928/grasp_l20_cup_2.json index bf5dea6..0eb9131 100644 --- a/data/cup_sim_capture_20260928/grasp_l20_cup_2.json +++ b/data/cup_sim_capture_20260928/grasp_l20_cup_2.json @@ -3,7 +3,7 @@ "source": "data/cup_sim_capture_20260928/hug_cup.npz", "hand_side": "left", "human_landmarks_mirrored": true, - "retarget_config": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/config/l20_left_scene_position.yml", + "retarget_config": "config/l20_left_scene_position.yml", "sample": 6, "wrist_pos": [ 0.26474, diff --git a/data/cup_workcell/escape_report.json b/data/cup_workcell/escape_report.json index 186bcc1..18fd7bd 100644 --- a/data/cup_workcell/escape_report.json +++ b/data/cup_workcell/escape_report.json @@ -118,7 +118,7 @@ "margin_m": 0.005, "executable_on_hardware": false, "scope": "continuous finite-table checks for fixed nominal hand; no self/cup/other-arm validation", - "snapshot": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json", + "snapshot": "data/layout_joint_read_20260928T052840Z/arm_snapshot.json", "table_top_base_m": -0.29512236765524225, "table_evidence": "simulation dimensions only" } \ No newline at end of file diff --git a/docs/INSTALL.md b/docs/INSTALL.md new file mode 100644 index 0000000..acf4085 --- /dev/null +++ b/docs/INSTALL.md @@ -0,0 +1,47 @@ +# 环境配置 + +主场景回放与杯身中段搜索使用 Python 3.12 + venv: + +~~~bash +python3.12 -m venv .venv +.venv/bin/python -m pip install -r requirements-sim.txt +.venv/bin/python scripts/prepare_snapshot.py +~~~ + +Ubuntu 系统组件:python3.12-venv、libgl1、libegl1、libglfw3。图形回放需要桌面显示;无头模型检查使用 MUJOCO_GL=egl。 + +## 可选工具 + +| 用途 | 安装 | +| --- | --- | +| 网格检查、几何构建 | .venv/bin/python -m pip install -r requirements-geometry.txt | +| D405 采集 | .venv/bin/python -m pip install -r requirements-camera.txt | +| 旧 mink 抓取演示 | .venv/bin/python -m pip install -r requirements-demo.txt | +| STEP 转网格 | .venv/bin/python -m pip install -r requirements-cad.txt | +| 历史控制器/手部工具 | .venv/bin/python -m pip install -r requirements-controller.txt | + +旧演示依赖已固定版本;CAD 依赖按上游解析,尚未完成各可选环境的全新安装验证;历史硬件工具不属于默认仿真流程,不应为环境检查而运行。 + +HUG 推理使用其自身兼容 venv、源码与 hug_full.safetensors;MANO 按提供方条件取得。重定向可单独创建 Python 3.12 的 .retarget 环境,安装 requirements-retarget.txt,并准备 retarget_l20_v2.py 及其配置。回放现有候选无需这些工具。 + +## 可选资源配置 + +在运行相关入口前 export 对应变量;Python 工具的相对配置以仓库根目录为基准。config/local.env.example 提供示例。 + +| 变量 | 默认位置/用途 | +| --- | --- | +| HUG_ROOT | external/hug;HUG 源码 | +| HUG_PYTHON | HUG_ROOT/.venv/bin/python | +| HUG_CHECKPOINT | HUG_ROOT/checkpoints/hug_full.safetensors | +| RETARGET_PYTHON | .retarget/bin/python | +| RETARGETING_ROOT | external/retargeting,需含 l20/retarget_l20_v2.py 和 config/l20 | +| LINKERHAND_SDK_ROOT | external/linkerhand-python-sdk;仅历史映射工具使用 | +| P7_SCENE_XML | external/p7_bimanual/model.xml;旧场景构建器使用,旁边需有 meta.json,可由 wasm-bimanual-grasp 的 P7 场景提供 | +| G20_LEFT_TABLE | assets/L20/LEFT/g20_left_G20.json;当前设备标定,不可直接套用其他设备 | +| CALIBRATED_LEFT_URDF | external/calibrated_left/linkerhand_g20_left.urdf;离线标定诊断专用,需相邻网格,缺失时不替换成未标定模型 | +| REFERENCE_LEFT_URDF | external/reference/l20_left_with_tips.urdf;独立坐标对比基准 | +| HAND_ADAPTER_STEP | external/hand_adapter.STEP;重新测量法兰时使用 | +| A7_SDK_LIBRARY | external/a7_sdk/liblbot_api_cpp.so.1.0.5;可选厂家库 | +| A7_BRIDGE_SETUP | 现场 ROS 桥的 setup.bash;仅相关历史硬件工具使用 | + +外部源码、权重、参考标定模型和 SDK 需另外提供。修改路径不会改变模型物理参数或控制保护。 diff --git a/docs/cup_workcell.md b/docs/cup_workcell.md index 735c380..3961bd7 100644 --- a/docs/cup_workcell.md +++ b/docs/cup_workcell.md @@ -20,7 +20,7 @@ 2026-09-28 坐标/安装核验:控制器快照与模型 FK 左右臂位置差 <0.002mm,安装矩阵与已确认配置一致(矩阵最大差 8.2e-7);HUG 相机到世界变换数值一致。这些是软件一致性检查,不代表真实标定精度。发现旧重定向 left URDF 与实际 LEFT 装配的手指侧向/轴方向镜像不一致;新增 assets/retarget/l20_left_scene_with_tips.urdf、config/l20_left_scene_position.yml 与实际模型一致。HUG MANO 默认 right,需显式 --mirror-human-hand 生成左手候选;转换后指尖拟合误差8.7–9.6mm。原装配/法兰安装未改。修正后3候选×8种子仍未找到预抓取IK,未进入路径碰撞检查,不能归因为桌面碰撞,也未完成抓取。报告 data/cup_coordinate_audit_20260928/report.json。 -重定向复现:`PYTHONPATH= LD_LIBRARY_PATH= /home/timessage/linkerhand-python-sdk/.venv/bin/python scripts/hug_to_l20.py --npz data/cup_sim_capture_20260928/hug_cup.npz --side left --top 3 --table-top .755 --config config/l20_left_scene_position.yml --mirror-human-hand`。仅离线候选验证,原真机 RealArm 安装参数未迁移,不能直接执行。 +重定向复现:`PYTHONPATH= LD_LIBRARY_PATH= $RETARGET_PYTHON scripts/hug_to_l20.py --npz data/cup_sim_capture_20260928/hug_cup.npz --side left --top 3 --table-top .755 --config config/l20_left_scene_position.yml --mirror-human-hand`。仅离线候选验证,原真机 RealArm 安装参数未迁移,不能直接执行。 抓取方向调整:scripts/search_cup_approach.py 搜索103种姿态,找到相对原候选 yaw=-90°、倾角=-60°、高度不变的可达解。接近前段桌面采样最小间隙8.845mm;scripts/check_cup_final_approach.py 验证末段70个笛卡尔点,终点桌面间隙15.193mm、手杯距离2.936mm。保存 data/cup_approach_search/{selected.json,approach_qpos.npy,approach_report.json}。只证明采样几何路径;末段允许接近杯子至接触,桌板仍保留5mm。 diff --git a/docs/elbow_trajectory_supervisor.md b/docs/elbow_trajectory_supervisor.md index b9883c1..0827abf 100644 --- a/docs/elbow_trajectory_supervisor.md +++ b/docs/elbow_trajectory_supervisor.md @@ -48,7 +48,7 @@ ArmState反馈映射、固定轨迹引用检查、50~200Hz时间间隔检查 ## 运行模拟 ```bash -/home/timessage/a7l20-hug-sim/.venv/bin/python /home/timessage/a7l20-hug-sim/scripts/demo_elbow_supervisor.py +.venv/bin/python scripts/demo_elbow_supervisor.py ``` 追加`--fault feedback-timeout`或`--fault stop-timeout`注入故障。 diff --git a/docs/left_hand_fist_restore.md b/docs/left_hand_fist_restore.md index 6370b61..a3d3dbc 100644 --- a/docs/left_hand_fist_restore.md +++ b/docs/left_hand_fist_restore.md @@ -1,7 +1,7 @@ # 左手握合与恢复:JSON查表和诊断日志 入口:`scripts/left_hand_fist_restore.py`,使用 -`/home/timessage/linkerhand-python-sdk/.venv/bin/python`。 +`$RETARGET_PYTHON`。 默认仅离线加载标定表,`--execute`才打开can0并控制左手0x28。 不连接机械臂,不写使能、速度、扭矩或工厂校准设置。 @@ -12,7 +12,7 @@ ## 标定表 -默认 `/home/timessage/Linkerbot_URDF/L20/LEFT/g20_left_G20.json`。 +默认 `assets/L20/LEFT/g20_left_G20.json`。 要求schema v4、LEFT G20、16主动+5被动关节、每关节256点。 指令和反馈角度均按angle_rad原表查找,不用SDK线性范围替代。 角度反查采用最接近的实测点;越界请求直接拒绝。zero_angles偏置不重复叠加。 diff --git a/docs/real_grasp_deploy.md b/docs/real_grasp_deploy.md index be38723..f6ff6a2 100644 --- a/docs/real_grasp_deploy.md +++ b/docs/real_grasp_deploy.md @@ -27,8 +27,8 @@ | 相机 | Intel RealSense **D405**,USB 接本机(`8086:0b5b`);固定在躯干,**标定后别再动** | | 控制器 | `192.168.10.21`,官方 web 控制平台 `http://192.168.10.21:8000/`(灵心巧手平台)| | 通信 | **rosbridge `ws://192.168.10.21:9090`**(本机不在控制器 ROS 网络内,走 websocket)| -| 本机 venv | `~/a7l20-hug-sim/.venv`(py3.12):mujoco/scipy/trimesh/cv2 + **pyrealsense2**、**roslibpy**(已装)| -| HUG venv | `~/hug/.venv`(py3.10);重定向 venv `~/linkerhand-python-sdk/.venv` | +| 本机 venv | `.venv`(py3.12):mujoco/scipy/trimesh/cv2 + **pyrealsense2**、**roslibpy**(已装)| +| HUG venv | `$HUG_PYTHON`(py3.10);重定向 venv `$RETARGET_PYTHON` | | ⚠ 安全拦截 | **Claude Code 安全分类器会拦"控制真机的命令"**,所有真机运动/桥接命令**由人在终端外部运行**(`!` 或自己终端)| --- @@ -148,7 +148,7 @@ - `view_pointcloud.py` 点云可视化 **仍待打通(装手后)** -- **L20 合指映射**:`hand_qpos`(16关节弧度) → `L20Hand{finger,cmd}`(逐指、cmd 量纲待定 0~255?/角度?)——接 `~/linkerhand-python-sdk`。`real_arm.set_hand` 已留接口。 +- **L20 合指映射**:`hand_qpos`(16关节弧度) → `L20Hand{finger,cmd}`(逐指、cmd 量纲待定 0~255?/角度?)——接 `$LINKERHAND_SDK_ROOT`。`real_arm.set_hand` 已留接口。 - **自体滤除**:真机臂在视野污染感知——先"移臂出视野",后补 URDF(`robot_description`)+关节角滤自身点云。 - **抓取成功判定**:再感知 / 手指电流 / 力矩(接 LinkerHand SDK)。 - **真机物体模板**:感知 ICP 分类需对应物体模板(`build_templates` 从 mesh/STEP 采);只求位置可用簇中心。 @@ -181,5 +181,3 @@ - [ ] **双臂协同/避碰**:目前只动右臂,右臂够 +y 侧须防撞左臂。 --- - -*相关仿真侧文档见 `~/ObsidianVault/02-Projects/a7l20-hug-sim.md`。* diff --git a/docs/table_contact_escape.md b/docs/table_contact_escape.md index 4aff55a..695e9e5 100644 --- a/docs/table_contact_escape.md +++ b/docs/table_contact_escape.md @@ -49,13 +49,13 @@ 保存快照+已采集桌面的条件诊断(不访问硬件): ```bash -/home/timessage/a7l20-hug-sim/.venv/bin/python /home/timessage/a7l20-hug-sim/scripts/plan_table_escape.py +.venv/bin/python scripts/plan_table_escape.py ``` 真实装配几何+**合成接触桌面**演示(不是实际桌面验证,不改变标定): ```bash -/home/timessage/a7l20-hug-sim/.venv/bin/python /home/timessage/a7l20-hug-sim/scripts/plan_table_escape.py --demo +.venv/bin/python scripts/plan_table_escape.py --demo ``` 回归测试:`scripts/test_table_contact_escape.py`。 diff --git a/requirements-cad.txt b/requirements-cad.txt new file mode 100644 index 0000000..38ab370 --- /dev/null +++ b/requirements-cad.txt @@ -0,0 +1,2 @@ +-r requirements-geometry.txt +cadquery-ocp diff --git a/requirements-camera.txt b/requirements-camera.txt new file mode 100644 index 0000000..90f5e5a --- /dev/null +++ b/requirements-camera.txt @@ -0,0 +1,2 @@ +-r requirements-sim.txt +pyrealsense2==2.58.4.10922 diff --git a/requirements-controller.txt b/requirements-controller.txt new file mode 100644 index 0000000..a55648d --- /dev/null +++ b/requirements-controller.txt @@ -0,0 +1,3 @@ +-r requirements-geometry.txt +roslibpy==2.1.0 +python-can==4.6.1 diff --git a/requirements-demo.txt b/requirements-demo.txt new file mode 100644 index 0000000..c35a135 --- /dev/null +++ b/requirements-demo.txt @@ -0,0 +1,5 @@ +-r requirements-geometry.txt +mink==1.3.0 +daqp==0.9.1 +imageio[ffmpeg]==2.37.4 +imageio-ffmpeg==0.6.0 diff --git a/requirements-geometry.txt b/requirements-geometry.txt new file mode 100644 index 0000000..c861123 --- /dev/null +++ b/requirements-geometry.txt @@ -0,0 +1,2 @@ +-r requirements-sim.txt +trimesh==5.1.0 diff --git a/requirements-retarget.txt b/requirements-retarget.txt new file mode 100644 index 0000000..2ac6015 --- /dev/null +++ b/requirements-retarget.txt @@ -0,0 +1,5 @@ +dex-retargeting==0.5.0 +pin==4.1.0 +PyYAML==6.0.3 +numpy==2.5.3 +scipy==1.18.1 diff --git a/scene/build_measured_layout.py b/scene/build_measured_layout.py index fb64cbf..f6b08ce 100644 --- a/scene/build_measured_layout.py +++ b/scene/build_measured_layout.py @@ -34,7 +34,7 @@ def build(): old_model = mujoco.MjModel.from_xml_path(str(SOURCE)) fresh_snapshot = None if cfg.get('snapshot_file'): - fresh_snapshot = json.loads(Path(cfg['snapshot_file']).read_text()) + fresh_snapshot = json.loads((ROOT / cfg['snapshot_file']).read_text()) key_id = old_model.key('snapshot').id for side, letter in [('left','L'),('right','R')]: state = fresh_snapshot['states'][side]['joint_state'] @@ -150,7 +150,7 @@ def build(): info['snapshot_received_at_utc'] = fresh_snapshot['received_at_utc'] info['snapshot_is_live'] = False info['snapshot_source'] = 'fresh read saved once; not continuous live streaming' - info['input_sha256'][cfg['snapshot_file']] = hashlib.sha256(Path(cfg['snapshot_file']).read_bytes()).hexdigest() + info['input_sha256'][cfg['snapshot_file']] = hashlib.sha256((ROOT / cfg['snapshot_file']).read_bytes()).hexdigest() info.pop('checks', None) # Original historical FK numbers do not describe this snapshot. info['snapshot_limit_warnings'] = [] for jid in range(old_model.njnt): diff --git a/scene/build_real_assembly.py b/scene/build_real_assembly.py index d1bed31..9cbf8d2 100644 --- a/scene/build_real_assembly.py +++ b/scene/build_real_assembly.py @@ -125,7 +125,7 @@ def build(snapshot_path=DEFAULT_SNAPSHOT): hand, _ = prepare_hand("left", kp=2., kv=.08) for mesh in hand.meshes: if mesh.file and not Path(mesh.file).is_absolute(): - mesh.file = str(Path("/home/timessage/Linkerbot_URDF/L20/LEFT") / mesh.file) + mesh.file = str((ROOT / "assets/L20/LEFT") / mesh.file) hand.compiler.meshdir = "" for body in hand.bodies: for geom in body.geoms: @@ -208,7 +208,7 @@ def verify_model(model, info): data = mujoco.MjData(model) mujoco.mj_resetDataKeyframe(model, data, model.key("snapshot").id) mujoco.mj_forward(model, data) - snapshot = json.loads(Path(info["snapshot_file"]).read_text()) + snapshot = json.loads((ROOT / info["snapshot_file"]).read_text()) checks = {} for side in ("left", "right"): pose = snapshot["states"][side]["pose"] diff --git a/scene/build_scene.py b/scene/build_scene.py index 7190e84..19a95a3 100644 --- a/scene/build_scene.py +++ b/scene/build_scene.py @@ -4,6 +4,7 @@ """ from __future__ import annotations +import os import argparse import json import re @@ -13,7 +14,9 @@ import mujoco import numpy as np ROOT = Path(__file__).resolve().parents[1] -P7_XML = Path.home() / "wasm-bimanual-grasp/scenes/p7_bimanual/model.xml" +P7_XML = Path(os.environ.get("P7_SCENE_XML", ROOT / "external/p7_bimanual/model.xml")).expanduser() +if not P7_XML.is_absolute(): + P7_XML = ROOT / P7_XML P7_META = P7_XML.with_name("meta.json") HAND_URDF = {"right": ROOT / "assets/l20_right_mj.urdf", "left": ROOT / "assets/l20_left_mj.urdf"} FLANGE = {"right": "arm_right_R8_Link", "left": "arm_left_L8_Link"} @@ -268,7 +271,7 @@ def build(kp: float, kv: float, obj_scale: float = 1.0, obj_spacing: float = 0.1 if f and not f.startswith("/"): for side in ("left", "right"): if mesh.name.startswith(f"{side}_hand_"): - mesh.file = str(Path("/home/timessage/Linkerbot_URDF/L20") / ("RIGHT" if side == "right" else "LEFT") / f) + mesh.file = str((ROOT / "assets/L20") / ("RIGHT" if side == "right" else "LEFT") / f) # 关节/执行器信息 for side in ("left", "right"): info["arms"][side] = {"joints": [f"arm_{side}_{'L' if side == 'left' else 'R'}{i}_Joint" for i in range(1, 8)], diff --git a/scene/cup_workcell.json b/scene/cup_workcell.json index 86110b3..96e39ec 100644 --- a/scene/cup_workcell.json +++ b/scene/cup_workcell.json @@ -4,8 +4,8 @@ "execution_authorized": false, "purpose": "Offline visual layout. Estimated desk extents, gap and caster dimensions are not collision evidence.", "world_frame": "floor frame: controller base_link translated only along +Z", - "source_arm_urdf": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/assets/controller_model/lingzuv2_description.urdf", - "mount_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/config/left_hand_mount.json", + "source_arm_urdf": "assets/controller_model/lingzuv2_description.urdf", + "mount_file": "config/left_hand_mount.json", "mount": { "basis": "User: all 7 joints zero, then ONLY elbow J4 +90 degrees; palm down, 45deg to horizontal, pinky side lower.", "status": "user_reference_resolved_not_physical_motion_validation", @@ -64,7 +64,7 @@ "hand_side_evidence": "LEFT URDF index root y=-0.03525m, pinky root y=+0.03525m; do not reuse right-hand side signs.", "execution_authorized": false }, - "snapshot_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json", + "snapshot_file": "data/layout_joint_read_20260928T052840Z/arm_snapshot.json", "snapshot_received_at_utc": "20260928T052840Z", "snapshot_is_live": false, "finger_pose": "nominal URDF zero, NOT measured hardware state", @@ -172,10 +172,10 @@ "assets/controller_model/lingzuv2_description.urdf": "136c6c0781ade1baca92aeeb13136c732008ff1177a1f9f47382688b4c12329d", "config/left_hand_mount.json": "42716134cd7f440f9ce26a914b848bd6b3f8f59dc4a87925908880ce993ea4e4", "data/left_cup_current/arm_snapshot_20260924T084830651325Z.json": "c1f960ae08975c52d04e778752cdd2e1e23bc9cf0c16a5c1d9df132dea7575aa", - "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json": "719b929afa14bad7433b889d1141f879331be84646731b35b8132fe324dd32a4" + "data/layout_joint_read_20260928T052840Z/arm_snapshot.json": "719b929afa14bad7433b889d1141f879331be84646731b35b8132fe324dd32a4" }, "snapshot_source": "fresh read saved once; not continuous live streaming", - "source_scene": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/scene/real_assembly.xml", + "source_scene": "scene/real_assembly.xml", "source_sha256": "f833889d39f149064a9e32d218eade50b6c6e84344df1c97c5c8dd22f59ada5b", "layout": { "measured": { @@ -205,10 +205,10 @@ "table_near": "User measured column front face to desk near edge: 0.205m. Corrected column depth 0.09m gives near x=0.09/2+0.205=0.25m. Assumes desk edge parallel to column front.", "unmeasured": "Desk width/depth, caster/deck height, exact column center relative to CAD base and desk yaw are display estimates. Deck center is 8cm forward of column to reproduce its visible extension underneath desk; desk yaw zero.", "photos": [ - "/home/timessage/\u56fe\u7247/a7/IMG20260928115533.jpg", - "/home/timessage/\u56fe\u7247/a7/IMG20260928115542.jpg", - "/home/timessage/\u56fe\u7247/a7/IMG20260928115548.jpg", - "/home/timessage/\u56fe\u7247/a7/IMG20260928115553.jpg" + "IMG20260928115533.jpg", + "IMG20260928115542.jpg", + "IMG20260928115548.jpg", + "IMG20260928115553.jpg" ], "assembly": "Preserve scene/real_assembly.xml bodies, hand adapter transform and keyframes exactly; only translate the assembly to floor coordinates. No hardware actions." }, @@ -218,7 +218,7 @@ "clearance_m": 0.0, "note": "Fit freshly subscribed arm pose to nominal desktop contact. Finger angles remain model zero, not measured. Pure offline display alignment." }, - "snapshot_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json" + "snapshot_file": "data/layout_joint_read_20260928T052840Z/arm_snapshot.json" }, "measured_controller_base_height_m": 1.0059999942912263, "display_lift_m": 0.04412237336401603, @@ -915,6 +915,7 @@ "dimension_uncertainty": "not independently quantified; residual is NOT absolute accuracy", "table_margin_m": 0.005, "physical_execution_authorized": false, - "position_capture": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/cup_moved_capture_20260928" - } -} \ No newline at end of file + "position_capture": "data/cup_moved_capture_20260928" + }, + "historical_external_sources": "Photo/STEP names are provenance only; original external files are not bundled." +} diff --git a/scene/measured_layout.json b/scene/measured_layout.json index 47ca928..7904305 100644 --- a/scene/measured_layout.json +++ b/scene/measured_layout.json @@ -4,8 +4,8 @@ "execution_authorized": false, "purpose": "Offline visual layout. Estimated desk extents, gap and caster dimensions are not collision evidence.", "world_frame": "floor frame: controller base_link translated only along +Z", - "source_arm_urdf": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/assets/controller_model/lingzuv2_description.urdf", - "mount_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/config/left_hand_mount.json", + "source_arm_urdf": "assets/controller_model/lingzuv2_description.urdf", + "mount_file": "config/left_hand_mount.json", "mount": { "basis": "User: all 7 joints zero, then ONLY elbow J4 +90 degrees; palm down, 45deg to horizontal, pinky side lower.", "status": "user_reference_resolved_not_physical_motion_validation", @@ -64,7 +64,7 @@ "hand_side_evidence": "LEFT URDF index root y=-0.03525m, pinky root y=+0.03525m; do not reuse right-hand side signs.", "execution_authorized": false }, - "snapshot_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json", + "snapshot_file": "data/layout_joint_read_20260928T052840Z/arm_snapshot.json", "snapshot_received_at_utc": "20260928T052840Z", "snapshot_is_live": false, "finger_pose": "nominal URDF zero, NOT measured hardware state", @@ -172,10 +172,10 @@ "assets/controller_model/lingzuv2_description.urdf": "136c6c0781ade1baca92aeeb13136c732008ff1177a1f9f47382688b4c12329d", "config/left_hand_mount.json": "42716134cd7f440f9ce26a914b848bd6b3f8f59dc4a87925908880ce993ea4e4", "data/left_cup_current/arm_snapshot_20260924T084830651325Z.json": "c1f960ae08975c52d04e778752cdd2e1e23bc9cf0c16a5c1d9df132dea7575aa", - "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json": "719b929afa14bad7433b889d1141f879331be84646731b35b8132fe324dd32a4" + "data/layout_joint_read_20260928T052840Z/arm_snapshot.json": "719b929afa14bad7433b889d1141f879331be84646731b35b8132fe324dd32a4" }, "snapshot_source": "fresh read saved once; not continuous live streaming", - "source_scene": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/scene/real_assembly.xml", + "source_scene": "scene/real_assembly.xml", "source_sha256": "f833889d39f149064a9e32d218eade50b6c6e84344df1c97c5c8dd22f59ada5b", "layout": { "measured": { @@ -205,10 +205,10 @@ "table_near": "User measured column front face to desk near edge: 0.205m. Corrected column depth 0.09m gives near x=0.09/2+0.205=0.25m. Assumes desk edge parallel to column front.", "unmeasured": "Desk width/depth, caster/deck height, exact column center relative to CAD base and desk yaw are display estimates. Deck center is 8cm forward of column to reproduce its visible extension underneath desk; desk yaw zero.", "photos": [ - "/home/timessage/图片/a7/IMG20260928115533.jpg", - "/home/timessage/图片/a7/IMG20260928115542.jpg", - "/home/timessage/图片/a7/IMG20260928115548.jpg", - "/home/timessage/图片/a7/IMG20260928115553.jpg" + "IMG20260928115533.jpg", + "IMG20260928115542.jpg", + "IMG20260928115548.jpg", + "IMG20260928115553.jpg" ], "assembly": "Preserve scene/real_assembly.xml bodies, hand adapter transform and keyframes exactly; only translate the assembly to floor coordinates. No hardware actions." }, @@ -218,7 +218,7 @@ "clearance_m": 0.0, "note": "Fit freshly subscribed arm pose to nominal desktop contact. Finger angles remain model zero, not measured. Pure offline display alignment." }, - "snapshot_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/layout_joint_read_20260928T052840Z/arm_snapshot.json" + "snapshot_file": "data/layout_joint_read_20260928T052840Z/arm_snapshot.json" }, "measured_controller_base_height_m": 1.0059999942912263, "display_lift_m": 0.04412237336401603, @@ -813,5 +813,6 @@ "preserved_body_max_translation_error_m": 5.351041609389175e-12, "all_original_keyframes_checked": 3, "all_original_body_orientations_unchanged": true - } + }, + "historical_external_sources": "Photo/STEP names are provenance only; original external files are not bundled." } diff --git a/scene/real_assembly.json b/scene/real_assembly.json index 81677be..411d249 100644 --- a/scene/real_assembly.json +++ b/scene/real_assembly.json @@ -4,8 +4,8 @@ "execution_authorized": false, "purpose": "offline kinematic assembly inspection, NOT validated dynamic grasping", "world_frame": "controller base_link; no display height offset", - "source_arm_urdf": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/assets/controller_model/lingzuv2_description.urdf", - "mount_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/config/left_hand_mount.json", + "source_arm_urdf": "assets/controller_model/lingzuv2_description.urdf", + "mount_file": "config/left_hand_mount.json", "mount": { "basis": "User: all 7 joints zero, then ONLY elbow J4 +90 degrees; palm down, 45deg to horizontal, pinky side lower.", "status": "user_reference_resolved_not_physical_motion_validation", @@ -64,7 +64,7 @@ "hand_side_evidence": "LEFT URDF index root y=-0.03525m, pinky root y=+0.03525m; do not reuse right-hand side signs.", "execution_authorized": false }, - "snapshot_file": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/left_cup_current/arm_snapshot_20260924T084830651325Z.json", + "snapshot_file": "data/left_cup_current/arm_snapshot_20260924T084830651325Z.json", "snapshot_received_at_utc": "20260924T084830651325Z", "snapshot_is_live": false, "finger_pose": "nominal URDF zero, NOT measured hardware state", @@ -150,7 +150,7 @@ "dynamic_mass_inertia": "not identified; viewer must not step dynamics" }, "table_reference": { - "source": "/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/table_edge_check_20260924_01/start_edge_audit.json", + "source": "data/table_edge_check_20260924_01/start_edge_audit.json", "normal": [ 0.017866379380500577, -0.04739512024276286, diff --git a/scripts/audit_adapter_geometry.py b/scripts/audit_adapter_geometry.py index d684bc1..f0244d2 100644 --- a/scripts/audit_adapter_geometry.py +++ b/scripts/audit_adapter_geometry.py @@ -26,7 +26,7 @@ def circles(path,z): def main(): arm=circles(ROOT/'assets/controller_model/meshes/L7_Link.STL',-.0525) - hand=circles('/home/timessage/Linkerbot_URDF/L20/LEFT/meshes/hand_base_link.STL',0.) + hand=circles(ROOT/'assets/L20/LEFT/meshes/hand_base_link.STL',0.) if len(arm)!=6 or len(hand)!=4:raise RuntimeError('Hole pattern mismatch') center=np.mean([h['center_mm'] for h in arm],axis=0) if not np.allclose(center,[-28,0],atol=.001):raise RuntimeError('Unexpected flange center') diff --git a/scripts/audit_cup_coordinates.py b/scripts/audit_cup_coordinates.py index 5fb9877..37dd1dd 100644 --- a/scripts/audit_cup_coordinates.py +++ b/scripts/audit_cup_coordinates.py @@ -1,5 +1,6 @@ """Audit saved transforms and IK, without hardware access.""" from pathlib import Path +from project_paths import configured_path import json,xml.etree.ElementTree as ET import numpy as np,mujoco from scipy.spatial.transform import Rotation as R @@ -14,12 +15,12 @@ def main(): base=pose(d.body('base_link').xpos,d.body('base_link').xmat.reshape(3,3));mount=json.loads((ROOT/'config/left_hand_mount.json').read_text());M=np.array(mount['rotation_Arm_Tip_to_hand']);tiphand=pose(mount['translation_Arm_Tip_to_hand_m'],M);l7hand=pose(mount['translation_L7_to_hand_m'],M) h=pose(d.body('left_hand_hand_base_link').xpos,d.body('left_hand_hand_base_link').xmat.reshape(3,3));tip=pose(d.site('left_Arm_Tip').xpos,d.site('left_Arm_Tip').xmat.reshape(3,3));l7=pose(d.body('L7_Link').xpos,d.body('L7_Link').xmat.reshape(3,3)) rep={'hardware_connected':False,'base_world_translation_m':base[:3,3].tolist(),'mount':{'tip_to_hand_matrix_error':float(abs(np.linalg.inv(tip)@h-tiphand).max()),'L7_to_hand_matrix_error':float(abs(np.linalg.inv(l7)@h-l7hand).max())}} - meta=json.loads((ROOT/'scene/measured_layout.json').read_text());snap=json.loads(Path(meta['snapshot_file']).read_text());rep['controller_fk']={} + meta=json.loads((ROOT/'scene/measured_layout.json').read_text());snap=json.loads((ROOT / meta['snapshot_file']).read_text());rep['controller_fk']={} for side in ['left','right']: p=snap['states'][side]['pose'];expected=pose([p['position'][x] for x in 'xyz'],R.from_quat([p['orientation'][x] for x in 'xyzw']).as_matrix());site=d.site(side+'_Arm_Tip');actual=np.linalg.inv(base)@pose(site.xpos,site.xmat.reshape(3,3));rep['controller_fk'][side]={'position_mm':float(np.linalg.norm(actual[:3,3]-expected[:3,3])*1000),'rotation_deg':float(np.degrees(R.from_matrix(expected[:3,:3].T@actual[:3,:3]).magnitude()))} cap=ROOT/'data/cup_sim_capture_20260928';cam=json.loads((cap/'camera.json').read_text());T=np.array(cam['T_world_cam_opencv']);npz=np.load(cap/'hug_cup.npz');rep['hug_camera_to_world']={'landmarks_max_error_m':float(abs(npz['landmarks_cam']@T[:3,:3].T+T[:3,3]-npz['landmarks_world']).max()),'wrist_matrix_error':float(abs(T@npz['T_cam_wrist']-npz['T_world_wrist']).max()),'exported_camera_matrix_error':float(abs(T-npz['T_world_cam']).max())} # Compare all common hand-joint transforms/axes; virtual fingertip additions are allowed. - paths=[ROOT/'assets/l20_left_mj.urdf',Path('/home/timessage/do-as-i-do/retargeting/config/l20/l20_left_with_tips.urdf')];trees=[ET.parse(p).getroot() for p in paths];maps=[{j.get('name'):j for j in t.findall('joint')} for t in trees];diff=[] + paths=[ROOT/'assets/l20_left_mj.urdf',configured_path('REFERENCE_LEFT_URDF', 'external/reference/l20_left_with_tips.urdf', required=True)];trees=[ET.parse(p).getroot() for p in paths];maps=[{j.get('name'):j for j in t.findall('joint')} for t in trees];diff=[] for name,a in maps[0].items(): b=maps[1].get(name) if b is None:diff.append([name,'missing']);continue diff --git a/scripts/check_index_board_hover.py b/scripts/check_index_board_hover.py index e39bfa7..a7f1cde 100644 --- a/scripts/check_index_board_hover.py +++ b/scripts/check_index_board_hover.py @@ -8,6 +8,7 @@ import argparse import tempfile import xml.etree.ElementTree as ET from pathlib import Path +from project_paths import configured_path import numpy as np import trimesh @@ -22,7 +23,7 @@ from search_cup_poses_offline import PoseGuard def hand_geometry(raw): lookup = LeftLookup() values = {k: v['table_angle_rad'] for k, v in lookup.describe(raw).items()} - path = Path('/home/timessage/Linkerbot_URDF_cal/L20/LEFT/linkerhand_g20_left.urdf') + path = configured_path('CALIBRATED_LEFT_URDF', 'external/calibrated_left/linkerhand_g20_left.urdf', required=True) robot = ET.parse(path).getroot() transforms = {'hand_base_link': np.eye(4)} pending = list(robot.findall('joint')) diff --git a/scripts/g20_left_lookup.py b/scripts/g20_left_lookup.py index cb9839c..950f36c 100644 --- a/scripts/g20_left_lookup.py +++ b/scripts/g20_left_lookup.py @@ -7,8 +7,9 @@ import hashlib import json import math from pathlib import Path +from project_paths import configured_path -DEFAULT_TABLE = Path('/home/timessage/Linkerbot_URDF/L20/LEFT/g20_left_G20.json') +DEFAULT_TABLE = configured_path('G20_LEFT_TABLE', 'assets/L20/LEFT/g20_left_G20.json') # SDK20 motor_index -> native G20 (finger index, payload slot). MOTOR_SLOT = {0:(0,2), 5:(0,1), 10:(0,0), 15:(0,5)} for _i in range(1,5): diff --git a/scripts/hand_mapper.py b/scripts/hand_mapper.py index f9ccaf5..1d34621 100644 --- a/scripts/hand_mapper.py +++ b/scripts/hand_mapper.py @@ -31,9 +31,10 @@ import sys import numpy as np from pathlib import Path +from project_paths import configured_path # 导入 LinkerHand SDK 的映射工具 -SDK_PATH = Path.home() / "linkerhand-python-sdk" +SDK_PATH = configured_path('LINKERHAND_SDK_ROOT', 'external/linkerhand-python-sdk') sys.path.insert(0, str(SDK_PATH / "LinkerHand" / "utils")) from mapping import arc_to_range_right_l20, arc_to_range_left_l20, is_within_range diff --git a/scripts/hug_infer_point.py b/scripts/hug_infer_point.py index 357161e..715f3e2 100644 --- a/scripts/hug_infer_point.py +++ b/scripts/hug_infer_point.py @@ -1,14 +1,15 @@ """无头跑 HUG:对采集目录里的 RGB-D,在指定像素(或 camera.json 里记录的物体像素)处采样 N 个人手抓取。 -解释器:~/hug/.venv/bin/python(HUG 环境)。 -用法:cd ~/hug && HF_HUB_OFFLINE=1 .venv/bin/python ~/a7l20-hug-sim/scripts/hug_infer_point.py \ - --capture ~/a7l20-hug-sim/data/capture_ready --object jar --num 16 [--steps 1] +解释器:$HUG_PYTHON(HUG 环境)。 +用法(仓库根目录):HF_HUB_OFFLINE=1 "$HUG_PYTHON" scripts/hug_infer_point.py \ + --capture data/capture_ready --object jar --num 16 [--steps 1] 输出:/hug_.npz —— landmarks_cam (N,21,3) / landmarks_world (N,21,3) / T_cam_wrist (N,4,4) / T_world_wrist (N,4,4) / pose_aa (N,15,3) / verts_world (N,778,3) / click_world (3,) landmark 顺序(HUG=MANO/OpenPose-21):0 腕,1-4 拇指(根→尖),5-8 食指,9-12 中指,13-16 无名指,17-20 小指。 """ import argparse, json, pickle, sys, time from pathlib import Path +from project_paths import configured_path import numpy as np, torch, cv2 @@ -18,7 +19,7 @@ def main(): ap.add_argument("--uv", type=float, nargs=2, default=None, help="原图像素坐标,覆盖 --object") ap.add_argument("--perceive", action="store_true", help="物体像素取自点云感知(perception.json)而非仿真真值(camera.json)") ap.add_argument("--num", type=int, default=16); ap.add_argument("--steps", type=int, default=1) - ap.add_argument("--checkpoint", default=str(Path.home() / "hug/checkpoints/hug_full.safetensors")) + ap.add_argument("--checkpoint", default=str(configured_path('HUG_CHECKPOINT', configured_path('HUG_ROOT', 'external/hug') / 'checkpoints/hug_full.safetensors'))) ap.add_argument("--seed", type=int, default=0) a = ap.parse_args() cap = Path(a.capture).expanduser().resolve() diff --git a/scripts/hug_to_l20.py b/scripts/hug_to_l20.py index 37c6126..cfb0bf8 100644 --- a/scripts/hug_to_l20.py +++ b/scripts/hug_to_l20.py @@ -1,18 +1,19 @@ """HUG 人手抓取 (MANO 21 点, 世界系) → L20 左/右手:腕位姿 (hand_base_link) + 16 主动关节角 → grasp_l20__.json -解释器:~/linkerhand-python-sdk/.venv/bin/python(dex-retargeting + pinocchio)。 -用法:env PYTHONPATH= LD_LIBRARY_PATH= ~/linkerhand-python-sdk/.venv/bin/python scripts/hug_to_l20.py \ +解释器:$RETARGET_PYTHON(dex-retargeting + pinocchio)。 +用法:env PYTHONPATH= LD_LIBRARY_PATH= $RETARGET_PYTHON scripts/hug_to_l20.py \ --npz data/capture_ready/hug_jar.npz --top 3 --side right [--check-frame] -做法与 ~/do-as-i-do/retargeting/l20/retarget_l20_v2.py 一致:掌基(z=腕→中指根, y=食指根−小指根)对齐 + 逐骨方向按机器人骨长迁移 +做法与 $RETARGETING_ROOT/l20/retarget_l20_v2.py 一致:掌基(z=腕→中指根, y=食指根−小指根)对齐 + 逐骨方向按机器人骨长迁移 + dex-retargeting position IK(21 点);腕姿态 R_wb = B_human @ B_robot^T。 """ import argparse, json, os, sys from pathlib import Path +from project_paths import configured_path import numpy as np, yaml from scipy.spatial.transform import Rotation as Rot ROOT = Path(__file__).resolve().parents[1] -L20DIR = Path.home() / "do-as-i-do/retargeting" +L20DIR = configured_path('RETARGETING_ROOT', 'external/retargeting') sys.path.insert(0, str(L20DIR / "l20")) from retarget_l20_v2 import palm_basis, _unit, CHAINS # noqa: E402 @@ -24,7 +25,11 @@ def build_retargeter(side="right", config_path=None): cfg_file = Path(config_path).resolve() if config_path else L20DIR / f"config/l20/l20_{side}_position.yml" from dex_retargeting.retargeting_config import RetargetingConfig cfg = yaml.safe_load(open(cfg_file))["retargeting"] - rt = RetargetingConfig.load_from_file(str(cfg_file)).build() + urdf = Path(cfg["urdf_path"]).expanduser() + if not urdf.is_absolute(): + urdf = (ROOT / urdf) if cfg_file.is_relative_to(ROOT) else (cfg_file.parent / urdf) + cfg["urdf_path"] = str(urdf) + rt = RetargetingConfig.from_dict(cfg).build() opt = rt.optimizer; robot = opt.robot link_ids = [robot.get_link_index(n) for n in cfg["target_link_names"]] def fk_points(q): diff --git a/scripts/inspect_hand_adapter.py b/scripts/inspect_hand_adapter.py index aa49267..a64be5a 100644 --- a/scripts/inspect_hand_adapter.py +++ b/scripts/inspect_hand_adapter.py @@ -1,6 +1,7 @@ """Measure the supplied STEP and export its exact surface as an STL in metres.""" import json from pathlib import Path +from project_paths import configured_path from OCP.STEPControl import STEPControl_Reader from OCP.Bnd import Bnd_Box from OCP.BRepBndLib import BRepBndLib @@ -17,7 +18,7 @@ from OCP.BRepMesh import BRepMesh_IncrementalMesh from OCP.StlAPI import StlAPI_Writer ROOT=Path(__file__).resolve().parents[1] -SOURCE=Path('/home/timessage/文档/A7V2-L20链接法兰 .STEP') +SOURCE=configured_path('HAND_ADAPTER_STEP', 'external/hand_adapter.STEP') def limits(box): diff --git a/scripts/joint_follow_adapter.py b/scripts/joint_follow_adapter.py index 8622235..36a6e68 100644 --- a/scripts/joint_follow_adapter.py +++ b/scripts/joint_follow_adapter.py @@ -10,11 +10,12 @@ import hashlib import json import tempfile from pathlib import Path +from project_paths import configured_path import numpy as np from elbow_raise_preflight import ROOT,DEFAULT_PLAN from trajectory_supervisor import Trajectory -SDK_LIBRARY=Path('/home/timessage/weipz-Lbot_Bridge/src/officer_sdk/lbot_driver/lib/linux_x64/liblbot_api_cpp.so.1.0.5') +SDK_LIBRARY=configured_path('A7_SDK_LIBRARY', 'external/a7_sdk/liblbot_api_cpp.so.1.0.5') INTERFACES={ 'sdk_joint_follow':{'function':'lbot_joint_follow','left_arm_enum':0,'angles':'7 doubles, rad','return':'send success only'}, 'local_bridge':{'topic':'/robot1/left_arm/joint_follow','type':'lbot_arm_interfaces/msg/FollowJoint','follow_flag_used':False}, diff --git a/scripts/live_demo.py b/scripts/live_demo.py index d51137c..7751e24 100644 --- a/scripts/live_demo.py +++ b/scripts/live_demo.py @@ -1,15 +1,16 @@ """实时演示:一个 MuJoCo 窗口里,依次对桌上每个物体跑 胸口相机采集 → HUG → 重定向 L20 → 右臂抓取 → 放到放置区 → 回 ready。 用法:A7L20_SCENE=ycb1 MUJOCO_GL=glfw .venv/bin/python scripts/live_demo.py [--objects a,b] [--num 16] [--top 5] [--no-view] -子进程:HUG 用 ~/hug/.venv,重定向用 ~/linkerhand-python-sdk/.venv;本进程用 a7l20 .venv 跑 MuJoCo + mink。 +子进程:HUG 用 $HUG_PYTHON,重定向用 $RETARGET_PYTHON;本进程用 a7l20 .venv 跑 MuJoCo + mink。 """ import argparse, json, os, subprocess, sys, time from pathlib import Path +from project_paths import configured_path import numpy as np sys.path.insert(0, str(Path(__file__).resolve().parent)) from grasp_exec import Sim, load_grasp_json, run, ROOT, SCENE -HUG_PY = Path.home() / "hug/.venv/bin/python"; SDK_PY = Path.home() / "linkerhand-python-sdk/.venv/bin/python" +HUG_PY = configured_path('HUG_PYTHON', configured_path('HUG_ROOT', 'external/hug') / '.venv/bin/python'); SDK_PY = configured_path('RETARGET_PYTHON', '.retarget/bin/python') DROP = np.array([0.56, -0.30]) # 放置区(桌面右后角) @@ -64,7 +65,7 @@ def main(): print(f" capture {dt:.1f}s: " + out.strip().splitlines()[0][:100]) set_pcd() perceive(qf) - code, out, dt = sh([str(HUG_PY), str(ROOT / "scripts/hug_infer_point.py"), "--capture", str(cap), "--object", obj, "--num", str(a.num)] + HUG_ARGS, cwd=str(Path.home() / "hug"), env=env_hug, allow=(3,)) + code, out, dt = sh([str(HUG_PY), str(ROOT / "scripts/hug_infer_point.py"), "--capture", str(cap), "--object", obj, "--num", str(a.num)] + HUG_ARGS, cwd=str(configured_path('HUG_ROOT', 'external/hug')), env=env_hug, allow=(3,)) if code == 3: # 点云感知没认出该物体:不对不可信位姿下手,记为漏检并跳过 print(f" 感知漏检: " + out.strip().splitlines()[-1][:120]); results[obj] = "miss"; sim.go_ready(2.5) print(f" => {obj}: PERCEPTION_MISS"); continue @@ -86,7 +87,7 @@ def main(): np.save(qf, sim.d.qpos.copy()); sh([sys.executable, str(ROOT / "scripts/capture_chest_rgbd.py"), "--out", str(cap), "--qpos", str(qf)]) set_pcd() perceive(qf) - c2, o2, _ = sh([str(HUG_PY), str(ROOT / "scripts/hug_infer_point.py"), "--capture", str(cap), "--object", obj, "--num", str(a.num), "--seed", str(rounds)] + HUG_ARGS, cwd=str(Path.home() / "hug"), env=env_hug, allow=(3,)) + c2, o2, _ = sh([str(HUG_PY), str(ROOT / "scripts/hug_infer_point.py"), "--capture", str(cap), "--object", obj, "--num", str(a.num), "--seed", str(rounds)] + HUG_ARGS, cwd=str(configured_path('HUG_ROOT', 'external/hug')), env=env_hug, allow=(3,)) if c2 == 3: # 被推动后感知不到了:放弃该物体 print(f" 重感知漏检,放弃 {obj}"); ok = False; break sh([str(SDK_PY), str(ROOT / "scripts/hug_to_l20.py"), "--npz", str(cap / f"hug_{obj}.npz"), "--top", str(a.top)], env=env_sdk) diff --git a/scripts/measure_workcell_cup.py b/scripts/measure_workcell_cup.py index 9d5759e..ba05382 100644 --- a/scripts/measure_workcell_cup.py +++ b/scripts/measure_workcell_cup.py @@ -1,7 +1,7 @@ import cv2,numpy as np,json from scipy.optimize import least_squares from pathlib import Path -p=Path('/home/timessage/a7l20-hug-sim/exports/a7l20-hug-sim/data/cup_model_20260928');im=cv2.imread(str(p/'rgb.png'));dep=cv2.imread(str(p/'depth.png'),-1)/1000.;K=np.array(json.loads((p/'camera.json').read_text())['K']);vv,uu=np.indices(dep.shape);xyz=np.stack([(uu-K[0,2])*dep/K[0,0],(vv-K[1,2])*dep/K[1,1],dep],-1) +p=(Path(__file__).resolve().parents[1]/'data/cup_model_20260928');im=cv2.imread(str(p/'rgb.png'));dep=cv2.imread(str(p/'depth.png'),-1)/1000.;K=np.array(json.loads((p/'camera.json').read_text())['K']);vv,uu=np.indices(dep.shape);xyz=np.stack([(uu-K[0,2])*dep/K[0,0],(vv-K[1,2])*dep/K[1,1],dep],-1) roi=(uu>270)&(uu<655)&(vv>130)&(vv<395)&(dep>.25)&(dep<.8);pts=xyz[roi][::3];rng=np.random.default_rng(42);best=[] for _ in range(400): a,b,c=pts[rng.choice(len(pts),3,False)];n=np.cross(b-a,c-a);n/=max(np.linalg.norm(n),1e-10);sel=np.abs((pts-a)@n)<.003 diff --git a/scripts/plan_workcell_escape.py b/scripts/plan_workcell_escape.py index fbd2332..0d3b338 100644 --- a/scripts/plan_workcell_escape.py +++ b/scripts/plan_workcell_escape.py @@ -14,7 +14,7 @@ def main(): meta=json.loads((ROOT/'scene/measured_layout.json').read_text());cfg=meta['layout'];work=json.loads((ROOT/'config/cup_workcell.json').read_text()) hand={j.get('name'):0. for j in ET.parse(HAND_URDF).getroot().findall('joint') if j.find('mimic') is None} geo=EscapeGeometry(hand) - state=json.loads(Path(meta['snapshot_file']).read_text())['states']['left']['joint_state'] + state=json.loads((ROOT / meta['snapshot_file']).read_text())['states']['left']['joint_state'] names=[x.upper() for x in state['name']];q=np.array([state['position'][names.index(f'L{i}_JOINT')] for i in range(1,8)]) measured=cfg['measured'];est=cfg['estimated_visual_only'];near=measured['column_xy_m'][0]/2+measured['column_front_to_table_near_m'] table=FiniteTable([near+est['table_depth_m']/2,0,measured['table_top_height_m']-meta['controller_base_height_m']],np.eye(3),[est['table_depth_m'],est['table_width_m'],measured['table_thickness_m']],uncertainty_m=0.,verified=True,source='exact simulated tabletop ONLY; NOT physical table certification') diff --git a/scripts/prepare_snapshot.py b/scripts/prepare_snapshot.py index 93757c3..e218724 100644 --- a/scripts/prepare_snapshot.py +++ b/scripts/prepare_snapshot.py @@ -1,14 +1,9 @@ -"""Rebase recorded local project paths after cloning. Does not modify external projects.""" +"""Check bundled snapshot resources without rewriting configuration files.""" from pathlib import Path -root=Path(__file__).resolve().parents[1] -old='/home/timessage/a7l20-hug-sim' -count=0 -for folder in ['scripts','config','scene','data','assets']: - for p in (root/folder).rglob('*'): - if p==Path(__file__).resolve() or p.suffix not in ['.py','.json','.yml','.yaml','.txt']:continue - try:s=p.read_text() - except (UnicodeError,IsADirectoryError):continue - if old in s: - s=s.replace(old+'/exports/a7l20-hug-sim','__SNAPSHOT_ROOT__').replace(old,'__SNAPSHOT_ROOT__') - p.write_text(s.replace('__SNAPSHOT_ROOT__',str(root)));count+=1 -print('Rebased',count,'text files for',root) +ROOT = Path(__file__).resolve().parents[1] +required = ["scene/cup_workcell.xml", "data/cup_middle_search/dynamic_scene.xml", + "assets/l20_left_mj.urdf", "assets/l20_right_mj.urdf", + "assets/L20/LEFT/g20_left_G20.json"] +missing = [p for p in required if not (ROOT / p).is_file()] +if missing: raise SystemExit("Missing snapshot resources: " + ", ".join(missing)) +print("Snapshot resources present; configuration unchanged.") diff --git a/scripts/project_paths.py b/scripts/project_paths.py new file mode 100644 index 0000000..bcf5a21 --- /dev/null +++ b/scripts/project_paths.py @@ -0,0 +1,10 @@ +"""Resolve bundled resources and explicitly configured optional tools.""" +import os +from pathlib import Path +ROOT = Path(__file__).resolve().parents[1] +def configured_path(name, default, *, required=False): + path = Path(os.environ.get(name, str(default))).expanduser() + if not path.is_absolute(): path = ROOT / path + if required and not path.exists(): + raise FileNotFoundError(f"{name}: {path} is missing; configure {name} (see docs/INSTALL.md)") + return path diff --git a/scripts/real_grasp.py b/scripts/real_grasp.py index fd38569..0e71f8c 100644 --- a/scripts/real_grasp.py +++ b/scripts/real_grasp.py @@ -11,12 +11,13 @@ """ import argparse, json, os, subprocess, sys, time from pathlib import Path +from project_paths import configured_path import numpy as np sys.path.insert(0, str(Path(__file__).resolve().parent)) from real_arm import RealArm ROOT = Path(__file__).resolve().parents[1] -HUG_PY = Path.home() / "hug/.venv/bin/python"; SDK_PY = Path.home() / "linkerhand-python-sdk/.venv/bin/python" +HUG_PY = configured_path('HUG_PYTHON', configured_path('HUG_ROOT', 'external/hug') / '.venv/bin/python'); SDK_PY = configured_path('RETARGET_PYTHON', '.retarget/bin/python') def sh(cmd, cwd=None, env=None): @@ -43,7 +44,7 @@ def perceive_and_plan(cap, obj, scene, num, top, side, table_top): env_hug = {k: v for k, v in os.environ.items() if k not in ("all_proxy", "ALL_PROXY")} | {"HF_HUB_OFFLINE": "1", "HF_ENDPOINT": "https://hf-mirror.com"} env_sdk = dict(os.environ) | {"PYTHONPATH": "", "LD_LIBRARY_PATH": ""} print("③ HUG 抓取推理 ...") - sh([str(HUG_PY), str(ROOT / "scripts/hug_infer_point.py"), "--capture", str(cap), "--object", obj, "--num", str(num), "--perceive"], cwd=str(Path.home() / "hug"), env=env_hug) + sh([str(HUG_PY), str(ROOT / "scripts/hug_infer_point.py"), "--capture", str(cap), "--object", obj, "--num", str(num), "--perceive"], cwd=str(configured_path('HUG_ROOT', 'external/hug')), env=env_hug) print("④ 重定向 L20 ...") sh([str(SDK_PY), str(ROOT / "scripts/hug_to_l20.py"), "--npz", str(cap / f"hug_{obj}.npz"), "--top", str(top), "--side", side, "--table-top", str(table_top)], env=env_sdk) return sorted(cap.glob(f"grasp_l20_{obj}_*.json"), key=lambda p: int(p.stem.split("_")[-1])) diff --git a/scripts/real_grasp_manual.py b/scripts/real_grasp_manual.py index 9e9fe2b..88213c9 100644 --- a/scripts/real_grasp_manual.py +++ b/scripts/real_grasp_manual.py @@ -12,14 +12,15 @@ """ import argparse, json, os, subprocess, sys, time from pathlib import Path +from project_paths import configured_path import numpy as np import cv2 sys.path.insert(0, str(Path(__file__).resolve().parent)) from real_arm import RealArm ROOT = Path(__file__).resolve().parents[1] -HUG_PY = Path.home() / "hug/.venv/bin/python" -SDK_PY = Path.home() / "linkerhand-python-sdk/.venv/bin/python" +HUG_PY = configured_path('HUG_PYTHON', configured_path('HUG_ROOT', 'external/hug') / '.venv/bin/python') +SDK_PY = configured_path('RETARGET_PYTHON', '.retarget/bin/python') def sh(cmd, cwd=None, env=None): @@ -74,7 +75,7 @@ def capture_and_hug(cap, click_uv, side, num, table_top=-0.265): "--capture", str(cap), "--object", "target", "--num", str(num)], - cwd=str(Path.home() / "hug"), env=env_hug) + cwd=str(configured_path('HUG_ROOT', 'external/hug')), env=env_hug) print(f"③ 重定向到 L20 {side} 手...") sh([str(SDK_PY), str(ROOT / "scripts/hug_to_l20.py"), diff --git a/scripts/real_raise.py b/scripts/real_raise.py index 69808c0..b6329e1 100644 --- a/scripts/real_raise.py +++ b/scripts/real_raise.py @@ -6,12 +6,12 @@ · 目标位置 = 当前 pose_states 位置 + (0,0,Δz);抬升前交叉校验 FK 位置≈pose_states(<2cm),不一致直接中止(防法兰/工具系错配)。 · 只发一次 MoveL、block=False;不确认(输入 y)不发指令。 · 随时急停(另开终端): - source /opt/ros/jazzy/setup.bash; source ~/weipz-Lbot_Bridge/install/setup.bash + source /opt/ros/jazzy/setup.bash; source $A7_BRIDGE_SETUP ros2 service call /robot1/right_arm/set_emergency_stop lbot_arm_interfaces/srv/SetEmergency "{emergency: true}" 运行: source /opt/ros/jazzy/setup.bash - source ~/weipz-Lbot_Bridge/install/setup.bash + source $A7_BRIDGE_SETUP python3 scripts/real_raise.py --dz 0.10 --speed 0.3 """ import argparse, sys diff --git a/scripts/run_pipeline.sh b/scripts/run_pipeline.sh index e839b57..e3b8926 100755 --- a/scripts/run_pipeline.sh +++ b/scripts/run_pipeline.sh @@ -1,22 +1,26 @@ -#!/bin/bash -# 端到端:胸口相机采集 → HUG 采样人手抓取 → 重定向到 L20 → MuJoCo 执行(右臂) -# 用法:bash scripts/run_pipeline.sh [num_samples=16] [top=3] +#!/usr/bin/env bash +# Simulation: RGB-D -> HUG -> retarget -> MuJoCo. set -euo pipefail -cd "$(dirname "$0")/.." +ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT" OBJ=${1:-jar}; NUM=${2:-16}; TOP=${3:-3} -CAP=data/capture_ready -A7=.venv/bin/python; HUG=~/hug/.venv/bin/python; SDK=~/linkerhand-python-sdk/.venv/bin/python -echo "== 1) capture (chest_cam @ ready)" -MUJOCO_GL=glfw $A7 scripts/capture_chest_rgbd.py --pose ready --out $CAP -echo "== 2) HUG: sample $NUM grasps at '$OBJ'" -(cd ~/hug && env -u all_proxy -u ALL_PROXY HF_HUB_OFFLINE=1 HF_ENDPOINT=https://hf-mirror.com $HUG ~/a7l20-hug-sim/scripts/hug_infer_point.py --capture ~/a7l20-hug-sim/$CAP --object $OBJ --num $NUM) -echo "== 3) retarget -> L20 (top $TOP)" -env PYTHONPATH= LD_LIBRARY_PATH= $SDK scripts/hug_to_l20.py --npz $CAP/hug_$OBJ.npz --top $TOP -echo "== 4) execute" +CAP="$ROOT/data/capture_ready" +A7="${A7_PYTHON:-$ROOT/.venv/bin/python}" +export HUG_ROOT="${HUG_ROOT:-$ROOT/external/hug}" +[[ "$HUG_ROOT" = /* ]] || export HUG_ROOT="$ROOT/$HUG_ROOT" +HUG="${HUG_PYTHON:-$HUG_ROOT/.venv/bin/python}" +SDK="${RETARGET_PYTHON:-$ROOT/.retarget/bin/python}" +[[ "$HUG" = /* ]] || HUG="$ROOT/$HUG" +[[ "$SDK" = /* ]] || SDK="$ROOT/$SDK" +for exe in "$A7" "$HUG" "$SDK"; do + [[ -x "$exe" ]] || { echo "Missing interpreter: $exe (see docs/INSTALL.md)" >&2; exit 1; } +done +MUJOCO_GL=glfw "$A7" scripts/capture_chest_rgbd.py --pose ready --out "$CAP" +(cd "$HUG_ROOT" && env -u all_proxy -u ALL_PROXY HF_HUB_OFFLINE=1 "$HUG" "$ROOT/scripts/hug_infer_point.py" --capture "$CAP" --object "$OBJ" --num "$NUM") +env PYTHONPATH= LD_LIBRARY_PATH= "$SDK" scripts/hug_to_l20.py --npz "$CAP/hug_$OBJ.npz" --top "$TOP" ok=0 for k in $(seq 0 $((TOP-1))); do - J=$CAP/grasp_l20_${OBJ}_$k.json; [ -f "$J" ] || continue - echo "-- candidate $k: $(python3 -c "import json;print(json.load(open('$J'))['metrics'])")" - if MUJOCO_GL=glfw $A7 scripts/grasp_exec.py --grasp-json $J --render --tag hug_${OBJ}_$k; then ok=1; echo "== SUCCESS with candidate $k (video out/grasp_hug_${OBJ}_$k.mp4)"; break; fi + J="$CAP/grasp_l20_${OBJ}_$k.json"; [[ -f "$J" ]] || continue + if MUJOCO_GL=glfw "$A7" scripts/grasp_exec.py --grasp-json "$J" --render --tag "hug_${OBJ}_$k"; then ok=1; break; fi done -[ $ok = 1 ] || { echo "== all $TOP candidates failed"; exit 1; } +[[ $ok = 1 ]] || { echo "All $TOP simulation candidates failed"; exit 1; } diff --git a/scripts/test_real_assembly.py b/scripts/test_real_assembly.py index 7c63cf1..ddc79ee 100644 --- a/scripts/test_real_assembly.py +++ b/scripts/test_real_assembly.py @@ -29,7 +29,7 @@ class RealAssemblyTests(unittest.TestCase): def setUpClass(cls): cls.info = json.loads((ROOT / "scene/real_assembly.json").read_text()) cls.model = mujoco.MjModel.from_xml_path(str(ROOT / "scene/real_assembly.xml")) - cls.snapshot = json.loads(Path(cls.info["snapshot_file"]).read_text()) + cls.snapshot = json.loads((ROOT / cls.info["snapshot_file"]).read_text()) cls.mount = json.loads(assembly.MOUNT_FILE.read_text()) def pose(self, name): diff --git a/scripts/verify_saved_cup_offline.py b/scripts/verify_saved_cup_offline.py index f61489f..ba1800d 100644 --- a/scripts/verify_saved_cup_offline.py +++ b/scripts/verify_saved_cup_offline.py @@ -37,7 +37,7 @@ def main(): 'Actual controller interpolation and stopping distance not certified by offline linear interpolation.', 'Local SDK documents emergency stop only; retaining enable and canceling queued motion are undocumented.', 'Self collision and cup/other obstacles not covered by this table-only test.'] - report['stop_evidence']={'sdk':'/home/timessage/weipz-Lbot_Bridge/src/officer_sdk/lbot_driver/include/lbot_driver/lbot_api_cpp.h', + report['stop_evidence']={'sdk':'lbot_driver/lbot_api_cpp.h (SDK 1.0.5 header; external vendor source)', 'symbol':'lbot_emergency_stop','keeps_enable':'unknown', 'executor':'scripts/execute_left_cup.py exception handler calls arm.emergency(True)'} path=cap/'offline_execution_verification.json'