SwitchKins - Remap execute can't work
- nhanpham
- Topic Author
- Offline
- Senior Member
- Posts: 77
- Thank you received: 1
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.
- andypugh
- Offline
- Moderator
- Posts: 23170
- Thank you received: 4860
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"])
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.
- nhanpham
- Topic Author
- Offline
- Senior Member
- Posts: 77
- Thank you received: 1
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"])
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.
- nhanpham
- Topic Author
- Offline
- Senior Member
- Posts: 77
- Thank you received: 1
- When I remove "yield INTERP_EXECUTE_FINISH" in my remap
- When I don't remove "yield INTERP_EXECUTE_FINISH" in my remap
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23170
- Thank you received: 4860
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.
- nhanpham
- Topic Author
- Offline
- Senior Member
- Posts: 77
- Thank you received: 1
Please Log in or Create an account to join the conversation.