Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1

More
19 Mar 2017 23:44 - 20 Mar 2017 00:16 #89910 by bevins
bevins created the topic: Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1
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.
    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! [ Click to expand ]
Attachments:
Last Edit: 20 Mar 2017 00:16 by bevins.
More
20 Mar 2017 01:21 #89918 by Mike@CNCproCuts.com
Mike@CNCproCuts.com replied the 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 ?
More
20 Mar 2017 01:30 - 20 Mar 2017 01:31 #89920 by bevins
bevins replied the topic: Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1

Mike@CNCproCuts.com wrote: 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.
More
20 Mar 2017 16:49 - 20 Mar 2017 17:16 #89955 by bevins
bevins replied the 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:
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.
More
21 Mar 2017 16:47 - 21 Mar 2017 16:50 #90011 by andypugh
andypugh replied the 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:
Last Edit: 21 Mar 2017 16:50 by andypugh.
The following user(s) said Thank You: bevins
More
22 Mar 2017 13:32 #90070 by bevins
bevins replied the topic: Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1

andypugh wrote: 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.
More
29 Sep 2017 18:43 #99636 by fras86
fras86 replied the 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
More
30 Sep 2017 02:53 - 30 Sep 2017 02:53 #99657 by bevins
bevins replied the 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.
Last Edit: 30 Sep 2017 02:53 by bevins.
More
02 Oct 2017 11:08 #99763 by bevins
bevins replied the topic: Interpreter ignoring axis move commands ina M6 remap 2.8.0-pre1

fras86 wrote: 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.
Attachments:
More
02 Oct 2017 18:47 #99777 by fras86
fras86 replied the 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!
Time to create page: 0.116 seconds
Powered by Kunena Forum