完善五轴 RTCP 仿真与验证资料
This commit is contained in:
@@ -10028,3 +10028,137 @@ nginx: configuration file /etc/nginx/nginx.conf test is successful
|
||||
8. 后续约定:
|
||||
- 后续每次完成代码、测试或文档完善后,将继续使用中文说明。
|
||||
- 每次形成本地提交后,将立即推送到当前云仓库 `origin/master`。
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-01 执行日志:LinuxCNC gmoccapy 与 Web WASM 实跑 JSON 对标
|
||||
|
||||
1. 用户任务:
|
||||
- 用户要求在 `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan` 中针对数控系统仿真功能,完整准确对标 `/home/meswork/cnc_wams/linuxcnc` 的 `gmoccapy` 数控系统仿真功能。
|
||||
- 要求分别实际运行 G 代码程序,将刀具预览路径、刀具执行路径、每行 G 代码执行过程写入 JSON。
|
||||
- 要求比较 LinuxCNC 与 Web 两份 JSON,并据此完善 Web 项目。
|
||||
|
||||
2. LinuxCNC native 侧验证:
|
||||
- 检查 LinuxCNC gmoccapy 配置目录,确认目标配置位于 `linuxcnc/configs/sim/gmoccapy/non_trivial_kinematics/table-rotary-tilting`。
|
||||
- 直接运行 `rs274` 时曾因缺少 RIP 环境报 `ModuleNotFoundError: No module named 'gscreen'`。
|
||||
- 改用 `linuxcnc/scripts/rip-environment rs274 -g -i xyzac-trt.ini -t xyzac-trt.tbl -v <temp-var> examples/<program>` 后,native canonical 输出可稳定采集。
|
||||
- 尝试启动完整 `linuxcnc`/`gmoccapy` GUI/Headless 进程,但自动化环境下不稳定;遗留的 `linuxcncsvr`、`rtapi_app`、`gmoccapy`、`pickconfig.tcl` 相关进程已清理。
|
||||
- 因此本轮以同一 LinuxCNC 源树中的 `rs274` canonical 输出作为可重复 native 基准;Web 侧使用 WASM interpreter 与 TP runtime 输出执行路径 samples。
|
||||
|
||||
3. Web 运行时问题定位:
|
||||
- 检查 `app/src/runtime/linuxcnc-interpreter-runtime.js`、machine-file staging、profile 与已有测试。
|
||||
- 发现 `G93` inverse-time feed 的 Web 解析曾使用源 G 代码 F 字,而不是 LinuxCNC canonical `SET_FEED_RATE`。
|
||||
- 用 gmoccapy `impeller-7bl-xyzac.ngc` 验证,native 第一段 G93 feed 为 `635.7454`,Web 原先会错取源 F 字 `318`。
|
||||
- 修复为优先解析 `canon_event=SET_FEED_RATE rate=...` 与 `canon_event=UPDATE_TAG feed=...`,只有没有有效 canonical feed 时才回退到源 F 字。
|
||||
|
||||
4. WASM machine-file canonical 输出修复:
|
||||
- 检查 `/home/meswork/cnc_wams/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_wasm.cpp`。
|
||||
- 发现 `lcinterp_run_fiveaxis_remap_file` 成功执行文件后没有调用 `append_events_and_state(output, interp)`,导致 machine-file 路径无法完整写出 canonical events。
|
||||
- 已补入 `append_events_and_state(output, interp);`。
|
||||
- 执行 `/home/meswork/cnc_wams/wasm-port/tools/build_wasm_core.sh` 重建 WASM core,构建成功。
|
||||
|
||||
5. native/Web JSON 对标脚本:
|
||||
- 新增 `web-rtcp-5axis-sim-plan/tools/collect-linuxcnc-web-parity.mjs`。
|
||||
- 脚本默认输出目录为 `working_run/linuxcnc-web-parity`。
|
||||
- 默认实跑用例为:
|
||||
- `impeller-7bl-xyzac.ngc`
|
||||
- `boat-xyzac.ngc`
|
||||
- 脚本写出:
|
||||
- `linuxcnc-native-<slug>.json`
|
||||
- `web-runtime-<slug>.json`
|
||||
- `comparison-<slug>.json`
|
||||
- `index.json`
|
||||
- JSON 内容包括:
|
||||
- `toolPreviewPath`:canonical 运动事件、行号、语句、轴位置、进给、原始事件。
|
||||
- `toolExecutionPath`:native 侧 canonical endpoint timing estimate,Web 侧 LinuxCNC TP WASM samples。
|
||||
- `lineExecution`:每一行 G 代码均有记录,含 `executionState`、运动事件数、最终轴位、事件列表;空行/注释行和无运动行也会记录。
|
||||
- `canonicalEvents`、`plannerTiming`、`rawResultText`、runtime diagnostics。
|
||||
|
||||
6. boat-xyzac 差异定位与修复:
|
||||
- 首次对比 `impeller-7bl-xyzac.ngc` 通过,`boat-xyzac.ngc` 发现 1 处差异:第 12 行快速移动 native Z=5,Web Z=0。
|
||||
- native 早期路径为:第 9 行到 XYZ0,第 10 行 Z5,第 12 行保持 Z5 后移动 XY。
|
||||
- Web 原因是 gmoccapy Python remap 在 WASM 中没有完整就绪,解释器走 builtin M6 后触发同步读取 `GET_EXTERNAL_POSITION_*`。
|
||||
- `/home/meswork/cnc_wams/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp` 中 `GET_EXTERNAL_POSITION_X/Y/Z/A/B/C/U/V/W` 原先全部固定返回 0,导致换刀同步后 Z 从 5 回到 0。
|
||||
- 已增加 `ExternalPosition` 和 `g_external_plane`,在 `CANON_UPDATE_END_POINT`、`STRAIGHT_TRAVERSE`、`STRAIGHT_FEED`、`ARC_FEED` 中维护最后一个 canonical 终点。
|
||||
- `GET_EXTERNAL_POSITION_*` 改为返回该终点;`GET_EXTERNAL_PLANE` 返回当前平面。
|
||||
- 圆弧终点映射按 LinuxCNC 行为处理:XY、YZ、XZ、UV、VW、UW 平面分别更新对应轴。
|
||||
- 重新执行 `./tools/build_wasm_core.sh`,构建成功。
|
||||
|
||||
7. runtime summary 与边界修复:
|
||||
- `app/src/runtime/linuxcnc-interpreter-runtime.js` 中将 `machineFileExecutionReady` 改为表示 machine-file 程序成功执行并产生 motion。
|
||||
- `remapRuntimeReady` 保留为单独诊断,表示 `fiveaxis_remaps_ready=1` 等 remap 配置真正就绪。
|
||||
- `app/src/runtime/full-execution-boundary.js` 改为使用 `summary.machineFileExecutionReady` 判断 machine-file 已执行,不再把 gmoccapy Python remap 未完整就绪误判成程序未运行。
|
||||
- 同时保留 `remapRuntimeReady` 诊断字段,避免把未完整就绪的 gmoccapy Python remap 伪装成 ready。
|
||||
|
||||
8. 测试补强:
|
||||
- `tests/node/verify_linuxcnc_interpreter_runtime.mjs` 增加 gmoccapy `impeller-7bl-xyzac.ngc` 的 G93 feed 断言,确认第一段 feed motion 使用 canonical feed `635.745` 附近值,而不是源 F 字 `318`。
|
||||
- `tests/node/verify_gmoccapy_xyzac_trt_parity.mjs` 增加 `boat-xyzac.ngc` machine-file 运行断言,确认第 12 行快速移动保持 `Z=5`。
|
||||
- `tests/node/verify_machine_file_staging.mjs` 更新为接受 machine-file TP planner samples,确认 planner runtime ready。
|
||||
- `tests/node/verify_full_execution_boundary.mjs` 增加 gmoccapy 风格 machine-file 边界断言,确认程序执行 ready 与 remap runtime ready 可以独立表达。
|
||||
|
||||
9. 实际运行与验证命令:
|
||||
- 执行 `node --check tools/collect-linuxcnc-web-parity.mjs`,通过。
|
||||
- 执行 `node --check tests/node/verify_gmoccapy_xyzac_trt_parity.mjs`,通过。
|
||||
- 执行 `node --check tests/node/verify_linuxcnc_interpreter_runtime.mjs`,通过。
|
||||
- 执行 `node tests/node/verify_linuxcnc_interpreter_runtime.mjs`,输出 `linuxcnc_interpreter_runtime_smoke=ok`。
|
||||
- 执行 `node tests/node/verify_gmoccapy_xyzac_trt_parity.mjs`,输出 `gmoccapy_xyzac_trt_parity_smoke=ok`。
|
||||
- 执行 `node tests/node/verify_real_linuxcnc_5axis_program_cases.mjs`,输出 `real_linuxcnc_5axis_program_cases_smoke=ok`。
|
||||
- 执行 `node tests/node/verify_machine_file_staging.mjs`,输出 `machine_file_staging_smoke=ok`。
|
||||
- 执行 `node tests/node/verify_full_execution_boundary.mjs`,输出 `full_execution_boundary_smoke=ok`。
|
||||
- 执行 `git diff --check` 检查本轮相关文件,无 whitespace error。
|
||||
|
||||
10. 中间失败与处理:
|
||||
- `verify_machine_file_staging.mjs` 曾因旧预期 `plannerRuntimeReady=false` 失败;实际 Web runtime 已产生 TP samples,因此更新测试为 `plannerRuntimeReady=true` 并验证通过。
|
||||
- 一次只读 JSON 抽查命令因 shell 展开 JavaScript 模板字符串导致 `bad substitution`,随后改用字符串拼接重新读取,结果正常。
|
||||
- 初版 `lineExecution` 只覆盖运动行,不满足“每行 G 代码执行过程”;已改为全程序行覆盖。
|
||||
- 初版全行 `lineExecution` 对 Web 第 0 条运动的 `firstMotionIndex/lastMotionIndex` 显示为 `null`;已使用数组序号作为 fallback 并重新生成 JSON。
|
||||
|
||||
11. 最终 JSON 结果:
|
||||
- 运行 `node tools/collect-linuxcnc-web-parity.mjs --out working_run/linuxcnc-web-parity`。
|
||||
- 输出目录:`/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/working_run/linuxcnc-web-parity`。
|
||||
- `impeller-7bl-xyzac.ngc`:
|
||||
- native motion count:4492。
|
||||
- Web motion count:4492。
|
||||
- mismatch count:0。
|
||||
- maxAxisDelta:0。
|
||||
- Web executed path samples:27571。
|
||||
- `boat-xyzac.ngc`:
|
||||
- native motion count:1833。
|
||||
- Web motion count:1833。
|
||||
- mismatch count:0。
|
||||
- maxAxisDelta:0。
|
||||
- Web executed path samples:27777。
|
||||
- 全行执行记录确认:
|
||||
- `impeller` JSON:program lines 4509,lineExecution 4509。
|
||||
- `boat` JSON:program lines 1880,lineExecution 1880。
|
||||
- 抽查 `boat-xyzac.ngc`:
|
||||
- 第 9 行 motion,Z=0。
|
||||
- 第 10 行 motion,Z=5。
|
||||
- 第 11 行 `T1 M6` 为 `no-motion`。
|
||||
- 第 12 行 motion,X=-49.65,Y=-23.015,Z=5。
|
||||
|
||||
12. 生成文件:
|
||||
- `working_run/linuxcnc-web-parity/index.json`
|
||||
- `working_run/linuxcnc-web-parity/linuxcnc-native-impeller-7bl-xyzac.json`
|
||||
- `working_run/linuxcnc-web-parity/web-runtime-impeller-7bl-xyzac.json`
|
||||
- `working_run/linuxcnc-web-parity/comparison-impeller-7bl-xyzac.json`
|
||||
- `working_run/linuxcnc-web-parity/linuxcnc-native-boat-xyzac.json`
|
||||
- `working_run/linuxcnc-web-parity/web-runtime-boat-xyzac.json`
|
||||
- `working_run/linuxcnc-web-parity/comparison-boat-xyzac.json`
|
||||
|
||||
13. 本轮相关改动文件:
|
||||
- `/home/meswork/cnc_wams/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_minimal_runtime.cpp`
|
||||
- `/home/meswork/cnc_wams/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_interp_wasm.cpp`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/app/src/runtime/linuxcnc-interpreter-runtime.js`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/app/src/runtime/full-execution-boundary.js`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/tests/node/verify_linuxcnc_interpreter_runtime.mjs`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/tests/node/verify_gmoccapy_xyzac_trt_parity.mjs`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/tests/node/verify_machine_file_staging.mjs`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/tests/node/verify_full_execution_boundary.mjs`
|
||||
- `/home/meswork/cnc_wams/web-rtcp-5axis-sim-plan/tools/collect-linuxcnc-web-parity.mjs`
|
||||
|
||||
14. 当前边界说明:
|
||||
- native JSON 使用 LinuxCNC 源树 `rs274` 在 gmoccapy XYZAC-TRT 配置下的真实 canonical 输出作为可重复基准。
|
||||
- Web JSON 使用 WASM interpreter machine-file runtime 产出的 canonical motion,并使用 LinuxCNC TP WASM samples 作为执行路径。
|
||||
- gmoccapy Python M6/M61 remap 在 WASM 中仍诊断为未完整 ready,例如 `fiveaxis_remaps_ready=0`;本轮没有伪造该状态,而是将其作为诊断保留。
|
||||
- 程序实际执行、路径生成与 native canonical 对比已经通过;完整 GUI/task/HAL 级 gmoccapy 自动化仍是后续独立边界。
|
||||
|
||||
Reference in New Issue
Block a user