Chris,
   Thank you so much for your help!  It worked like a charm.

For the next person looking to obtain relative work coordinates in python,
here is the routine I derived from code in touchy's emc_interface.  Note,
self.s = linuxcnc.stat()


def absolute_to_relative(self,p):
      self.s.poll()

      x = p[0] - self.s.g5x_offset[0] - self.s.tool_offset[0]
      y = p[1] - self.s.g5x_offset[1] - self.s.tool_offset[1]
      z = p[2] - self.s.g5x_offset[2] - self.s.tool_offset[2]
      a = p[3] - self.s.g5x_offset[3] - self.s.tool_offset[3]
      b = p[4] - self.s.g5x_offset[4] - self.s.tool_offset[4]
      c = p[5] - self.s.g5x_offset[5] - self.s.tool_offset[5]
      u = p[6] - self.s.g5x_offset[6] - self.s.tool_offset[6]
      v = p[7] - self.s.g5x_offset[7] - self.s.tool_offset[7]
      w = p[8] - self.s.g5x_offset[8] - self.s.tool_offset[8]

      if self.s.rotation_xy != 0:
         t = math.radians(-self.s.rotation_xy)
         xr = x * math.cos(t) - y * math.sin(t)
         yr = x * math.sin(t) + y * math.cos(t)
         x = xr
         y = yr

      x -= self.s.g92_offset[0]
      y -= self.s.g92_offset[1]
      z -= self.s.g92_offset[2]
      a -= self.s.g92_offset[3]
      b -= self.s.g92_offset[4]
      c -= self.s.g92_offset[5]
      u -= self.s.g92_offset[6]
      v -= self.s.g92_offset[7]
      w -= self.s.g92_offset[8]

      return (x, y, z, a, b, c, u, v, w)


On Sat, Sep 20, 2014 at 1:19 PM, Chris Radek <ch...@timeguy.com> wrote:

> On Sat, Sep 20, 2014 at 12:28:46PM -0400, Kip Shaffer wrote:
> > When rotation_xy is 0 (and tool_offset is all zeros) the following is
> true:
> >
> >              Work position = actual_position - g92_offset - g5x_offset
> >
> > However, when rotation_xy is not zero, a rotation has to be applied.  The
> > question is where?
>
> This is tricky to get right!
>
> Tool offsets don't rotate
> G5x offsets don't rotate
> G92 offsets DO rotate
> Don't forget wrapped rotaries
> Don't forget units
>
> The canonical code for this is what AXIS uses: see glcanon.py around
> line 1265
>
> and in fact you can see this very clearly in AXIS if you mess with
> the offsets and rotation, and see what the preview does.  It
> represents each offset with a labeled line from the old to the new
> origin.  You can see that the g92 line rotates (within the G5x
> system) but the g5x line doesn't.
>
> You can find equivalent code in touchy's emc_interface.py around
> line 300
>
> Start with unoffset position
> subtract tool length
> subtract g5x offset
> rotate x,y (negative direction)
> subtract g92 offset
> for each rotary, if it's wrapped, adjust mod 360
> adjust units for presentation to user, if necessary, for xyz and uvw
>
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.  Video for Nerds.  Stuff that Matters.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>
------------------------------------------------------------------------------
Slashdot TV.  Video for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to