修正 LinuxCNC NURBS 平面映射
This commit is contained in:
@@ -96,6 +96,27 @@ const CncSimPose ¤t_position() {
|
|||||||
return active_sink ? active_sink->position() : zero;
|
return active_sink ? active_sink->position() : zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename NurbsPoint>
|
||||||
|
CncSimPose nurbs_plane_point_to_pose(const NurbsPoint &point, CANON_PLANE plane) {
|
||||||
|
CncSimPose end = current_position();
|
||||||
|
switch (plane) {
|
||||||
|
case CANON_PLANE::YZ:
|
||||||
|
end.y = point.NURBS_X;
|
||||||
|
end.z = point.NURBS_Y;
|
||||||
|
break;
|
||||||
|
case CANON_PLANE::XZ:
|
||||||
|
end.x = point.NURBS_Y;
|
||||||
|
end.z = point.NURBS_X;
|
||||||
|
break;
|
||||||
|
case CANON_PLANE::XY:
|
||||||
|
default:
|
||||||
|
end.x = point.NURBS_X;
|
||||||
|
end.y = point.NURBS_Y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
void trace_call(const char *name) {
|
void trace_call(const char *name) {
|
||||||
if (std::getenv("CNC_SIM_TRACE_CANON")) {
|
if (std::getenv("CNC_SIM_TRACE_CANON")) {
|
||||||
std::fprintf(stderr, "canon:%s\n", name);
|
std::fprintf(stderr, "canon:%s\n", name);
|
||||||
@@ -385,27 +406,21 @@ void STOP_SPEED_FEED_SYNCH() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NURBS_G5_FEED(int lineno, const std::vector<NURBS_CONTROL_POINT> &points, unsigned int, CANON_PLANE) {
|
void NURBS_G5_FEED(int lineno, const std::vector<NURBS_CONTROL_POINT> &points, unsigned int, CANON_PLANE plane) {
|
||||||
if (!active_sink) {
|
if (!active_sink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const auto &point : points) {
|
for (const auto &point : points) {
|
||||||
CncSimPose end = active_sink->position();
|
active_sink->straight_feed(lineno, nurbs_plane_point_to_pose(point, plane));
|
||||||
end.x = point.NURBS_X;
|
|
||||||
end.y = point.NURBS_Y;
|
|
||||||
active_sink->straight_feed(lineno, end);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NURBS_G6_FEED(int lineno, const std::vector<NURBS_G6_CONTROL_POINT> &points, unsigned int, double, int, CANON_PLANE) {
|
void NURBS_G6_FEED(int lineno, const std::vector<NURBS_G6_CONTROL_POINT> &points, unsigned int, double, int, CANON_PLANE plane) {
|
||||||
if (!active_sink) {
|
if (!active_sink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const auto &point : points) {
|
for (const auto &point : points) {
|
||||||
CncSimPose end = active_sink->position();
|
active_sink->straight_feed(lineno, nurbs_plane_point_to_pose(point, plane));
|
||||||
end.x = point.NURBS_X;
|
|
||||||
end.y = point.NURBS_Y;
|
|
||||||
active_sink->straight_feed(lineno, end);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -472,6 +472,10 @@ cp "$base_var_file" "$var_file"
|
|||||||
CNC_SIM_RS274_VAR="$var_file" \
|
CNC_SIM_RS274_VAR="$var_file" \
|
||||||
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g52_offset.ngc \
|
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g52_offset.ngc \
|
||||||
>/tmp/cnc_sim_linuxcnc_source_g52_offset.json
|
>/tmp/cnc_sim_linuxcnc_source_g52_offset.json
|
||||||
|
cp "$base_var_file" "$var_file"
|
||||||
|
CNC_SIM_RS274_VAR="$var_file" \
|
||||||
|
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_g52_xz_nurbs.ngc \
|
||||||
|
>/tmp/cnc_sim_linuxcnc_source_g52_xz_nurbs.json
|
||||||
|
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
@@ -2026,6 +2030,17 @@ if g52_states != expected_g52_states:
|
|||||||
raise SystemExit(f"unexpected source-linked G52 shared offset sequence: {g52_states!r}")
|
raise SystemExit(f"unexpected source-linked G52 shared offset sequence: {g52_states!r}")
|
||||||
if not any(event["type"] == "program-end" and event["line"] == 7 for event in g52_offset):
|
if not any(event["type"] == "program-end" and event["line"] == 7 for event in g52_offset):
|
||||||
raise SystemExit("missing source-linked G52 offset program end line number")
|
raise SystemExit("missing source-linked G52 offset program end line number")
|
||||||
|
|
||||||
|
g52_xz_nurbs = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_g52_xz_nurbs.json").read_text())
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["plane"] == 18 and
|
||||||
|
event["end"]["x"] == 3 and
|
||||||
|
event["end"]["y"] == 0 and
|
||||||
|
event["end"]["z"] == 3
|
||||||
|
for event in g52_xz_nurbs
|
||||||
|
):
|
||||||
|
raise SystemExit("missing source-linked G18/XZ NURBS endpoint mapped to X/Z axes")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)"
|
echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)"
|
||||||
@@ -2112,3 +2127,4 @@ echo "dumped /tmp/cnc_sim_linuxcnc_source_coordinate_p0.json"
|
|||||||
echo "dumped /tmp/cnc_sim_linuxcnc_source_coordinate_select_all.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_coordinate_select_all.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_source_g92_restore.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_g92_restore.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_source_g52_offset.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_g52_offset.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_g52_xz_nurbs.json"
|
||||||
|
|||||||
7
tests/gcode/linuxcnc_g52_xz_nurbs.ngc
Normal file
7
tests/gcode/linuxcnc_g52_xz_nurbs.ngc
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
G21 G90 G18
|
||||||
|
F100
|
||||||
|
G5.2 X1 Z1 P1
|
||||||
|
G5.2 X2 Z2 P1
|
||||||
|
G5.2 X3 Z3 P1
|
||||||
|
G5.3
|
||||||
|
M2
|
||||||
Reference in New Issue
Block a user