SwitchKins - Remap execute can't work

More
17 Dec 2021 09:28 #229280 by nhanpham
Hi all,

I am using switckins for my scara robot.
I'm writing a remap for G0.

I'm working in JOINT mode.
The remap was just executed when had X,Y change.
When X,Y-axis position doesn't change and Z change then the remap code doesn't work. (Z-axis didn't move to any position ).

My ini config remap:

[RS274NGC]
 PARAMETER_FILE = scara.var
    USER_M_PATH = ./mcodes
SUBROUTINE_PATH = ./remap_subs
       FEATURES = 8
          REMAP = G0.2  modalgroup=1 argspec=xyzcf  epilog=cycle_epilog python=g01testskins


My Remap:

def g01testskins(self, **words):
    pos={'x':0,'y':0,'z':0,'c':0}
    fcmd =""
    hasF = False
    try:
        cmd = {'x':"",'y':"",'z':"",'c':"",'f':""}
        typeGcode = "g0"
        for name in cmd:
            if name == "f":
                if name in words:
                    typeGcode = "g1"
                    cmd[name] = "F{} ".format(words[name])     
            elif name in words:
                pos[name] = float(words[name])
                cmd[name] = "{}{} ".format(name,words[name])
                statusKin = 1
            else: 
                pos[name]  = float(hal.get_value("axis."+name+".pos-cmd")) 
        gcodecmd="G53 %s X%.4fY%.4fZ%.4f C %.4f %s "%(typeGcode, pos ,pos ,pos ,pos, cmd["f"])
        print("M438 test ", gcodecmd , "in ",time.time())
        self.execute(gcodecmd ,lineno())
        yield interpreter.INTERP_EXECUTE_FINISH
    except Exception as e:
        self.set_errormsg(e)
        return INTERP_ERROR
    return INTERP_OK


After I got the result:

M438 test  G53 g1 X34.7745Y-77.1625Z1.5400 C -0.0020 F300.0   in  1639732421.5478294 
M438 test  G53 g1 X34.7745Y-77.1625Z5.5400 C -0.0020 F300.0   in  1639732421.5878732
M438 test  G53 g1 X34.7745Y-77.1625Z-2.0000 C -0.0020 F300.0   in  1639732421.627927
M438 test  G53 g1 X34.7745Y-77.1625Z3.4000 C -0.0020 F300.0   in  1639732421.6779833
M438 test  G53 g1 X34.7745Y-77.1625Z0.0000 C -0.0020 F300.0   in  1639732421.7280483
 


My gcode test:

;Begin
G21
G0.2 X34.7745 Y-77.1625 Z3.8100 C-0.0020 F300.0 
G0.2  X34.7745 Y-77.1625 Z1.5400 C-0.0020 F300.0
G0.2  X34.7745 Y-77.1625 Z5.5400 C-0.0020 F300.0
G0.2 X34.7745 Y-77.1625 Z-2.00 C-0.0020 F300.0
G0.2  X34.7745 Y-77.1625 Z3.400 C-0.0020 F300.0
G0.2  X34.7745 Y-77.1625 Z0.00 C-0.0020 F300.0
M30


The Z-axis didn't move to any position.

If i change the X,Y-Axis position then Gcode works OK. 

can you help me check it?
 

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

More
21 Dec 2021 21:58 #229663 by andypugh
Am I right in thinking that the problem is not that the remap isn't remapping, but that the remap code itself is not having the expected result?

Does anything happen in the cycle_epilog? I recall reading earlier that a pure-python remap shouldn't use prolog and epilog, but that's not the problem.

Shouldn't
gcodecmd="G53 %s X%.4fY%.4fZ%.4f C %.4f %s "%(typeGcode, pos ,pos ,pos ,pos, cmd["f"])
be
gcodecmd="G53 %s X%.4fY%.4fZ%.4f C %.4f %s "%(typeGcode, pos[x] ,pos[y] ,pos[z] ,pos[c], cmd["f"])
?

Rather than send the non-moved axes to their existing position, it would be better simply to not have them in the final command.

You can probably simplify the code by starting off with a command string of "G53 " and then appending the other axis commands as they are parsed. Leaving out any non-moved axes.

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

More
23 Dec 2021 04:09 #229789 by nhanpham
hi,

sorry for my mistake when i copy. My code : 
gcodecmd="G53 %s X%.4fY%.4fZ%.4f C %.4f %s "%(typeGcode, pos[x] ,pos[y] ,pos[z] ,pos[c], cmd["f"])
My remap code works OK in MDI mode.
In AUTO mode, it's working ok in WORLD (M439) mode. But with the joint model (M438), the z-axis don't move when x,z axis pos don't have any change.

I tried to remove yield INTERP_EXECUTE_FINISH in python remap. And it helped me move the z-axis in joint mode.
but I don't know why the remap code doesn't work in joint mode.

 
   
gcodecmd="G53 %s X%.4fY%.4fZ%.4f C %.4f %s "%(typeGcode, pos['x'] ,pos['y'] ,pos['z'] ,pos['c'], cmd["f"])        
self.execute(gcodecmd)        
#yield INTERP_EXECUTE_FINISH

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

More
23 Dec 2021 04:21 - 23 Dec 2021 04:32 #229790 by nhanpham
This error just occurs when I use JOINT mode in AUTO mode.

- When I remove "yield INTERP_EXECUTE_FINISH" in my remap



- When I don't remove "yield INTERP_EXECUTE_FINISH" in my remap

Last edit: 23 Dec 2021 04:32 by nhanpham.

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

More
24 Dec 2021 00:15 #229839 by andypugh
Do you actually use "Joint mode" or are you using a kinematics that makes Axis mode behave like joint mode?

I think it is the latter, in that LinuxCNC only runs the kinematics code in Axis (world) mode. I don't know if this helps, but it might be useful to understand the issues.

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

More
24 Dec 2021 00:57 #229844 by nhanpham
ah, I'm using a kinematics of switchkins that makes Axis mode behave like joint mode.

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

Time to create page: 0.089 seconds
Powered by Kunena Forum