- Configuring LinuxCNC
- Advanced Configuration
- Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
19 Mar 2017 23:44 - 20 Mar 2017 00:16 #89910
by bevins
We have been working on this all day, and cant get past the two issues as follows:
In a remap of M6 scenario, like the following in the linuxcnc.ini configuration file
[RS274NGC]
REMAP=M6 modalgroup=6 prolog=change_prolog python=change_remap epilog=change_epilog
In the change_remap function,
I try the following methods and in both, the Interpreter complains if the G-Code is invalid.
The G-Code in both statements are valid, and the Interpreter is not complaining
which means the interpreter accepts the command format per say. The only problem
is that nothing moves and it continues as if nothing was wrong ...
Ignoring a valid G-Code command without a warning / error message is what is
happening but that seems an error, we should at least get a warning no ?
But the main problem is why the interpreter is ignoring it in the first place.
The code is working firing up the change_remap function, I can even talk to
the Digital Output and Input sucessfully.
Issue #2
When I load a G-Code file in linuxcnc from the File open menu, if the file contains a T1 M6,
linuxcnc runs the remap right away without user interaction.
Opening a program, fires up the change_remap function ... Why ?
How can we protect from automatic execution of a G-Code program
In a remap of M6 scenario, like the following in the linuxcnc.ini configuration file
[RS274NGC]
REMAP=M6 modalgroup=6 prolog=change_prolog python=change_remap epilog=change_epilog
In the change_remap function,
I try the following methods and in both, the Interpreter complains if the G-Code is invalid.
def ok_for_mdi(self):
self.stat.poll()
return not self.stat.estop and self.stat.enabled and self.stat.homed and _
(self.stat.interp_state == self.cnc.INTERP_IDLE)
if self.ok_for_mdi():
self.command.mode(self.cnc.MODE_MDI)
self.command.wait_complete() # wait until mode switch executed
self.command.mdi("G1 G53 F%d X%f Y%f Z0.0" % (self.feedSpeed, posX, posY))
or
self.execute("G1 G53 F%d X%f Y%f" % (10, 20.0, -9.0))
The G-Code in both statements are valid, and the Interpreter is not complaining
which means the interpreter accepts the command format per say. The only problem
is that nothing moves and it continues as if nothing was wrong ...
Ignoring a valid G-Code command without a warning / error message is what is
happening but that seems an error, we should at least get a warning no ?
But the main problem is why the interpreter is ignoring it in the first place.
The code is working firing up the change_remap function, I can even talk to
the Digital Output and Input sucessfully.
Issue #2
When I load a G-Code file in linuxcnc from the File open menu, if the file contains a T1 M6,
linuxcnc runs the remap right away without user interaction.
Opening a program, fires up the change_remap function ... Why ?
How can we protect from automatic execution of a G-Code program
Warning: Spoiler!
%
G0 G17 G20 G90 G40 G49 G64 P0.001
T1 M6
G0 Z0.8000
G0 X0.0000 Y0.0000 M3 M8 S24000
G0X3.5392Y-3.7108Z0.2000
G1Z-0.1250F75.0
G1X3.6250Y-3.6250
X16.5000
X16.5858Y-3.7108
X16.5000Y-3.6250
X16.5858Y-3.5392
X16.5000Y-3.6250
X3.6250
X3.5392Y-3.5392
X3.6250Y-3.6250
X3.5392Y-3.7108
X3.2850Y-3.9650
X3.1192Y-4.1308
X3.2850Y-3.9650
X16.8400
X17.0058Y-4.1308
X16.8400Y-3.9650
Y-3.2850
X17.0058Y-3.1192
X16.8400Y-3.2850
X3.2850
X3.1192Y-3.1192
X3.2850Y-3.2850
Y-3.9650
X2.8650Y-4.3850
X2.6992Y-4.5508
X2.8650Y-4.3850
X17.2600
X17.4258Y-4.5508
X17.2600Y-4.3850
Y-2.8650
X17.4258Y-2.6992
X17.2600Y-2.8650
X2.8650
X2.6992Y-2.6992
X2.8650Y-2.8650
Y-4.3850
X2.4450Y-4.8050
X2.2792Y-4.9708
X2.4450Y-4.8050
X17.6800
X17.8458Y-4.9708
X17.6800Y-4.8050
Y-2.4450
X17.8458Y-2.2792
X17.6800Y-2.4450
X2.4450
X2.2792Y-2.2792
X2.4450Y-2.4450
Y-4.8050
X2.0250Y-5.2250
X1.8592Y-5.3908
X2.0250Y-5.2250
X18.1000
X18.2658Y-5.3908
X18.1000Y-5.2250
Y-2.0250
X18.2658Y-1.8592
X18.1000Y-2.0250
X2.0250
X1.8592Y-1.8592
X2.0250Y-2.0250
Y-5.2250
X1.6050Y-5.6450
X1.4392Y-5.8108
X1.6050Y-5.6450
X18.5200
X18.6858Y-5.8108
X18.5200Y-5.6450
Y-1.6050
X18.6858Y-1.4392
X18.5200Y-1.6050
X1.6050
X1.4392Y-1.4392
X1.6050Y-1.6050
Y-5.6450
X1.1850Y-6.0650
X18.9400
X19.1058Y-6.2308
X18.9400Y-6.0650
Y-1.1850
X19.1058Y-1.0192
X18.9400Y-1.1850
X1.1850
X1.0192Y-1.0192
X1.1850Y-1.1850
Y-6.0650
X1.0192Y-6.2308
X1.1850Y-6.0650
X0.7650Y-6.4850
X0.5992Y-6.6508
X0.7650Y-6.4850
X19.3600
X19.5258Y-6.6508
X19.3600Y-6.4850
Y-0.7650
X19.5258Y-0.5992
X19.3600Y-0.7650
X0.7650
X0.5992Y-0.5992
X0.7650Y-0.7650
Y-6.4850
X0.3450Y-6.9050
X0.1792Y-7.0708
X0.3450Y-6.9050
X19.7800
X19.9458Y-7.0708
X19.7800Y-6.9050
Y-0.3450
X19.9458Y-0.1792
X19.7800Y-0.3450
X0.3450
X0.1792Y-0.1792
X0.3450Y-0.3450
Y-6.9050
X-0.0750Y-7.3250
X20.2000
Y0.0750
X-0.0750
Y-7.3250
G0Z0.2000
G0Z0.8000
G0X0.0000Y0.0000
M2
%
G0 G17 G20 G90 G40 G49 G64 P0.001
T1 M6
G0 Z0.8000
G0 X0.0000 Y0.0000 M3 M8 S24000
G0X3.5392Y-3.7108Z0.2000
G1Z-0.1250F75.0
G1X3.6250Y-3.6250
X16.5000
X16.5858Y-3.7108
X16.5000Y-3.6250
X16.5858Y-3.5392
X16.5000Y-3.6250
X3.6250
X3.5392Y-3.5392
X3.6250Y-3.6250
X3.5392Y-3.7108
X3.2850Y-3.9650
X3.1192Y-4.1308
X3.2850Y-3.9650
X16.8400
X17.0058Y-4.1308
X16.8400Y-3.9650
Y-3.2850
X17.0058Y-3.1192
X16.8400Y-3.2850
X3.2850
X3.1192Y-3.1192
X3.2850Y-3.2850
Y-3.9650
X2.8650Y-4.3850
X2.6992Y-4.5508
X2.8650Y-4.3850
X17.2600
X17.4258Y-4.5508
X17.2600Y-4.3850
Y-2.8650
X17.4258Y-2.6992
X17.2600Y-2.8650
X2.8650
X2.6992Y-2.6992
X2.8650Y-2.8650
Y-4.3850
X2.4450Y-4.8050
X2.2792Y-4.9708
X2.4450Y-4.8050
X17.6800
X17.8458Y-4.9708
X17.6800Y-4.8050
Y-2.4450
X17.8458Y-2.2792
X17.6800Y-2.4450
X2.4450
X2.2792Y-2.2792
X2.4450Y-2.4450
Y-4.8050
X2.0250Y-5.2250
X1.8592Y-5.3908
X2.0250Y-5.2250
X18.1000
X18.2658Y-5.3908
X18.1000Y-5.2250
Y-2.0250
X18.2658Y-1.8592
X18.1000Y-2.0250
X2.0250
X1.8592Y-1.8592
X2.0250Y-2.0250
Y-5.2250
X1.6050Y-5.6450
X1.4392Y-5.8108
X1.6050Y-5.6450
X18.5200
X18.6858Y-5.8108
X18.5200Y-5.6450
Y-1.6050
X18.6858Y-1.4392
X18.5200Y-1.6050
X1.6050
X1.4392Y-1.4392
X1.6050Y-1.6050
Y-5.6450
X1.1850Y-6.0650
X18.9400
X19.1058Y-6.2308
X18.9400Y-6.0650
Y-1.1850
X19.1058Y-1.0192
X18.9400Y-1.1850
X1.1850
X1.0192Y-1.0192
X1.1850Y-1.1850
Y-6.0650
X1.0192Y-6.2308
X1.1850Y-6.0650
X0.7650Y-6.4850
X0.5992Y-6.6508
X0.7650Y-6.4850
X19.3600
X19.5258Y-6.6508
X19.3600Y-6.4850
Y-0.7650
X19.5258Y-0.5992
X19.3600Y-0.7650
X0.7650
X0.5992Y-0.5992
X0.7650Y-0.7650
Y-6.4850
X0.3450Y-6.9050
X0.1792Y-7.0708
X0.3450Y-6.9050
X19.7800
X19.9458Y-7.0708
X19.7800Y-6.9050
Y-0.3450
X19.9458Y-0.1792
X19.7800Y-0.3450
X0.3450
X0.1792Y-0.1792
X0.3450Y-0.3450
Y-6.9050
X-0.0750Y-7.3250
X20.2000
Y0.0750
X-0.0750
Y-7.3250
G0Z0.2000
G0Z0.8000
G0X0.0000Y0.0000
M2
%
Last edit: 20 Mar 2017 00:16 by bevins.
Please Log in or Create an account to join the conversation.
- Mike@CNCproCuts.com
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
20 Mar 2017 01:21 #89918
by Mike@CNCproCuts.com
Replied by Mike@CNCproCuts.com on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Also, when testing the stat.interp_state and stat.task_mode I get :
stat.interp_state == linuxcnc.INTERP_IDLE
stat.task_mode == linuxcnc.MODE_MANUAL manual ? should we be in MODE_AUTO ?
I understand the INTERP_IDLE but not the MODE_MANUAL ... being in an Automatic Tool Changing action ... It feels like a remnant of the Manual Tool Change ... something we forgot to remove or set ...
Is the a way a telling LinuxCNC that it will run an Automatic Tool Changer and not a Manual Tool Changer ?
stat.interp_state == linuxcnc.INTERP_IDLE
stat.task_mode == linuxcnc.MODE_MANUAL manual ? should we be in MODE_AUTO ?
I understand the INTERP_IDLE but not the MODE_MANUAL ... being in an Automatic Tool Changing action ... It feels like a remnant of the Manual Tool Change ... something we forgot to remove or set ...
Is the a way a telling LinuxCNC that it will run an Automatic Tool Changer and not a Manual Tool Changer ?
Please Log in or Create an account to join the conversation.
20 Mar 2017 01:30 - 20 Mar 2017 01:31 #89920
by bevins
I dont think you can run mdi commands while in auto. Dont know about self.execute.
I think it is something in the src that is not allowing the interpreter to execute the commands. Two instances ?
It clearly states you can run a full python toolchange in the docs but i am starting to believe it is not possible with the interpreter having to execute commands initiated from python.
Replied by bevins on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Also, when testing the stat.interp_state and stat.task_mode I get :
stat.interp_state == linuxcnc.INTERP_IDLE
stat.task_mode == linuxcnc.MODE_MANUAL manual ? should we be in MODE_AUTO ?
I understand the INTERP_IDLE but not the MODE_MANUAL ... being in an Automatic Tool Changing action ... It feels like a remnant of the Manual Tool Change ... something we forgot to remove or set ...
Is the a way a telling LinuxCNC that it will run an Automatic Tool Changer and not a Manual Tool Changer ?
I dont think you can run mdi commands while in auto. Dont know about self.execute.
I think it is something in the src that is not allowing the interpreter to execute the commands. Two instances ?
It clearly states you can run a full python toolchange in the docs but i am starting to believe it is not possible with the interpreter having to execute commands initiated from python.
Last edit: 20 Mar 2017 01:31 by bevins.
Please Log in or Create an account to join the conversation.
20 Mar 2017 16:49 - 20 Mar 2017 17:16 #89955
by bevins
Replied by bevins on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
This is from the documentation and it does not work. IT says in the docs for remapo section 3.3 it says:
This statement below (Directly from the docs) does not seem to be true and the above code does not work.
"The examples described so far can be found in configs/sim/axis/remap/getting-started with complete working configurations."
Granted we are remapping M6 but using the prolog and ipilog.
At this ppoint I dont know what to do other than throw in the towel and go with o-word subs, whcih is what I wanted to shy away from in the beginning.
I have found a thread in the users mailing list that discusses this exact same issue it seems, and was reponded to by a developer saying that it explicity cannot be done, but thats from 2014.. mailing list thread discussing same issue
We have over 1000 lines of code and 64 man hours in this to find out possibly it cannot be done. Its a bit dissapointing......
Advanced example: Remapped codes in pure Python
The interpreter and emccanon modules expose most of the Interpreter and some Canon internals, so many things which so far required coding in C/C+\+ can be now be done in Python.
The following example is based on the nc_files/involute.py script - but canned as a G-code with some parameter extraction and checking. It also demonstrates calling the interpreter recursively (see self.execute()).
Assuming a definition like so (NB: this does not use argspec):
REMAP=G88.1 modalgroup=1 py=involute
The involute function in python/remap.py listed below does all word extraction from the current block directly. Note that interpreter errors can be translated to Python exceptions. Remember this is readahead time - execution time errors cannot be trapped this way.
import sys
import traceback
from math import sin,cos
from interpreter import *
from emccanon import MESSAGE
from util import lineno, call_pydevd
# raises InterpreterException if execute() or read() fails
throw_exceptions = 1
def involute(self, **words):
""" remap function with raw access to Interpreter internals """
if self.debugmask & 0x20000000: call_pydevd() # USER2 debug flag
if equal(self.feed_rate,0.0):
return "feedrate > 0 required"
if equal(self.speed,0.0):
return "spindle speed > 0 required"
plunge = 0.1 # if Z word was given, plunge - with reduced feed
# inspect controlling block for relevant words
c = self.blocks[self.remap_level]
x0 = c.x_number if c.x_flag else 0
y0 = c.y_number if c.y_flag else 0
a = c.p_number if c.p_flag else 10
old_z = self.current_z
if self.debugmask & 0x10000000:
print "x0=%f y0=%f a=%f old_z=%f" % (x0,y0,a,old_z)
try:
#self.execute("G3456") # would raise InterpreterException
self.execute("G21",lineno())
self.execute("G64 P0.001",lineno())
self.execute("G0 X%f Y%f" % (x0,y0),lineno())
if c.z_flag:
feed = self.feed_rate
self.execute("F%f G1 Z%f" % (feed * plunge, c.z_number),lineno())
self.execute("F%f" % (feed),lineno())
for i in range(100):
t = i/10.
x = x0 + a * (cos(t) + t * sin(t))
y = y0 + a * (sin(t) - t * cos(t))
self.execute("G1 X%f Y%f" % (x,y),lineno())
if c.z_flag: # retract to starting height
self.execute("G0 Z%f" % (old_z),lineno())
except InterpreterException,e:
msg = "%d: '%s' - %s" % (e.line_number,e.line_text, e.error_message)
return msg
return INTERP_OK
This statement below (Directly from the docs) does not seem to be true and the above code does not work.
"The examples described so far can be found in configs/sim/axis/remap/getting-started with complete working configurations."
Granted we are remapping M6 but using the prolog and ipilog.
At this ppoint I dont know what to do other than throw in the towel and go with o-word subs, whcih is what I wanted to shy away from in the beginning.
I have found a thread in the users mailing list that discusses this exact same issue it seems, and was reponded to by a developer saying that it explicity cannot be done, but thats from 2014.. mailing list thread discussing same issue
We have over 1000 lines of code and 64 man hours in this to find out possibly it cannot be done. Its a bit dissapointing......
Last edit: 20 Mar 2017 17:16 by bevins.
Please Log in or Create an account to join the conversation.
21 Mar 2017 16:47 - 21 Mar 2017 16:50 #90011
by andypugh
Replied by andypugh on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
The chap who would know is Michael Haberler, but you would have to contact him via machinekit.io. I don't think he is active here any more.
You definitely _can_ move axes with the emccanon interface inside a python remap.
github.com/LinuxCNC/linuxcnc/blob/af15a4...terp/pymove/oword.py
I did it in the remappped G71 lathe threading routines here:
You definitely _can_ move axes with the emccanon interface inside a python remap.
github.com/LinuxCNC/linuxcnc/blob/af15a4...terp/pymove/oword.py
I did it in the remappped G71 lathe threading routines here:
Last edit: 21 Mar 2017 16:50 by andypugh.
The following user(s) said Thank You: bevins
Please Log in or Create an account to join the conversation.
22 Mar 2017 13:32 #90070
by bevins
Thank you Andy....
I am able to move the axis in python code now.
It was errors on my part and I apologize if I came off arrogant. I was stressed and frustrated.
The interpretor was not ignoring us but rather doing exactly what I told it to do and at the speed I told it to go, which was 10IPM, which at glance you cant see it moving hardly at all.
So, back to getting this toolchanger working.
Replied by bevins on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
The chap who would know is Michael Haberler, but you would have to contact him via machinekit.io. I don't think he is active here any more.
You definitely _can_ move axes with the emccanon interface inside a python remap.
github.com/LinuxCNC/linuxcnc/blob/af15a4...terp/pymove/oword.py
I did it in the remappped G71 lathe threading routines here:
Thank you Andy....
I am able to move the axis in python code now.
It was errors on my part and I apologize if I came off arrogant. I was stressed and frustrated.
The interpretor was not ignoring us but rather doing exactly what I told it to do and at the speed I told it to go, which was 10IPM, which at glance you cant see it moving hardly at all.
So, back to getting this toolchanger working.
Please Log in or Create an account to join the conversation.
29 Sep 2017 18:43 #99636
by fras86
Replied by fras86 on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Hi Bob,
I am doing an M6 remap is pure python as well but I cannot get any motion commands to execute from within the python remap function. My goal is to do a normal manual tool change but when I click continue I want to do a TLO. I am also reading in tool change position and probe position from the INI file and that all works. My only issue is I cannot get g-code commands to execute while in the python remap function.
It appears that the motion commands are being stored in the queue and then when I exit the remap (either using return INTERP_OK or yield INTERP_EXECUTE_FINISH) the queued commands execute one after another.
I have tried putting everything into one function, tried grouping g-code commands into their own functions (both mid and self.execute) tried using return, tried using yield but the best I can do is have all the commands execute when I exit the remap. I have an ok_for_mid() function, and I test for preview task.
Would you be willing to share your remap.py script so I can see if I am just doing something stupid? I have read the manuals multiple times related to this and cannot figure out what I am missing. I have tried to make simple remap.py scripts that just execute a command like: self.execute("M3") or self.execute("G0 X10") but they only execute once I have exited the remap.
I would really appreciate any help!
Fraser
I am doing an M6 remap is pure python as well but I cannot get any motion commands to execute from within the python remap function. My goal is to do a normal manual tool change but when I click continue I want to do a TLO. I am also reading in tool change position and probe position from the INI file and that all works. My only issue is I cannot get g-code commands to execute while in the python remap function.
It appears that the motion commands are being stored in the queue and then when I exit the remap (either using return INTERP_OK or yield INTERP_EXECUTE_FINISH) the queued commands execute one after another.
I have tried putting everything into one function, tried grouping g-code commands into their own functions (both mid and self.execute) tried using return, tried using yield but the best I can do is have all the commands execute when I exit the remap. I have an ok_for_mid() function, and I test for preview task.
Would you be willing to share your remap.py script so I can see if I am just doing something stupid? I have read the manuals multiple times related to this and cannot figure out what I am missing. I have tried to make simple remap.py scripts that just execute a command like: self.execute("M3") or self.execute("G0 X10") but they only execute once I have exited the remap.
I would really appreciate any help!
Fraser
Please Log in or Create an account to join the conversation.
30 Sep 2017 02:53 - 30 Sep 2017 02:53 #99657
by bevins
Replied by bevins on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Are you checking whitch task is running?
You need to first thing in your remap function. Ill upload my remap file.
You need to first thing in your remap function. Ill upload my remap file.
Last edit: 30 Sep 2017 02:53 by bevins.
Please Log in or Create an account to join the conversation.
02 Oct 2017 11:08 #99763
by bevins
I would suggest trying to do a toolchange, not manual, but an automatic until you get it right so the interpreter is processing your commands.
It is very touch and go with the interpreter because there is little to no info or docs on it.
My remap I am using an xml class to do my settings, so just be aware of that. Other than that it should be straight forward.
Comment out your manual tool change in the hal and see if that changes anything.
The forum doesnt like .py files so I had to change it to hal extension.
Replied by bevins on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Hi Bob,
Would you be willing to share your remap.py script so I can see if I am just doing something stupid? I have read the manuals multiple times related to this and cannot figure out what I am missing. I have tried to make simple remap.py scripts that just execute a command like: self.execute("M3") or self.execute("G0 X10") but they only execute once I have exited the remap.
I would really appreciate any help!
Fraser
I would suggest trying to do a toolchange, not manual, but an automatic until you get it right so the interpreter is processing your commands.
It is very touch and go with the interpreter because there is little to no info or docs on it.
My remap I am using an xml class to do my settings, so just be aware of that. Other than that it should be straight forward.
Comment out your manual tool change in the hal and see if that changes anything.
The forum doesnt like .py files so I had to change it to hal extension.
Please Log in or Create an account to join the conversation.
02 Oct 2017 18:47 #99777
by fras86
Replied by fras86 on topic Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Thank you!
I'll play around with it and see if I can get some of it working so I can adapt it to what I am trying to do. It definitely seems like I am having issues with the interpreter!
I'll play around with it and see if I can get some of it working so I can adapt it to what I am trying to do. It definitely seems like I am having issues with the interpreter!
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Advanced Configuration
- Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
Time to create page: 0.093 seconds