数控系统仿真软件,从linuxcnc移植过来的。主要程序的功能,必须直接来源于linuxcnc的源程序。不要自己编写。这是一条铁的纪律。持续推进
结论:已新增直接调用 LinuxCNC tpAddLine/tpRunCycle 的多段队列验证,覆盖两段线性运动排队、执行完成、队列清空和终点到达,并通过 native probes 全量验证。
This commit is contained in:
@@ -28,6 +28,9 @@ double axis_acc_limit(int axis)
|
|||||||
|
|
||||||
void init_motion_state()
|
void init_motion_state()
|
||||||
{
|
{
|
||||||
|
status = {};
|
||||||
|
config = {};
|
||||||
|
|
||||||
config.numJoints = 3;
|
config.numJoints = 3;
|
||||||
config.numSpindles = 1;
|
config.numSpindles = 1;
|
||||||
config.numDIO = 4;
|
config.numDIO = 4;
|
||||||
@@ -61,6 +64,13 @@ void init_motion_state()
|
|||||||
axis_acc_limit);
|
axis_acc_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pose_near(EmcPose const &actual, EmcPose const &expected)
|
||||||
|
{
|
||||||
|
return std::fabs(actual.tran.x - expected.tran.x) < 1e-9 &&
|
||||||
|
std::fabs(actual.tran.y - expected.tran.y) < 1e-9 &&
|
||||||
|
std::fabs(actual.tran.z - expected.tran.z) < 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
void run_linear_probe()
|
void run_linear_probe()
|
||||||
{
|
{
|
||||||
init_motion_state();
|
init_motion_state();
|
||||||
@@ -171,10 +181,7 @@ void run_arc_probe()
|
|||||||
|
|
||||||
EmcPose final_pos{};
|
EmcPose final_pos{};
|
||||||
const int get_pos_rc = tpGetPos(&tp, &final_pos);
|
const int get_pos_rc = tpGetPos(&tp, &final_pos);
|
||||||
const int near_end =
|
const int near_end = pose_near(final_pos, 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_create=" << create_rc << "\n";
|
||||||
std::cout << "tp_arc_set_cycle_time=" << set_cycle_rc << "\n";
|
std::cout << "tp_arc_set_cycle_time=" << set_cycle_rc << "\n";
|
||||||
@@ -196,6 +203,90 @@ void run_arc_probe()
|
|||||||
<< final_pos.tran.z << "\n";
|
<< final_pos.tran.z << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run_queued_lines_probe()
|
||||||
|
{
|
||||||
|
init_motion_state();
|
||||||
|
|
||||||
|
TP_STRUCT tp{};
|
||||||
|
EmcPose start{};
|
||||||
|
EmcPose end1{};
|
||||||
|
EmcPose end2{};
|
||||||
|
struct state_tag_t tag {};
|
||||||
|
|
||||||
|
end1.tran.x = 1.0;
|
||||||
|
end2.tran.x = 1.0;
|
||||||
|
end2.tran.y = 1.0;
|
||||||
|
|
||||||
|
const int create_rc = tpCreate(&tp, TP_DEFAULT_QUEUE_SIZE, 3);
|
||||||
|
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_line1_rc = tpAddLine(
|
||||||
|
&tp,
|
||||||
|
end1,
|
||||||
|
EMC_MOTION_TYPE_FEED,
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
10.0,
|
||||||
|
100.0,
|
||||||
|
status.enables_new,
|
||||||
|
0,
|
||||||
|
-1,
|
||||||
|
tag);
|
||||||
|
const int depth_after_line1 = tpQueueDepth(&tp);
|
||||||
|
const int add_line2_rc = tpAddLine(
|
||||||
|
&tp,
|
||||||
|
end2,
|
||||||
|
EMC_MOTION_TYPE_FEED,
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
10.0,
|
||||||
|
100.0,
|
||||||
|
status.enables_new,
|
||||||
|
0,
|
||||||
|
-1,
|
||||||
|
tag);
|
||||||
|
const int depth_after_line2 = tpQueueDepth(&tp);
|
||||||
|
|
||||||
|
int cycle_rc = 0;
|
||||||
|
int cycles = 0;
|
||||||
|
for (; cycles < 20000 && !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 = pose_near(final_pos, end2);
|
||||||
|
|
||||||
|
std::cout << "tp_queue_create=" << create_rc << "\n";
|
||||||
|
std::cout << "tp_queue_set_cycle_time=" << set_cycle_rc << "\n";
|
||||||
|
std::cout << "tp_queue_set_pos=" << set_pos_rc << "\n";
|
||||||
|
std::cout << "tp_queue_set_vmax=" << set_vmax_rc << "\n";
|
||||||
|
std::cout << "tp_queue_set_vlimit=" << set_vlimit_rc << "\n";
|
||||||
|
std::cout << "tp_queue_set_amax=" << set_amax_rc << "\n";
|
||||||
|
std::cout << "tp_queue_set_term_cond=" << set_term_rc << "\n";
|
||||||
|
std::cout << "tp_queue_add_line1=" << add_line1_rc << "\n";
|
||||||
|
std::cout << "tp_queue_depth_after_line1=" << depth_after_line1 << "\n";
|
||||||
|
std::cout << "tp_queue_add_line2=" << add_line2_rc << "\n";
|
||||||
|
std::cout << "tp_queue_depth_after_line2=" << depth_after_line2 << "\n";
|
||||||
|
std::cout << "tp_queue_cycle_rc=" << cycle_rc << "\n";
|
||||||
|
std::cout << "tp_queue_cycles=" << cycles << "\n";
|
||||||
|
std::cout << "tp_queue_get_pos=" << get_pos_rc << "\n";
|
||||||
|
std::cout << "tp_done_after_queued_lines=" << tpIsDone(&tp) << "\n";
|
||||||
|
std::cout << "tp_queue_final_depth=" << tpQueueDepth(&tp) << "\n";
|
||||||
|
std::cout << "tp_queue_final_pos_near_end=" << near_end << "\n";
|
||||||
|
std::cout << "tp_queue_final_pos="
|
||||||
|
<< final_pos.tran.x << ","
|
||||||
|
<< final_pos.tran.y << ","
|
||||||
|
<< final_pos.tran.z << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@@ -217,5 +308,6 @@ int main()
|
|||||||
std::cout << "pose_xyz=" << pose.tran.x << "," << pose.tran.y << "," << pose.tran.z << "\n";
|
std::cout << "pose_xyz=" << pose.tran.x << "," << pose.tran.y << "," << pose.tran.z << "\n";
|
||||||
run_linear_probe();
|
run_linear_probe();
|
||||||
run_arc_probe();
|
run_arc_probe();
|
||||||
|
run_queued_lines_probe();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,13 @@ grep -Fq "tp_final_pos=1,0,0" "$TP_API_STDOUT"
|
|||||||
grep -Fq "tp_add_circle=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_done_after_arc=1" "$TP_API_STDOUT"
|
||||||
grep -Fq "tp_arc_final_pos_near_end=1" "$TP_API_STDOUT"
|
grep -Fq "tp_arc_final_pos_near_end=1" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_queue_add_line1=0" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_queue_depth_after_line1=1" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_queue_add_line2=0" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_queue_depth_after_line2=2" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_done_after_queued_lines=1" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_queue_final_depth=0" "$TP_API_STDOUT"
|
||||||
|
grep -Fq "tp_queue_final_pos_near_end=1" "$TP_API_STDOUT"
|
||||||
|
|
||||||
check_fixture_output() {
|
check_fixture_output() {
|
||||||
local fixture="$1"
|
local fixture="$1"
|
||||||
|
|||||||
Reference in New Issue
Block a user