- LinuxCNC
- General LinuxCNC Questions
- [solved] Python Remap: How to access current a,b and c positions?
[solved] Python Remap: How to access current a,b and c positions?
- Aciera
- Topic Author
- Offline
- Administrator
Less
More
- Posts: 4033
- Thank you received: 1741
01 Mar 2020 16:19 - 07 Mar 2020 07:59 #158898
by Aciera
[solved] Python Remap: How to access current a,b and c positions? was created by Aciera
I'd like to do a remap for a 6-axis robot.
I'm using this code
old_x = self.current_x
old_y = self.current_y
old_z = self.current_z
which works. But
old_a = self.current_a
old_b = self.current_b
old_c = self.current_c
does not. Giving 'attributeError: ' Interp' object has no attribute ' current_a'
same for b and c.
How do I acces the current a,b and c positions?
I'm using this code
Warning: Spoiler!
import sys
import traceback
from math import sin,cos
from interpreter import *
from emccanon import MESSAGE, SET_MOTION_OUTPUT_BIT, CLEAR_MOTION_OUTPUT_BIT,SET_AUX_OUTPUT_BIT,CLEAR_AUX_OUTPUT_BIT
from util import lineno, call_pydevd
throw_exceptions = 1 # raises InterpreterException if execute() or read() fail
def g912(self, **words):
MESSAGE("x: '%s'" % (self.current_x))
for key in words:
MESSAGE("word '%s' = %f" % (key, words[key]))
if words.has_key('p'):
MESSAGE("the P word was present")
c = self.blocks[self.remap_level]
dx = c.x_number if c.x_flag else 0
dy = c.y_number if c.y_flag else 0
dz = c.z_number if c.z_flag else 0
da = c.a_number if c.a_flag else 0
db = c.b_number if c.b_flag else 0
dc = c.c_number if c.c_flag else 0
old_x = self.current_x
old_y = self.current_y
old_z = self.current_z
old_a = self.a
old_b = 0
old_c = 0
x = old_x + dx
y = old_y + dy
z = old_z + dz
a = old_a + da
b = old_b + db
c = old_c + dc
MESSAGE("comment on this line: '%s'" % (self.blocks[self.remap_level].comment))
self.execute("G0 X%f Y%f Z%f" % (x,y,z),lineno())
return INTERP_OK
import traceback
from math import sin,cos
from interpreter import *
from emccanon import MESSAGE, SET_MOTION_OUTPUT_BIT, CLEAR_MOTION_OUTPUT_BIT,SET_AUX_OUTPUT_BIT,CLEAR_AUX_OUTPUT_BIT
from util import lineno, call_pydevd
throw_exceptions = 1 # raises InterpreterException if execute() or read() fail
def g912(self, **words):
MESSAGE("x: '%s'" % (self.current_x))
for key in words:
MESSAGE("word '%s' = %f" % (key, words[key]))
if words.has_key('p'):
MESSAGE("the P word was present")
c = self.blocks[self.remap_level]
dx = c.x_number if c.x_flag else 0
dy = c.y_number if c.y_flag else 0
dz = c.z_number if c.z_flag else 0
da = c.a_number if c.a_flag else 0
db = c.b_number if c.b_flag else 0
dc = c.c_number if c.c_flag else 0
old_x = self.current_x
old_y = self.current_y
old_z = self.current_z
old_a = self.a
old_b = 0
old_c = 0
x = old_x + dx
y = old_y + dy
z = old_z + dz
a = old_a + da
b = old_b + db
c = old_c + dc
MESSAGE("comment on this line: '%s'" % (self.blocks[self.remap_level].comment))
self.execute("G0 X%f Y%f Z%f" % (x,y,z),lineno())
return INTERP_OK
old_x = self.current_x
old_y = self.current_y
old_z = self.current_z
which works. But
old_a = self.current_a
old_b = self.current_b
old_c = self.current_c
does not. Giving 'attributeError: ' Interp' object has no attribute ' current_a'
same for b and c.
How do I acces the current a,b and c positions?
Last edit: 07 Mar 2020 07:59 by Aciera.
Please Log in or Create an account to join the conversation.
- thang
- Offline
- Elite Member
Less
More
- Posts: 196
- Thank you received: 11
02 Mar 2020 02:09 #158927
by thang
Replied by thang on topic Python Remap: How to access current a,b and c positions?
Try AA_current instead of current_a.
The following user(s) said Thank You: Aciera
Please Log in or Create an account to join the conversation.
- Aciera
- Topic Author
- Offline
- Administrator
Less
More
- Posts: 4033
- Thank you received: 1741
02 Mar 2020 06:26 #158942
by Aciera
Replied by Aciera on topic Python Remap: How to access current a,b and c positions?
Thanks thang!
I wonder where this sudden change of pattern comes from. Is there a documentation for this? I feel like I've looked just about everywhere but nothing worked.
I wonder where this sudden change of pattern comes from. Is there a documentation for this? I feel like I've looked just about everywhere but nothing worked.
Please Log in or Create an account to join the conversation.
- thang
- Offline
- Elite Member
Less
More
- Posts: 196
- Thank you received: 11
02 Mar 2020 06:45 #158946
by thang
Replied by thang on topic Python Remap: How to access current a,b and c positions?
maybe here:https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/rs274ngc/interpmodule.cc
The following user(s) said Thank You: Aciera
Please Log in or Create an account to join the conversation.
- LinuxCNC
- General LinuxCNC Questions
- [solved] Python Remap: How to access current a,b and c positions?
Time to create page: 0.053 seconds