Change work offset values in a Pure Python remap w/o self.execute()

More
09 Feb 2023 16:52 #264150 by Aciera
I'm working on a pure python remap for G68.2 and affiliated Gcodes and I have fallen down the 'yield INTERP_EXECUTE_FINISH' hole.
I needed 'yield INTERP_EXECUTE_FINISH' because I have to wait for a joint move to finish before I can continue with replacing the active work offset values (ie G54 or whatever is active). The line I used for this was
'self.execute("G10 L2 P0 X%f Y%f Z%f " % (P[0],P[1],P[2]) ,lineno())'
with P holding the new offset values.
Now however I cannot use any 'self.execute(...)' because of the preceeding 'yield INTERP_EXECUTE_FINISH'.  So I came up with this to write the new offset values directly into the numbered parameters:
    # get which offset is active (g54=1 .. g59.3=9)
    active_offset = int(self.params[5220])
    # set the relevant parameter numbers that hold the active offset values
    # (G54_x: #5221, G55_x:#[5221+20], G56_x:#[5221+40] ....)
    work_offset_x = (active_offset-1)*20 + 5221
    work_offset_y = work_offset_x + 1
    work_offset_z = work_offset_x + 2

    self.params[work_offset_x] = P[0]
    self.params[work_offset_y] = P[1]
    self.params[work_offset_z] = P[2]

This works and it writes the values into the parameters but they aren't actually read and used unless  I reload them with an mdi command like 'G54' which I can't do from the remap because I can't use 'self.execute(..)'.
So if anybody knows of a way to do this from a remap without using 'self.execute(..)' let me know please.

Warning: Spoiler!

Please Log in or Create an account to join the conversation.

More
09 Feb 2023 17:09 #264154 by Aciera
Ok, never mind I just found it:

emccanon.SET_G5X_OFFSET(0, P[0], P[1], P[2], 0,0,0,0,0,0)
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
10 Feb 2023 15:25 #264227 by Aciera
Just an update in case somebody comes across this in the future as there are some odd thing with this:
1.
emccanon.SET_G5X_OFFSET(0, P[0], P[1], P[2], 0,0,0,0,0,0)
With index '0' seems to write to G53 and the axis DRO is then stuck at G53 
A 'G53 X0Y0Z0' ignores the new values and uses the old offset (x100y0z0 in my case)
 

2.
emccanon.SET_G5X_OFFSET(1, P[0], P[1], P[2], 0,0,0,0,0,0)
With index '1' seems to write to G54 just fine but also doesn't seem to update G53 properly.
So a 'G53 G0 X0 Y0 Z0' will ignore the offset-change with the above emccanon.SET_G5X_OFFSET(...)
 

If anybody has an idea I could get this to work please let me know.

This is the code I'm using:

Warning: Spoiler!
 
Attachments:

Please Log in or Create an account to join the conversation.

More
11 Feb 2023 08:14 #264276 by cmorley
AFAIU G53 should be set by homing and never be changed - that is the machines base offsets.

emccanon.SET_G5X_OFFSET(0, P[0], P[1], P[2], 0,0,0,0,0,0) index '0' could very well be 'set the current user system' - that is what it does in the higher gcode level. But that is not reliable in gcode programs as read-ahead can mess it up.

Please Log in or Create an account to join the conversation.

More
11 Feb 2023 10:31 - 11 Feb 2023 10:35 #264284 by Aciera

AFAIU G53 should be set by homing and never be changed - that is the machines base offsets.

For some reason I used to think that 'G93 x0y0z0' would take the machine to the position where all joint positions are zero.

emccanon.SET_G5X_OFFSET(0, P[0], P[1], P[2], 0,0,0,0,0,0) index '0' could very well be 'set the current user system' - that is what it does in the higher gcode level.

It seems a bit odd, neither here nor there:
Attachments:
Last edit: 11 Feb 2023 10:35 by Aciera.

Please Log in or Create an account to join the conversation.

More
11 Feb 2023 10:39 #264285 by Aciera
I start the config, home the machine and in MDI I set G54 and command to go to machine home:
g10 l2 p0 x100 y100 z100 a0 b0
g53 g0 x0 y0 z0
Nothing moves since we are already in home position and the DRO (as expected) reads:
 

Now I call a G69.9 remap that looks like this:
Warning: Spoiler!


and the DRO changes to this:
 

then do an MDI call to go to machine home position: g53 g0 x0 y0 z0
and I get this:
 

and a follow MDI command: g54 g0 x0 y0 z0
gives me this:
 

l don't get it.

Anyway I decided to leave that alone and I manged to do the offset transformation before calling 'yield INTERP_EXECUTE_FINISH' so I could use 'self.execute(..)'
Attachments:

Please Log in or Create an account to join the conversation.

More
20 Feb 2023 22:50 #264913 by andypugh
I think that it is probably better to use emccanon commands in general.

Rather than self.execute("G53 G0...") try using emccanon.STRAIGHT_TRAVERSE()
github.com/LinuxCNC/linuxcnc/blob/master...l_intf/canon.hh#L245

Reading through the code in interp_convert.cc it seems like G53 is achieved by subtracting all the offsets from the commanded position and making the move in program coordinates, but I am not entirely clear about that.

Please Log in or Create an account to join the conversation.

Time to create page: 0.512 seconds
Powered by Kunena Forum