LinuxCNC: Aktuelle Position inklusive Offset mit Python ermitteln
In unserem vorherigen Beispiel LinuxCNC: Aktuelle Position mit Python ermitteln haben wir gezeigt, wie man stat.actual_position verwendet, um die aktuelle Position in Maschinenkoordinaten über LinuxCNCs Python-API zu ermitteln.
get_current_position_with_offset.py
#!/usr/bin/env python2.7
import linuxcnc
stat = linuxcnc.stat()
stat.poll()
x,y,z,a,b,c,u,v,w = stat.actual_position
# HINWEIS: ABCUVW ignorieren, da für meine Maschine nicht verwendet
# G5x-Offset abziehen
xo,yo,zo,ao,bo,co,uo,vo,wo = stat.g5x_offset
x -= xo
y -= yo
z -= zo
# Werkzeug-Offset abziehen
xo,yo,zo,ao,bo,co,uo,vo,wo = stat.tool_offset
x -= xo
y -= yo
z -= zo
# Offset-Koordinaten ausgeben
print(x,y,z)If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow