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.
Time to create page: 0.190 seconds
Powered by Kunena Forum