Contact me: hankecnc@gmail.com

轴:在预览未在空间中“接地”的程序时做得更好 #185

推推 grbl 3年前 (2023-01-29) 384次浏览
打开
jepler 打开了这个问题 2016 年 10 月 21 日 · 0 条评论
打开

轴:在预览未在空间中“接地”的程序时做得更好#185

jepler 打开了这个问题 2016 年 10 月 21 日 · 0 条评论

注释

轴:在预览未在空间中“接地”的程序时做得更好 #185
成员

充其量我们一直在谈论导致 AXIS 虚假警告程序可能超出机器软限制的零件程序。

一类问题是由零件程序引起的,这些零件程序不是以一组准备 G0 运动开始的,这些运动将控制点带到相对于坐标系原点的固定位置,例如以运动开始的零件程序G1(因此没有轴在第一次切割之前处于确定位置),或者开始G0 X- Y- / G1 Z...(以便 3+ 轴中只有 2 个在第一次切割之前处于确定位置),或者开始G91 G0 X- Y- Z-(以便指定所有轴字母,但因为移动是相对它仍然没有建立绝对位置)或者G38.2 X- Y- Z-一个G0 X- Y- / G38.2 Z-或多个轴仅由探测移动的结果建立。

为了使用更好的术语,我称这些程序为“未接地”,并且我编写了一个小型独立程序,它似乎可以很好地确定程序是否接地。

对于未接地的程序,我们将 (A) 需要从当前位置而不是坐标系开始生成预览,并且 (B) 在加载此类程序并且用户慢跑时向用户显示警告,预览可能过时了。(与触发后自动加载不同,任何慢跑结束后加载都过于重量级而不可行,因此警告可能是一个更好的主意)

import gcode
import sys
from rs274.interpret import Translated, ArcsToSegmentsMixin

class FirstMove(Exception):
    def __init__(self, coords, is_probe):
        Exception.__init__(self, "<FirstMove coords=%s is_probe=%s>"
                            % (coords, is_probe))
        self.coords = coords
        self.is_probe = is_probe

class GroundedCanon(Translated, ArcsToSegmentsMixin):
    def comment(*args): pass
    def next_line(*args): pass
    def set_g5x_offset(*args): pass
    def set_g92_offset(*args): pass
    def set_xy_rotation(*args): pass
    def get_external_angular_units(self): return 1.0
    def get_external_length_units(self): return 1.0
    def set_plane(*args): pass
    def get_axis_mask(self): return 7
    def get_tool(self, tool):
        return tool, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0
    def set_feed_rate(self, rate): pass
    def user_defined_function(self, m, p, q): pass

    def straight_traverse(self, *coords): pass
    def straight_feed(self, *coords):
        raise FirstMove(coords, True)
    def straight_probe(self, *coords):
        raise FirstMove(coords, False)

def get_first_traverse(filename, origin):
    canon = GroundedCanon()
    canon.parameter_file = "/dev/null"
    try:
        result, seq = gcode.parse(filename, canon, "", "", "", origin)
    except FirstMove as e:
        print origin, e
        return e.coords, e.is_probe
    else:
        return (0.0,) * 9, False

def is_grounded(filename, axes=(0,1,2)):
    s = set()
    for idx in axes:
        origin = tuple(1 if idx == i else 0 for i in range(9))
        s.add(get_first_traverse(filename, origin))
    print >>sys.stderr, filename, len(s), s
    return len(s) == 1

if __name__ == '__main__':
    for fn in sys.argv[1:]:
        print "%s:0: %s" % (fn, "grounded" if is_grounded(fn) else "ungrounded")

这也取决于对 gcodemodule 的一个小改动

diff --git a/src/emc/rs274ngc/gcodemodule.cc b/src/emc/rs274ngc/gcodemodule.cc
index c4e9382..1788b73 100644
--- a/src/emc/rs274ngc/gcodemodule.cc
+++ b/src/emc/rs274ngc/gcodemodule.cc
@@ -687,7 +687,12 @@ static PyObject *parse_file(PyObject *self, PyObject *args) {
     int error_line_offset = 0;
     struct timeval t0, t1;
     int wait = 1;
-    if(!PyArg_ParseTuple(args, "sO|sss", &f, &callback, &unitcode, &initcode, &interpname))
+
+    _pos_x = _pos_y = _pos_z = _pos_a = _pos_b = _pos_c = 0;
+    _pos_u = _pos_v = _pos_w = 0;
+
+    if(!PyArg_ParseTuple(args, "sO|sss(ddddddddd)", &f, &callback, &unitcode, &initcode, &interpname,
+            &_pos_x, &_pos_y, &_pos_z, &_pos_a, &_pos_b, &_pos_c, &_pos_u, &_pos_v, &_pos_w))
         return NULL;

     if(pinterp) {
@@ -708,9 +713,6 @@ static PyObject *parse_file(PyObject *self, PyObject *args) {
     interp_error = 0;
     last_sequence_number = -1;

-    _pos_x = _pos_y = _pos_z = _pos_a = _pos_b = _pos_c = 0;
-    _pos_u = _pos_v = _pos_w = 0;
-
     interp_new.init();
     interp_new.open(f);

免费注册 在 GitHub 上加入此对话。已有帐户? 登录评论
标签
还没有
项目

还没有

发展

没有分支机构或拉取请求

1名参加者
轴:在预览未在空间中“接地”的程序时做得更好 #185

喜欢 (0)