修正 LinuxCNC NURBS 平面映射

This commit is contained in:
cnc
2026-05-24 21:52:21 +08:00
parent b4861fd618
commit efc92d0380
3 changed files with 48 additions and 10 deletions

View File

@@ -96,6 +96,27 @@ const CncSimPose &current_position() {
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) {
if (std::getenv("CNC_SIM_TRACE_CANON")) {
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) {
return;
}
for (const auto &point : points) {
CncSimPose end = active_sink->position();
end.x = point.NURBS_X;
end.y = point.NURBS_Y;
active_sink->straight_feed(lineno, end);
active_sink->straight_feed(lineno, nurbs_plane_point_to_pose(point, plane));
}
}
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) {
return;
}
for (const auto &point : points) {
CncSimPose end = active_sink->position();
end.x = point.NURBS_X;
end.y = point.NURBS_Y;
active_sink->straight_feed(lineno, end);
active_sink->straight_feed(lineno, nurbs_plane_point_to_pose(point, plane));
}
}