From 6892e083cc5194c601468a3a74ee9f022259510b Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sun, 7 Jun 2026 07:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8E=A7=E7=B3=BB=E7=BB=9F=E4=BB=BF?= =?UTF-8?q?=E7=9C=9F=E8=BD=AF=E4=BB=B6=EF=BC=8C=E4=BB=8Elinuxcnc=E7=A7=BB?= =?UTF-8?q?=E6=A4=8D=E8=BF=87=E6=9D=A5=E7=9A=84=E3=80=82=E4=B8=BB=E8=A6=81?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E7=9B=B4=E6=8E=A5=E6=9D=A5=E6=BA=90=E4=BA=8Elinuxcnc?= =?UTF-8?q?=E7=9A=84=E6=BA=90=E7=A8=8B=E5=BA=8F=E3=80=82=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=BC=96=E5=86=99=E3=80=82=E8=BF=99=E6=98=AF?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E9=93=81=E7=9A=84=E7=BA=AA=E5=BE=8B=E3=80=82?= =?UTF-8?q?=E6=8C=81=E7=BB=AD=E6=8E=A8=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:已在 TP native probe 中新增直接调用 LinuxCNC tpAddCircle/tpRunCycle 的圆弧运动验证,并通过 native probes 全量验证。 --- .../linuxcnc_wrap/linuxcnc_tp_api_probe.cpp | 75 +++++++++++++++++++ .../tests/native/verify_native_probes.sh | 3 + 2 files changed, 78 insertions(+) diff --git a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_tp_api_probe.cpp b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_tp_api_probe.cpp index 5ed9062..120476a 100644 --- a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_tp_api_probe.cpp +++ b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_tp_api_probe.cpp @@ -1,3 +1,4 @@ +#include #include #include "emc/motion/motion.h" @@ -122,6 +123,79 @@ void run_linear_probe() << final_pos.tran.z << "\n"; } +void run_arc_probe() +{ + init_motion_state(); + + TP_STRUCT tp{}; + EmcPose start{}; + EmcPose end{}; + PmCartesian center{}; + PmCartesian normal{}; + struct state_tag_t tag {}; + + start.tran.x = 1.0; + end.tran.y = 1.0; + normal.z = 1.0; + + const int create_rc = tpCreate(&tp, TP_DEFAULT_QUEUE_SIZE, 2); + const int set_cycle_rc = tpSetCycleTime(&tp, 0.001); + const int set_pos_rc = tpSetPos(&tp, &start); + const int set_vmax_rc = tpSetVmax(&tp, 1.0, 1.0); + const int set_vlimit_rc = tpSetVlimit(&tp, 1.0); + const int set_amax_rc = tpSetAmax(&tp, 10.0); + const int set_term_rc = tpSetTermCond(&tp, TC_TERM_COND_STOP, 0.0); + const int add_circle_rc = tpAddCircle( + &tp, + end, + center, + normal, + 0, + EMC_MOTION_TYPE_ARC, + 1.0, + 1.0, + 10.0, + 100.0, + status.enables_new, + 0, + tag); + + int cycle_rc = 0; + int cycles = 0; + for (; cycles < 10000 && !tpIsDone(&tp); ++cycles) { + cycle_rc = tpRunCycle(&tp, 1000000); + if (cycle_rc < 0) { + break; + } + } + + EmcPose final_pos{}; + const int get_pos_rc = tpGetPos(&tp, &final_pos); + const int near_end = + std::fabs(final_pos.tran.x - end.tran.x) < 1e-9 && + std::fabs(final_pos.tran.y - end.tran.y) < 1e-9 && + std::fabs(final_pos.tran.z - end.tran.z) < 1e-9; + + std::cout << "tp_arc_create=" << create_rc << "\n"; + std::cout << "tp_arc_set_cycle_time=" << set_cycle_rc << "\n"; + std::cout << "tp_arc_set_pos=" << set_pos_rc << "\n"; + std::cout << "tp_arc_set_vmax=" << set_vmax_rc << "\n"; + std::cout << "tp_arc_set_vlimit=" << set_vlimit_rc << "\n"; + std::cout << "tp_arc_set_amax=" << set_amax_rc << "\n"; + std::cout << "tp_arc_set_term_cond=" << set_term_rc << "\n"; + std::cout << "tp_add_circle=" << add_circle_rc << "\n"; + std::cout << "tp_arc_cycle_rc=" << cycle_rc << "\n"; + std::cout << "tp_arc_cycles=" << cycles << "\n"; + std::cout << "tp_arc_get_pos=" << get_pos_rc << "\n"; + std::cout << "tp_done_after_arc=" << tpIsDone(&tp) << "\n"; + std::cout << "tp_arc_queue_depth=" << tpQueueDepth(&tp) << "\n"; + std::cout << "tp_arc_final_pos_near_end=" << near_end << "\n"; + std::cout << "tp_arc_final_pos=" + << final_pos.tran.x << "," + << final_pos.tran.y << "," + << final_pos.tran.z << "\n"; +} + } // namespace int main() @@ -142,5 +216,6 @@ int main() std::cout << "tc_circular=" << TC_CIRCULAR << "\n"; std::cout << "pose_xyz=" << pose.tran.x << "," << pose.tran.y << "," << pose.tran.z << "\n"; run_linear_probe(); + run_arc_probe(); return 0; } diff --git a/wasm-port/tests/native/verify_native_probes.sh b/wasm-port/tests/native/verify_native_probes.sh index b300a3c..a24b6fa 100755 --- a/wasm-port/tests/native/verify_native_probes.sh +++ b/wasm-port/tests/native/verify_native_probes.sh @@ -95,6 +95,9 @@ grep -Fq "tp_set_cycle_time=0" "$TP_API_STDOUT" grep -Fq "tp_add_line=0" "$TP_API_STDOUT" grep -Fq "tp_done_after_line=1" "$TP_API_STDOUT" grep -Fq "tp_final_pos=1,0,0" "$TP_API_STDOUT" +grep -Fq "tp_add_circle=0" "$TP_API_STDOUT" +grep -Fq "tp_done_after_arc=1" "$TP_API_STDOUT" +grep -Fq "tp_arc_final_pos_near_end=1" "$TP_API_STDOUT" check_fixture_output() { local fixture="$1"