Hi,
Here is first working version of Arcs moved into C.
Please comment.
Alex.
Move Translate and ArcsSegments into C
From: Alexey Starikovskiy <[email protected]>
---
lib/python/rs274/__init__.py | 1
lib/python/rs274/glcanon.py | 33 ++-
lib/python/rs274/interpret.py | 99 ----------
nc_files/systems.ngc | 11 +
src/emc/rs274ngc/gcodemodule.cc | 325 +++++++++++++++++----------------
src/emc/usr_intf/axis/scripts/axis.py | 1
6 files changed, 194 insertions(+), 276 deletions(-)
diff --git a/lib/python/rs274/__init__.py b/lib/python/rs274/__init__.py
index 1f513f2..084bf19 100644
--- a/lib/python/rs274/__init__.py
+++ b/lib/python/rs274/__init__.py
@@ -15,4 +15,3 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from interpret import Translated, ArcsToSegmentsMixin
diff --git a/lib/python/rs274/glcanon.py b/lib/python/rs274/glcanon.py
index d28706a..93f5c33 100644
--- a/lib/python/rs274/glcanon.py
+++ b/lib/python/rs274/glcanon.py
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from rs274 import Translated, ArcsToSegmentsMixin, OpenGLTk
+from rs274 import OpenGLTk
from minigl import *
import math
import glnav
@@ -35,7 +35,7 @@ limiticon = array.array('B',
255, 255, 176, 0, 152, 0, 140, 0, 134, 0, 128, 0, 0, 0,
0, 0, 0, 0])
-class GLCanon(Translated, ArcsToSegmentsMixin):
+class GLCanon:
def __init__(self, colors, geometry):
# traverse list - [line number, [start position], [end position], [tlo x, tlo y, tlo z]]
self.traverse = []; self.traverse_append = self.traverse.append
@@ -50,6 +50,8 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
self.lo = (0,) * 9
self.first_move = True
self.offset_x = self.offset_y = self.offset_z = 0
+ self.offset_a = self.offset_b = self.offset_c = 0
+ self.offset_u = self.offset_v = self.offset_w = 0
self.geometry = geometry
self.min_extents = [9e99,9e99,9e99]
self.max_extents = [-9e99,-9e99,-9e99]
@@ -60,6 +62,7 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
self.xo = self.yo = self.zo = self.ao = self.bo = self.co = self.uo = self.vo = self.wo = 0
self.dwell_time = 0
self.suppress = 0
+ self.plane = 1
def comment(self, arg):
if arg.startswith("AXIS,"):
@@ -73,9 +76,11 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
def check_abort(self): pass
- def next_line(self, st):
- self.state = st
- self.lineno = self.state.sequence_number
+ def next_line(self, lineno):
+ self.lineno = lineno
+
+ def set_plane(self, plane):
+ self.plane = plane
def draw_lines(self, lines, for_selection, j=0):
return emc.draw_lines(self.geometry, lines, for_selection)
@@ -146,6 +151,9 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
def change_tool(self, arg):
self.first_move = True
+ def set_xy_rotation(self, theta):
+ self.rotation_xy = theta
+
def set_origin_offsets(self, offset_x, offset_y, offset_z, offset_a, offset_b, offset_c, offset_u, offset_v, offset_w):
self.offset_x = offset_x
self.offset_y = offset_y
@@ -159,7 +167,7 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
def straight_traverse(self, x,y,z, a,b,c, u, v, w):
if self.suppress > 0: return
- l = self.rotate_and_translate(x,y,z,a,b,c,u,v,w)
+ l = (x,y,z,a,b,c,u,v,w)
if not self.first_move:
self.traverse_append((self.lineno, self.lo, l, [self.xo, self.yo, self.zo]))
self.lo = l
@@ -167,7 +175,6 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
def rigid_tap(self, x, y, z):
if self.suppress > 0: return
self.first_move = False
- l = self.rotate_and_translate(x,y,z,0,0,0,0,0,0)[:3]
l += [self.lo[3], self.lo[4], self.lo[5],
self.lo[6], self.lo[7], self.lo[8]]
self.feed_append((self.lineno, self.lo, l, self.feedrate, [self.xo, self.yo, self.zo]))
@@ -175,13 +182,7 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
self.feed_append((self.lineno, l, self.lo, self.feedrate, [self.xo, self.yo, self.zo]))
def arc_feed(self, *args):
- if self.suppress > 0: return
self.first_move = False
- self.in_arc = True
- try:
- ArcsToSegmentsMixin.arc_feed(self, *args)
- finally:
- self.in_arc = False
def straight_arcsegment(self, x,y,z, a,b,c, u, v, w):
self.first_move = False
@@ -192,7 +193,7 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
def straight_feed(self, x,y,z, a,b,c, u, v, w):
if self.suppress > 0: return
self.first_move = False
- l = self.rotate_and_translate(x,y,z,a,b,c,u,v,w)
+ l = (x,y,z,a,b,c,u,v,w)
self.feed_append((self.lineno, self.lo, l, self.feedrate, [self.xo, self.yo, self.zo]))
self.lo = l
straight_probe = straight_feed
@@ -200,13 +201,13 @@ class GLCanon(Translated, ArcsToSegmentsMixin):
def user_defined_function(self, i, p, q):
if self.suppress > 0: return
color = self.colors['m1xx']
- self.dwells_append((self.lineno, color, self.lo[0], self.lo[1], self.lo[2], self.state.plane/10-17))
+ self.dwells_append((self.lineno, color, self.lo[0], self.lo[1], self.lo[2], self.plane - 1))
def dwell(self, arg):
if self.suppress > 0: return
self.dwell_time += arg
color = self.colors['dwell']
- self.dwells_append((self.lineno, color, self.lo[0], self.lo[1], self.lo[2], self.state.plane/10-17))
+ self.dwells_append((self.lineno, color, self.lo[0], self.lo[1], self.lo[2], self.plane - 1))
def highlight(self, lineno, geometry):
diff --git a/lib/python/rs274/interpret.py b/lib/python/rs274/interpret.py
index 7c0fb26..56d0f78 100644
--- a/lib/python/rs274/interpret.py
+++ b/lib/python/rs274/interpret.py
@@ -16,105 +16,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import math
-class Translated:
- offset_x = offset_y = offset_z = offset_a = offset_b = offset_c = 0
- rotation_xy = 0
- def rotate_and_translate(self, x,y,z,a,b,c,u,v,w):
- t = self.rotation_xy
- if t:
- t = math.radians(t)
- rotx = x * math.cos(t) - y * math.sin(t)
- y = x * math.sin(t) + y * math.cos(t)
- x = rotx
-
- return [x+self.offset_x, y+self.offset_y, z+self.offset_z,
- a+self.offset_a, b+self.offset_b, c+self.offset_c,
- u+self.offset_u, v+self.offset_v, w+self.offset_w]
-
- def straight_traverse(self, *args):
- self.straight_traverse_translated(*self.rotate_and_translate(*args))
- def straight_feed(self, *args):
- self.straight_feed_translated(*self.rotate_and_translate(*args))
- def set_origin_offsets(self, offset_x, offset_y, offset_z, offset_a, offset_b, offset_c, offset_u=None, offset_v=None, offset_w=None):
- self.offset_x = offset_x
- self.offset_y = offset_y
- self.offset_z = offset_z
- self.offset_a = offset_a
- self.offset_b = offset_b
- self.offset_c = offset_c
- self.offset_u = offset_u
- self.offset_v = offset_v
- self.offset_w = offset_w
- def set_xy_rotation(self, theta):
- self.rotation_xy = theta
-
-class ArcsToSegmentsMixin:
- plane = 1
-
- def set_plane(self, plane):
- self.plane = plane
-
- def arc_feed(self, x1, y1, cx, cy, rot, z1, a, b, c, u, v, w):
- if self.plane == 1:
- t = self.rotation_xy
- if t:
- t = math.radians(t)
- rotx = x1 * math.cos(t) - y1 * math.sin(t)
- roty = x1 * math.sin(t) + y1 * math.cos(t)
- x1 = rotx
- y1 = roty
- f = n = [x1+self.offset_x,y1+self.offset_y,z1+self.offset_z, a+self.offset_a, b+self.offset_b, c+self.offset_c, u+self.offset_u, v+self.offset_v, w+self.offset_w]
- if t:
- rotcx = cx * math.cos(t) - cy * math.sin(t)
- rotcy = cx * math.sin(t) + cy * math.cos(t)
- cx = rotcx
- cy = rotcy
- cx += self.offset_x
- cy += self.offset_y
- xyz = [0,1,2]
- elif self.plane == 3:
- f = n = [y1+self.offset_x,z1+self.offset_y,x1+self.offset_z, a+self.offset_a, b+self.offset_b, c+self.offset_c, u+self.offset_u, v+self.offset_v, w+self.offset_w]
- cx=cx+self.offset_z
- cy=cy+self.offset_x
- xyz = [2,0,1]
- else:
- f = n = [z1+self.offset_x,x1+self.offset_y,y1+self.offset_z, a+self.offset_a, b+self.offset_b, c+self.offset_c, u+self.offset_u, v+self.offset_v, w+self.offset_w]
- cx=cx+self.offset_y
- cy=cy+self.offset_z
- xyz = [1,2,0]
- o = self.lo[:]
- theta1 = math.atan2(o[xyz[1]]-cy, o[xyz[0]]-cx)
- theta2 = math.atan2(n[xyz[1]]-cy, n[xyz[0]]-cx)
-
- # these ought to be the same, but go ahead and display them if not, for debugging
- rad1 = math.hypot(o[xyz[0]]-cx, o[xyz[1]]-cy)
- rad2 = math.hypot(n[xyz[0]]-cx, n[xyz[1]]-cy)
-
- if rot < 0:
- if theta2 >= theta1: theta2 -= math.pi * 2
- else:
- if theta2 <= theta1: theta2 += math.pi * 2
-
- def interp(low, high):
- return low + (high-low) * i / steps
-
- steps = max(8, int(128 * abs(theta1 - theta2) / math.pi))
- p = [0] * 9
- for i in range(1, steps):
- theta = interp(theta1, theta2)
- rad = interp(rad1, rad2)
- p[xyz[0]] = math.cos(theta) * rad + cx
- p[xyz[1]] = math.sin(theta) * rad + cy
- p[xyz[2]] = interp(o[xyz[2]], n[xyz[2]])
- p[3] = interp(o[3], n[3])
- p[4] = interp(o[4], n[4])
- p[5] = interp(o[5], n[5])
- p[6] = interp(o[6], n[6])
- p[7] = interp(o[7], n[7])
- p[8] = interp(o[8], n[8])
- self.straight_arcsegment(*p)
- self.straight_arcsegment(*n)
-
class PrintCanon:
def set_origin_offsets(self, *args):
print "set_origin_offsets", args
diff --git a/nc_files/systems.ngc b/nc_files/systems.ngc
index 1594b66..6f49b61 100644
--- a/nc_files/systems.ngc
+++ b/nc_files/systems.ngc
@@ -1,7 +1,18 @@
G20
(font: /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBI.ttf)
(text: G54)
+G10 L2 P1 R30
+G10 L2 P2 R60
+G10 L2 P3 R90
+G10 L2 P4 R120
+G10 L2 P5 R150
+G10 L2 P6 R180
+G10 L2 P7 R210
+G10 L2 P8 R270
+G10 L2 P9 R300
+
G54
+
#1=0.1 (SafeHeight)
#2=0.01 (Depth of CUT)
#3=0.00015 (Scale)
diff --git a/src/emc/rs274ngc/gcodemodule.cc b/src/emc/rs274ngc/gcodemodule.cc
index 80d2671..43baf5b 100644
--- a/src/emc/rs274ngc/gcodemodule.cc
+++ b/src/emc/rs274ngc/gcodemodule.cc
@@ -27,137 +27,39 @@
char _parameter_file_name[LINELEN];
-
-/* This definition of offsetof avoids the g++ warning
- * 'invalid offsetof from non-POD type'.
- */
-#undef offsetof
-#define offsetof(T,x) (size_t)(-1+(char*)&(((T*)1)->x))
-
-
-static PyObject *int_array(int *arr, int sz) {
- PyObject *res = PyTuple_New(sz);
- for(int i = 0; i < sz; i++) {
- PyTuple_SET_ITEM(res, i, PyInt_FromLong(arr[i]));
- }
- return res;
-}
-
-typedef struct {
- PyObject_HEAD
- double settings[ACTIVE_SETTINGS];
- int gcodes[ACTIVE_G_CODES];
- int mcodes[ACTIVE_M_CODES];
-} LineCode;
-
-static PyObject *LineCode_gcodes(LineCode *l) {
- return int_array(l->gcodes, ACTIVE_G_CODES);
-}
-static PyObject *LineCode_mcodes(LineCode *l) {
- return int_array(l->mcodes, ACTIVE_M_CODES);
-}
-
-static PyGetSetDef LineCodeGetSet[] = {
- {"gcodes", (getter)LineCode_gcodes},
- {"mcodes", (getter)LineCode_mcodes},
- {NULL, NULL},
-};
-
-static PyMemberDef LineCodeMembers[] = {
- {"sequence_number", T_INT, offsetof(LineCode, gcodes[0]), READONLY},
-
- {"feed_rate", T_DOUBLE, offsetof(LineCode, settings[1]), READONLY},
- {"speed", T_DOUBLE, offsetof(LineCode, settings[2]), READONLY},
- {"motion_mode", T_INT, offsetof(LineCode, gcodes[1]), READONLY},
- {"block", T_INT, offsetof(LineCode, gcodes[2]), READONLY},
- {"plane", T_INT, offsetof(LineCode, gcodes[3]), READONLY},
- {"cutter_side", T_INT, offsetof(LineCode, gcodes[4]), READONLY},
- {"units", T_INT, offsetof(LineCode, gcodes[5]), READONLY},
- {"distance_mode", T_INT, offsetof(LineCode, gcodes[6]), READONLY},
- {"feed_mode", T_INT, offsetof(LineCode, gcodes[7]), READONLY},
- {"origin", T_INT, offsetof(LineCode, gcodes[8]), READONLY},
- {"tool_length_offset", T_INT, offsetof(LineCode, gcodes[9]), READONLY},
- {"retract_mode", T_INT, offsetof(LineCode, gcodes[10]), READONLY},
- {"path_mode", T_INT, offsetof(LineCode, gcodes[11]), READONLY},
-
- {"stopping", T_INT, offsetof(LineCode, mcodes[1]), READONLY},
- {"spindle", T_INT, offsetof(LineCode, mcodes[2]), READONLY},
- {"toolchange", T_INT, offsetof(LineCode, mcodes[3]), READONLY},
- {"mist", T_INT, offsetof(LineCode, mcodes[4]), READONLY},
- {"flood", T_INT, offsetof(LineCode, mcodes[5]), READONLY},
- {"overrides", T_INT, offsetof(LineCode, mcodes[6]), READONLY},
- {NULL}
-};
-
-static PyTypeObject LineCodeType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "gcode.linecode", /*tp_name*/
- sizeof(LineCode), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- LineCodeMembers, /*tp_members*/
- LineCodeGetSet, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- PyType_GenericNew, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
-};
-
static PyObject *callback;
static int interp_error;
static int last_sequence_number;
static bool metric;
static double _pos_x, _pos_y, _pos_z, _pos_a, _pos_b, _pos_c, _pos_u, _pos_v, _pos_w;
+static int plane = 1;
+static double offset[9] = {0};
+static double lo[9] = {0};
+static double rotation_xy = 0, rotation_sin = 0, rotation_cos = 1;
+
EmcPose tool_offset;
static Interp interp_new;
+static void rotate_and_translate(double p[9])
+{
+ if (rotation_xy) {
+ double rotx = p[0] * rotation_cos - p[1] * rotation_sin;
+ p[1] = p[0] * rotation_sin + p[0] * rotation_cos;
+ p[0] = rotx;
+ }
+ for (int i = 0; i < 9; ++i)
+ p[i] = p[i] + offset[i];
+}
+
static void maybe_new_line(int sequence_number=interp_new.sequence_number());
static void maybe_new_line(int sequence_number) {
if(interp_error) return;
if(sequence_number == last_sequence_number)
return;
- LineCode *new_line_code =
- (LineCode*)(PyObject_New(LineCode, &LineCodeType));
- interp_new.active_settings(new_line_code->settings);
- interp_new.active_g_codes(new_line_code->gcodes);
- interp_new.active_m_codes(new_line_code->mcodes);
- new_line_code->gcodes[0] = sequence_number;
last_sequence_number = sequence_number;
PyObject *result =
- PyObject_CallMethod(callback, "next_line", "O", new_line_code);
- Py_DECREF(new_line_code);
+ PyObject_CallMethod(callback, "next_line", "i", sequence_number);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
}
@@ -222,95 +124,190 @@ void SPLINE_FEED(double x1, double y1, double x2, double y2, double x3, double y
}
}
+#define max(a,b) (a)>(b)?(a):(b)
+
+inline double interp(double low, double high, double ratio) {
+ return low + (high - low) * ratio;
+}
+
void ARC_FEED(int line_number,
- double first_end, double second_end, double first_axis,
- double second_axis, int rotation, double axis_end_point,
- double a_position, double b_position, double c_position,
- double u_position, double v_position, double w_position) {
- // XXX: set _pos_*
- if(metric) {
- first_end /= 25.4;
- second_end /= 25.4;
- first_axis /= 25.4;
- second_axis /= 25.4;
- axis_end_point /= 25.4;
- u_position /= 25.4;
- v_position /= 25.4;
- w_position /= 25.4;
+ double e1, double e2, double c1, double c2, int rot, double e3,
+ double a, double b, double c, double u, double v, double w) {
+ if (metric) {
+ e1 /= 25.4; e2 /= 25.4; c1 /= 25.4; c2 /= 25.4; e3 /= 25.4;
+ u /= 25.4; v /= 25.4; w /= 25.4;
}
maybe_new_line(line_number);
if(interp_error) return;
+ int xyz[3];
+ double n[9];
+ if (plane == 1) {
+ if (rotation_xy) {
+ double t = e1 * rotation_cos - e2 * rotation_sin;
+ e2 = e1 * rotation_sin + e2 * rotation_cos;
+ e1 = t;
+ t = c1 * rotation_cos - c2 * rotation_sin;
+ c2 = c1 * rotation_sin + c2 * rotation_cos;
+ c1 = t;
+ }
+ n[0] = e1 + offset[0];
+ n[1] = e2 + offset[1];
+ n[2] = e3 + offset[2];
+ n[3] = a + offset[3];
+ n[4] = b + offset[4];
+ n[5] = c + offset[5];
+ n[6] = u + offset[6];
+ n[7] = v + offset[7];
+ n[8] = w + offset[8];
+ c1 += offset[0];
+ c2 += offset[1];
+ xyz[0] = 0; xyz[1] = 1; xyz[2] = 2;
+ } else if (plane == 3) {
+ n[0] = e2 + offset[0];
+ n[1] = e3 + offset[1];
+ n[2] = e1 + offset[2];
+ n[3] = a + offset[3];
+ n[4] = b + offset[4];
+ n[5] = c + offset[5];
+ n[6] = u + offset[6];
+ n[7] = v + offset[7];
+ n[8] = w + offset[8];
+ c1 += offset[2];
+ c2 += offset[0];
+ xyz[0] = 2; xyz[1] = 0; xyz[2] = 1;
+ } else {
+ n[0] = e3 + offset[0];
+ n[1] = e1 + offset[1];
+ n[2] = e2 + offset[2];
+ n[3] = a + offset[3];
+ n[4] = b + offset[4];
+ n[5] = c + offset[5];
+ n[6] = u + offset[6];
+ n[7] = v + offset[7];
+ n[8] = w + offset[8];
+ c1 += offset[1];
+ c2 += offset[2];
+ xyz[0] = 1; xyz[1] = 2; xyz[2] = 0;
+ }
+ double theta1 = atan2(lo[xyz[1]] - c2, lo[xyz[0]] - c1);
+ double theta2 = atan2(n[xyz[1]]-c2, n[xyz[0]]-c1);
+
+ double rad = hypot(lo[xyz[0]] - c1, lo[xyz[1]] - c2);
+
+ if (rot < 0) {
+ if (theta2 >= theta1)
+ theta2 -= M_PI * 2;
+ } else {
+ if (theta2 <= theta1)
+ theta2 += M_PI * 2;
+ }
+
+ int steps = max(3, int(32 * abs(theta1 - theta2) / M_PI));
+ double p[9];
+ for (int i = 0; i < steps; ++i) {
+ double ratio = double(i)/steps;
+ double theta = interp(theta1, theta2, ratio);
+ p[xyz[0]] = cos(theta) * rad + c1;
+ p[xyz[1]] = sin(theta) * rad + c2;
+ p[xyz[2]] = interp(lo[xyz[2]], n[xyz[2]], ratio);
+ for (int j = 3; j < 9; ++j)
+ p[j] = interp(lo[j], n[j], ratio);
+ PyObject *result =
+ PyObject_CallMethod(callback, "straight_arcsegment", "fffffffff",
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]);
+ if(result == NULL) interp_error ++;
+ Py_XDECREF(result);
+ }
PyObject *result =
- PyObject_CallMethod(callback, "arc_feed", "ffffifffffff",
- first_end, second_end, first_axis, second_axis,
- rotation, axis_end_point,
- a_position, b_position, c_position,
- u_position, v_position, w_position);
+ PyObject_CallMethod(callback, "straight_arcsegment", "fffffffff",
+ n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8]);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
+ for (int i = 0; i < 9; ++i) lo[i] = p[i];
}
void STRAIGHT_FEED(int line_number,
double x, double y, double z,
double a, double b, double c,
- double u, double v, double w) {
- _pos_x=x; _pos_y=y; _pos_z=z;
+ double u, double v, double w)
+{
+ _pos_x=x; _pos_y=y; _pos_z=z;
_pos_a=a; _pos_b=b; _pos_c=c;
_pos_u=u; _pos_v=v; _pos_w=w;
- if(metric) { x /= 25.4; y /= 25.4; z /= 25.4; u /= 25.4; v /= 25.4; w /= 25.4; }
+
+ double p[9] = {x,y,z,a,b,c,u,v,w};
+ if (metric)
+ for (int i = 0; i < 9; ++i)
+ p[i] /= 25.4;
maybe_new_line(line_number);
if(interp_error) return;
+ rotate_and_translate(p);
PyObject *result =
PyObject_CallMethod(callback, "straight_feed", "fffffffff",
- x, y, z, a, b, c, u, v, w);
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
+ for (int i = 0; i < 9; ++i) lo[i] = p[i];
}
void STRAIGHT_TRAVERSE(int line_number,
double x, double y, double z,
double a, double b, double c,
- double u, double v, double w) {
- _pos_x=x; _pos_y=y; _pos_z=z;
+ double u, double v, double w)
+{
+ _pos_x=x; _pos_y=y; _pos_z=z;
_pos_a=a; _pos_b=b; _pos_c=c;
_pos_u=u; _pos_v=v; _pos_w=w;
- if(metric) { x /= 25.4; y /= 25.4; z /= 25.4; u /= 25.4; v /= 25.4; w /= 25.4; }
+
+ double p[9] = {x,y,z,a,b,c,u,v,w};
+ if (metric)
+ for (int i = 0; i < 9; ++i)
+ p[i] /= 25.4;
maybe_new_line(line_number);
if(interp_error) return;
+ rotate_and_translate(p);
PyObject *result =
PyObject_CallMethod(callback, "straight_traverse", "fffffffff",
- x, y, z, a, b, c, u, v, w);
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
+ for (int i = 0; i < 9; ++i) lo[i] = p[i];
}
void SET_ORIGIN_OFFSETS(double x, double y, double z,
double a, double b, double c,
double u, double v, double w) {
- if(metric) { x /= 25.4; y /= 25.4; z /= 25.4; u /= 25.4; v /= 25.4; w /= 25.4; }
+ if (metric) {
+ x /= 25.4; y /= 25.4; z /= 25.4; u /= 25.4; v /= 25.4; w /= 25.4;
+ }
+ offset[0] = x; offset[1] = y; offset[2] = z; offset[3] = a, offset[4] = b, offset[5] = c, offset[6] = u, offset[7] = v, offset[8] = w;
maybe_new_line();
- if(interp_error) return;
+ if (interp_error) return;
PyObject *result =
- PyObject_CallMethod(callback, "set_origin_offsets", "fffffffff",
- x, y, z, a, b, c, u, v, w);
+ PyObject_CallMethod(callback, "set_origin_offsets", "fffffffff",
+ x, y, z, a, b, c, u, v, w);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
}
void SET_XY_ROTATION(double t) {
+ rotation_xy = t * M_PI / 180;
+ rotation_sin = sin(rotation_xy);
+ rotation_cos = cos(rotation_xy);
maybe_new_line();
- if(interp_error) return;
- PyObject *result =
- PyObject_CallMethod(callback, "set_xy_rotation", "f", t);
+ PyObject *result = PyObject_CallMethod(callback, "set_xy_rotation", "f", t);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
+ if(interp_error) return;
};
void USE_LENGTH_UNITS(CANON_UNITS u) { metric = u == CANON_UNITS_MM; }
void SELECT_PLANE(CANON_PLANE pl) {
- maybe_new_line();
+ plane = pl;
+ maybe_new_line();
if(interp_error) return;
+
PyObject *result =
PyObject_CallMethod(callback, "set_plane", "i", pl);
if(result == NULL) interp_error ++;
@@ -401,17 +398,26 @@ void SET_TOOL_TABLE_ENTRY(int pocket, int toolno, EmcPose offset, double diamete
double frontangle, double backangle, int orientation) {
}
-void USE_TOOL_LENGTH_OFFSET(EmcPose offset) {
- tool_offset = offset;
+void USE_TOOL_LENGTH_OFFSET(EmcPose o) {
maybe_new_line();
if(interp_error) return;
if(metric) {
- offset.tran.x /= 25.4; offset.tran.y /= 25.4; offset.tran.z /= 25.4;
- offset.u /= 25.4; offset.v /= 25.4; offset.w /= 25.4; }
- PyObject *result = PyObject_CallMethod(callback, "tool_offset", "ddddddddd", offset.tran.x, offset.tran.y, offset.tran.z,
- offset.a, offset.b, offset.c, offset.u, offset.v, offset.w);
+ o.tran.x /= 25.4; o.tran.y /= 25.4; o.tran.z /= 25.4;
+ o.u /= 25.4; o.v /= 25.4; o.w /= 25.4; }
+ PyObject *result = PyObject_CallMethod(callback, "tool_offset", "ddddddddd", o.tran.x, o.tran.y, o.tran.z,
+ o.a, o.b, o.c, o.u, o.v, o.w);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
+ lo[0] -= tool_offset.tran.x - o.tran.x;
+ lo[1] -= tool_offset.tran.y - o.tran.y;
+ lo[2] -= tool_offset.tran.z - o.tran.z;
+ lo[3] -= tool_offset.a - o.a;
+ lo[4] -= tool_offset.b - o.b;
+ lo[5] -= tool_offset.c - o.c;
+ lo[6] -= tool_offset.u - o.u;
+ lo[7] -= tool_offset.v - o.v;
+ lo[8] -= tool_offset.w - o.w;
+ tool_offset = o;
}
void SET_FEED_REFERENCE(double reference) { }
@@ -488,11 +494,14 @@ void RIGID_TAP(int line_number,
if(metric) { x /= 25.4; y /= 25.4; z /= 25.4; }
maybe_new_line(line_number);
if(interp_error) return;
+ double p[9] = {x, y, z, 0, 0, 0, 0, 0, 0};
+ rotate_and_translate(p);
PyObject *result =
PyObject_CallMethod(callback, "rigid_tap", "fff",
- x, y, z);
+ p[0], p[1], p[2]);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
+ for (int i = 0; i < 3; ++i) lo[i] = p[i];
}
double GET_EXTERNAL_MOTION_CONTROL_TOLERANCE() { return 0.1; }
double GET_EXTERNAL_PROBE_POSITION_X() { return _pos_x; }
@@ -761,8 +770,6 @@ PyMODINIT_FUNC
initgcode(void) {
PyObject *m = Py_InitModule3("gcode", gcode_methods,
"Interface to EMC rs274ngc interpreter");
- PyType_Ready(&LineCodeType);
- PyModule_AddObject(m, "linecode", (PyObject*)&LineCodeType);
PyObject_SetAttrString(m, "MAX_ERROR", PyInt_FromLong(maxerror));
PyObject_SetAttrString(m, "MIN_ERROR",
PyInt_FromLong(INTERP_MIN_ERROR));
diff --git a/src/emc/usr_intf/axis/scripts/axis.py b/src/emc/usr_intf/axis/scripts/axis.py
index 107839b..a62d4d0 100755
--- a/src/emc/usr_intf/axis/scripts/axis.py
+++ b/src/emc/usr_intf/axis/scripts/axis.py
@@ -62,7 +62,6 @@ import gcode
import locale
import bwidget
from math import hypot, atan2, sin, cos, pi, sqrt
-from rs274 import ArcsToSegmentsMixin
import emc
from glnav import *
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers