Import LinuxCNC source tree
This commit is contained in:
217
configs/sim/axis/remap/getting-started/demo.ini
Normal file
217
configs/sim/axis/remap/getting-started/demo.ini
Normal file
@@ -0,0 +1,217 @@
|
||||
[EMC]
|
||||
VERSION = 1.1
|
||||
MACHINE = getting-started:demo.ini
|
||||
# Debug level, 0 means no messages. See src/emc/nml_intf/debugflags.h for others
|
||||
DEBUG = 0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = axis
|
||||
OPEN_FILE= ./nc_files/examples.ngc
|
||||
CYCLE_TIME = 0.100
|
||||
HELP_FILE = doc/help.txt
|
||||
POSITION_OFFSET = RELATIVE
|
||||
POSITION_FEEDBACK = ACTUAL
|
||||
MAX_FEED_OVERRIDE = 1.2
|
||||
MAX_SPINDLE_OVERRIDE = 1.0
|
||||
MAX_LINEAR_VELOCITY = 1.2
|
||||
DEFAULT_LINEAR_VELOCITY = .25
|
||||
PROGRAM_PREFIX = ../../nc_files/
|
||||
INTRO_GRAPHIC = linuxcnc.gif
|
||||
INTRO_TIME = 5
|
||||
#EDITOR = geany
|
||||
TOOL_EDITOR = tooledit
|
||||
INCREMENTS = 1 in, 0.1 in, 10 mil, 1 mil, 1mm, .1mm, 1/8000 in
|
||||
|
||||
[FILTER]
|
||||
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
|
||||
PROGRAM_EXTENSION = .py Python Script
|
||||
png = image-to-gcode
|
||||
gif = image-to-gcode
|
||||
jpg = image-to-gcode
|
||||
py = python3
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = sim.var
|
||||
SUBROUTINE_PATH = nc_subroutines:../../nc_files/remap_lib/common_nc_subs
|
||||
LOG_LEVEL = 0
|
||||
|
||||
# generalized remapping of RS274NGC codes
|
||||
#-----------------------------------------
|
||||
# currently only unused M- and G-codes may be activated as per below, plus the
|
||||
# T,M6,M61,S and F codes.
|
||||
# G: currently supported modal group: 1
|
||||
# M:currently supported modal groups: 5,6,7,8,9,10
|
||||
# for T,S,F remaps the modal group is fixed and any modalgroup= option is ignored
|
||||
|
||||
|
||||
# An argument specification (keyword 'argspec') describes required and permitted words,
|
||||
# and preconditions for that code to execute.
|
||||
#
|
||||
# It consists of 0-n characters of the class [@A-KMNP-Za-kmnp-z^>] .
|
||||
#
|
||||
# parameter words:
|
||||
# an uppercase letter for each required parameter 'word'
|
||||
# a lowercase letter for each optional parameter 'word'
|
||||
#
|
||||
# Preconditions:
|
||||
# an '^' means: speed must be > 0
|
||||
# an '>' means: feed must be > 0
|
||||
#
|
||||
# if calling an NGC oword function (ngc= <funcname>), the parameters are passed
|
||||
# as local named parameters which are already set when the function starts
|
||||
# optional words are passed if set in the block, and may be tested for existence
|
||||
# by # EXISTS(#<..>) .
|
||||
#
|
||||
# example 1:
|
||||
REMAP= M400 modalgroup=10 argspec=Pq ngc=m400
|
||||
# see nc_subroutines/m400.ngc
|
||||
# to exercise, try:
|
||||
# M400
|
||||
# M400 P123
|
||||
# M400 P123 Q456
|
||||
# ---------------
|
||||
#
|
||||
# Example 2:
|
||||
#
|
||||
# Calling with traditional positioal parameter lists:
|
||||
#
|
||||
# To do so, add the '@' character to the argspec.
|
||||
# In this case, the arguments (required or optional) will be passed tradional-style
|
||||
#
|
||||
REMAP= M410 modalgroup=10 argspec=@Pq ngc=m410
|
||||
# see nc_subroutines/m410.ngc
|
||||
#
|
||||
# to exercise, try:
|
||||
# M410
|
||||
# M410 P123
|
||||
# M410 P123 Q456
|
||||
#
|
||||
# NB: you lose the capability to distinguish more than one optional parameter word!
|
||||
# since you can't tell whether Q was passed as 'Q0' or no Q word was set.
|
||||
#
|
||||
# -------------------------------------------------------------------------
|
||||
#
|
||||
# up to here you wouldn't need the PYTHON section to be defined since no
|
||||
# Python code was used.
|
||||
# Examples below refer to Python handlers and hence need the plugin configured.
|
||||
#
|
||||
# instead of calling an NGC procedure, we call the remap.g886() Python function:
|
||||
#
|
||||
REMAP= G88.6 modalgroup=1 argspec=XYZp py=g886
|
||||
# see python/remap.py function g886
|
||||
# to exercise, try:
|
||||
# g88.6 x1 y2 z3
|
||||
# g88.6 x1 y2 z3 p33 (a comment here)
|
||||
|
||||
# a more complex example
|
||||
# based on nc_files/involute.py example and can it as a G-code
|
||||
# all checking is done in the Python procedure by directly accessing interpreter internals
|
||||
#
|
||||
REMAP= G88.1 modalgroup=1 py=involute
|
||||
# see python/remap.py function involute
|
||||
#
|
||||
#
|
||||
# pin wiggling example - equivalent of M62
|
||||
# usgage : M462 P<pin-number> Q<0 or 1>
|
||||
REMAP= M462 modalgroup=10 argspec=PQ py=m462
|
||||
|
||||
# pin wiggling example - equivalent of M65
|
||||
# usgage : M465 P<pin-number> Q<0 or 1>
|
||||
REMAP= M465 modalgroup=10 argspec=PQ py=m465
|
||||
|
||||
# this is important - read nc_subroutines/on_abort.ngc
|
||||
ON_ABORT_COMMAND= O <on_abort> call
|
||||
|
||||
[EMCMOT]
|
||||
EMCMOT = motmod
|
||||
COMM_TIMEOUT = 1.0
|
||||
SERVO_PERIOD = 1000000
|
||||
|
||||
[TASK]
|
||||
TASK = milltask
|
||||
CYCLE_TIME = 0.001
|
||||
|
||||
[HAL]
|
||||
HALUI = halui
|
||||
HALFILE = LIB:basic_sim.tcl
|
||||
|
||||
[TRAJ]
|
||||
COORDINATES = X Y Z
|
||||
LINEAR_UNITS = inch
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 1.2
|
||||
POSITION_FILE = position.txt
|
||||
MAX_LINEAR_VELOCITY = 1.2
|
||||
NO_FORCE_HOMING = 1
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = tool.tbl
|
||||
TOOL_CHANGE_POSITION = 0 0 0
|
||||
TOOL_CHANGE_QUILL_UP = 1
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins
|
||||
JOINTS = 3
|
||||
|
||||
[AXIS_X]
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 100.0
|
||||
|
||||
[JOINT_0]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 100.0
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 20.0
|
||||
HOME_LATCH_VEL = 20.0
|
||||
HOME_SEQUENCE = 1
|
||||
|
||||
[AXIS_Y]
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 100.0
|
||||
|
||||
[JOINT_1]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 100.0
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 20.0
|
||||
HOME_LATCH_VEL = 20.0
|
||||
HOME_SEQUENCE = 1
|
||||
|
||||
[AXIS_Z]
|
||||
MIN_LIMIT = -8.0
|
||||
MAX_LIMIT = 8.00
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 100.0
|
||||
|
||||
[JOINT_2]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 100.0
|
||||
MIN_LIMIT = -8.0
|
||||
MAX_LIMIT = 8.00
|
||||
HOME_OFFSET = 1.0
|
||||
HOME_SEARCH_VEL = 20.0
|
||||
HOME_LATCH_VEL = 20.0
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
[PYTHON]
|
||||
PATH_PREPEND= python
|
||||
|
||||
# import the following Python module
|
||||
TOPLEVEL= python/toplevel.py
|
||||
|
||||
# the higher the more verbose tracing of the Python plugin
|
||||
LOG_LEVEL = 8
|
||||
17
configs/sim/axis/remap/getting-started/nc_files/examples.ngc
Normal file
17
configs/sim/axis/remap/getting-started/nc_files/examples.ngc
Normal file
@@ -0,0 +1,17 @@
|
||||
; you might want to single step this file
|
||||
|
||||
; M400 will fail - try in MDI window
|
||||
m400 p10
|
||||
m400 p10 q43
|
||||
m400p10
|
||||
; M410 will fail - try in MDI window
|
||||
m410 p10
|
||||
m400 p10 q43
|
||||
;
|
||||
F60 S2000 M3
|
||||
;
|
||||
g88.1 x0
|
||||
;
|
||||
g88.1 x1 y2 z3 p4
|
||||
;
|
||||
m2
|
||||
@@ -0,0 +1,12 @@
|
||||
o<change_min> sub
|
||||
(debug, change_min: loaded tool=#<current_tool> selected_pocket=#<selected_pocket>)
|
||||
|
||||
; show aborting a change on tool 2 by returning a negative value
|
||||
; o100 if [#<tool> EQ 2]
|
||||
; o100 return [-1]
|
||||
; o100 endif
|
||||
|
||||
; succeed by returning a positive value
|
||||
; which will inspected by the epilog handler
|
||||
o<change_min> endsub [1]
|
||||
m2
|
||||
@@ -0,0 +1,14 @@
|
||||
; configured by:
|
||||
; [RS274NGC]
|
||||
; REMAP=M400 modalgroup=10 argspec=Pq ngc=m400
|
||||
;
|
||||
o<m400> sub
|
||||
#5599 = 1 (turn on debug, output)
|
||||
(P is required since it's uppercase in the argspec)
|
||||
(debug, P word=#<P>)
|
||||
(the q argspec is optional since its lowercase in the argspec. Use as follows:)
|
||||
o100 if [EXISTS[#<q>]]
|
||||
(debug, Q word set: #<q>)
|
||||
o100 endif
|
||||
o<m400> endsub
|
||||
M2
|
||||
@@ -0,0 +1,4 @@
|
||||
o<m410> sub
|
||||
(debug, m410.ngc: [1]=#1 [2]=#2)
|
||||
o<m410> endsub
|
||||
M2
|
||||
@@ -0,0 +1,13 @@
|
||||
o<prepare_min> sub
|
||||
(debug, prepare_min: loaded tool=#<current_tool>, selected pocket=#<selected_pocket>)
|
||||
(debug, prepare tool #<new_tool> from pocket=#<new_pocket>)
|
||||
|
||||
; show aborting a prepare on tool 2 by returning a negative value
|
||||
; o100 if [#<tool> EQ 2]
|
||||
; o100 return [-1]
|
||||
; o100 endif
|
||||
|
||||
; succeed by returning a positive value
|
||||
; which will inspected by the epilog handler
|
||||
o<prepare_min> endsub [1]
|
||||
m2
|
||||
35
configs/sim/axis/remap/getting-started/python/oword.py
Normal file
35
configs/sim/axis/remap/getting-started/python/oword.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011, 2013 Dewey Garrett <dgarrett@panix.com>, Michael
|
||||
# Haberler <git@mah.priv.at>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
from util import call_pydevd
|
||||
|
||||
def foo(*args):
|
||||
print("foo!")
|
||||
|
||||
|
||||
# make debugger available as oword procedure
|
||||
def pydevd(self,*args):
|
||||
call_pydevd()
|
||||
|
||||
|
||||
|
||||
# this would be defined in the oword module
|
||||
def mysub(self, *args):
|
||||
print("number of parameters passed:", len(args))
|
||||
for a in args:
|
||||
print(a)
|
||||
114
configs/sim/axis/remap/getting-started/python/remap.py
Normal file
114
configs/sim/axis/remap/getting-started/python/remap.py
Normal file
@@ -0,0 +1,114 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011, 2013, 2014 Dewey Garrett <dgarrett@panix.com>,
|
||||
# Michael Haberler <git@mah.priv.at>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
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 g886(self, **words):
|
||||
for key in words:
|
||||
MESSAGE("word '%s' = %f" % (key, words[key]))
|
||||
if words.has_key('p'):
|
||||
MESSAGE("the P word was present")
|
||||
MESSAGE("comment on this line: '%s'" % (self.blocks[self.remap_level].comment))
|
||||
return INTERP_OK
|
||||
|
||||
|
||||
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):
|
||||
self.set_errormsg("feedrate > 0 required")
|
||||
return INTERP_ERROR
|
||||
|
||||
if equal(self.speed[0], 0.0):
|
||||
self.set_errormsg("spindle speed > 0 required")
|
||||
return INTERP_ERROR
|
||||
|
||||
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: # USER1 debug flag
|
||||
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 as e:
|
||||
msg = "%d: '%s' - %s" % (e.line_number,e.line_text, e.error_message)
|
||||
self.set_errormsg(msg) # replace builtin error message
|
||||
return INTERP_ERROR
|
||||
|
||||
return INTERP_OK
|
||||
|
||||
|
||||
def m462(self, **words):
|
||||
""" remap function which does the equivalent of M62, but via Python """
|
||||
|
||||
p = int(words['p'])
|
||||
q = int(words['q'])
|
||||
|
||||
if q:
|
||||
SET_MOTION_OUTPUT_BIT(p)
|
||||
else:
|
||||
CLEAR_MOTION_OUTPUT_BIT(p)
|
||||
return INTERP_OK
|
||||
|
||||
def m465(self, **words):
|
||||
""" remap function which does the equivalent of M65, but via Python """
|
||||
|
||||
p = int(words['p'])
|
||||
q = int(words['q'])
|
||||
|
||||
if q:
|
||||
SET_AUX_OUTPUT_BIT(p)
|
||||
else:
|
||||
CLEAR_AUX_OUTPUT_BIT(p)
|
||||
return INTERP_OK
|
||||
20
configs/sim/axis/remap/getting-started/python/toplevel.py
Normal file
20
configs/sim/axis/remap/getting-started/python/toplevel.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011, 2013 Dewey Garrett <dgarrett@panix.com>, Michael
|
||||
# Haberler <git@mah.priv.at>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
import oword
|
||||
import remap
|
||||
68
configs/sim/axis/remap/getting-started/python/util.py
Normal file
68
configs/sim/axis/remap/getting-started/python/util.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011, 2013 Dewey Garrett <dgarrett@panix.com>, Michael
|
||||
# Haberler <git@mah.priv.at>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
import inspect
|
||||
import emccanon
|
||||
|
||||
# O-word procedure to trap into the Pydevd debugger
|
||||
# start debug server in Eclipse, then
|
||||
# call as 'O<pydevd> call' from MDI
|
||||
|
||||
# example setup for debugging embedded Python code
|
||||
# see http://pydev.org/manual_adv_remote_debugger.html
|
||||
# if this points to a valid directory,
|
||||
|
||||
def call_pydevd():
|
||||
""" trap into the pydevd debugger"""
|
||||
|
||||
import os,sys
|
||||
|
||||
pydevdir= '/home/mah/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/org.python.pydev.debug_2.0.0.2011040403/pysrc/'
|
||||
|
||||
# the 'emctask' module is present only in the milltask instance, otherwise both the UI and
|
||||
# milltask would try to connect to the debug server.
|
||||
|
||||
if os.path.isdir(pydevdir) and 'emctask' in sys.builtin_module_names:
|
||||
sys.path.append(pydevdir)
|
||||
sys.path.insert(0,pydevdir)
|
||||
try:
|
||||
import pydevd
|
||||
emccanon.MESSAGE("pydevd imported, connecting to Eclipse debug server...")
|
||||
pydevd.settrace()
|
||||
except:
|
||||
emccanon.MESSAGE("no pydevd module found")
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def lineno():
|
||||
""" return line number in the current Python script """
|
||||
return inspect.currentframe().f_back.f_lineno
|
||||
|
||||
def error_stack(self):
|
||||
""" print the Interpreters error stack (function names) """
|
||||
print("error stack level=%d" % (self.stack_index))
|
||||
for s in self.stack():
|
||||
print("--'%s'" % (s))
|
||||
|
||||
def callstack(self):
|
||||
""" print the O-Word call stack """
|
||||
for i in range(self.call_level):
|
||||
c = self.sub_context[i]
|
||||
print("%d: pos=%d seq=%d filename=%s sub=%s" % (i,c.position, c.sequence_number,c.filename,c.subname))
|
||||
|
||||
1
configs/sim/axis/remap/getting-started/tool.tbl
Symbolic link
1
configs/sim/axis/remap/getting-started/tool.tbl
Symbolic link
@@ -0,0 +1 @@
|
||||
../tool.tbl
|
||||
Reference in New Issue
Block a user