Import LinuxCNC source tree
This commit is contained in:
43
configs/sim/axis/remap/cycle/README
Normal file
43
configs/sim/axis/remap/cycle/README
Normal file
@@ -0,0 +1,43 @@
|
||||
This shows how cycles can be made out of O-word subroutines or directly coded in Python.
|
||||
|
||||
# Assume G84.2 is remapped to Python g842 like so in the [RS274NGC] ini section:
|
||||
# REMAP=G84.2 argspec=xyzqp python=g842 modalgroup=1
|
||||
#
|
||||
# then executing
|
||||
#
|
||||
# G84.2 x1 y1 (line1)
|
||||
# x3 y3 (line2)
|
||||
# y5 (line3)
|
||||
# ...
|
||||
#
|
||||
# will execute like:
|
||||
# *G84.2 x1 y1
|
||||
# G84.2 x3 y3
|
||||
# G84.2 x3 y5
|
||||
#
|
||||
# until motion is cleared with G80 or some other motion is executed.
|
||||
#
|
||||
# This enables writing cycles in Python, or as Oword procedures; in the
|
||||
# latter case the self.motion_mode should be set in the Python epilog.
|
||||
#
|
||||
|
||||
And the same thing as an Oword procedure:
|
||||
|
||||
# a cycle with an Oword sub
|
||||
#REMAP=G84.3 modalgroup=1 argspec=xyzqp prolog=g843_prolog ngc=g843 epilog=g843_epilog
|
||||
|
||||
|
||||
The examples only show they parameters they are fed, and dont do anything useful - "you get the idea".
|
||||
Sticky parameters are handled properly.
|
||||
|
||||
Usage:
|
||||
|
||||
linuxcnc cycle.ini
|
||||
|
||||
hit run and see what happens.
|
||||
|
||||
To understand how things fit together:
|
||||
|
||||
- see the REMAP statements in cycle.ini
|
||||
- python/remap.py contains the Python glue
|
||||
- nc_subroutines/g843.ngc is an example 'cycle body'
|
||||
239
configs/sim/axis/remap/cycle/cycle.ini
Normal file
239
configs/sim/axis/remap/cycle/cycle.ini
Normal file
@@ -0,0 +1,239 @@
|
||||
[EMC]
|
||||
VERSION = 1.1
|
||||
MACHINE = cycle.ini
|
||||
DEBUG = 0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = axis
|
||||
OPEN_FILE=./nc_files/examples.ngc
|
||||
CYCLE_TIME = 0.100
|
||||
POSITION_OFFSET = RELATIVE
|
||||
POSITION_FEEDBACK = ACTUAL
|
||||
MAX_FEED_OVERRIDE = 1.2
|
||||
MAX_SPINDLE_OVERRIDE = 1.0
|
||||
PROGRAM_PREFIX = ../../nc_files/
|
||||
INTRO_GRAPHIC = linuxcnc.gif
|
||||
INTRO_TIME = 5
|
||||
#EDITOR = geany
|
||||
INCREMENTS = 1 mm, .01 in, .1mm, 1 mil, .1 mil, 1/8000 in
|
||||
GEOMETRY = XYZBCUVW
|
||||
|
||||
[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-9axis.var
|
||||
SUBROUTINE_PATH = nc_subroutines:../../nc_files/remap_lib/common_nc_subs
|
||||
LOG_LEVEL = 1
|
||||
|
||||
# A cycle in Python: G84.2 <X- Y- Z- Q- P->
|
||||
REMAP=G84.2 argspec=xyzabcuvwqplr python=g842 modalgroup=1
|
||||
|
||||
# A cycle with an oword procedure: G84.3 <X- Y- Z- Q- P->
|
||||
REMAP=G84.3 argspec=xyzabcuvwqplr prolog=cycle_prolog ngc=g843 epilog=cycle_epilog modalgroup=1
|
||||
|
||||
# this is important - read common_nc_subs/reset_state.ngc
|
||||
ON_ABORT_COMMAND=O <reset_state> call
|
||||
|
||||
[EMCMOT]
|
||||
EMCMOT = motmod unlock_joints_mask=0x10
|
||||
COMM_TIMEOUT = 1.0
|
||||
SERVO_PERIOD = 1000000
|
||||
|
||||
[TASK]
|
||||
TASK = milltask
|
||||
CYCLE_TIME = 0.001
|
||||
|
||||
[HAL]
|
||||
HALUI = halui
|
||||
HALFILE = LIB:basic_sim.tcl
|
||||
HALFILE = locking_indexer.hal
|
||||
|
||||
[TRAJ]
|
||||
COORDINATES = X Y Z A B C U V W
|
||||
LINEAR_UNITS = inch
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 1.0
|
||||
DEFAULT_ANGULAR_VELOCITY = 45.0
|
||||
POSITION_FILE = position9.txt
|
||||
MAX_LINEAR_VELOCITY = 1.2
|
||||
MAX_ANGULAR_VELOCITY = 90.0
|
||||
NO_FORCE_HOMING = 1
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = tool.tbl
|
||||
TOOL_CHANGE_POSITION = 0 0 2
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins
|
||||
JOINTS = 9
|
||||
|
||||
[AXIS_X]
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
|
||||
[JOINT_0]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 5.0
|
||||
HOME_LATCH_VEL = 1.0
|
||||
HOME_SEQUENCE = 1
|
||||
|
||||
[AXIS_Y]
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
|
||||
[JOINT_1]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 5.0
|
||||
HOME_LATCH_VEL = 1.0
|
||||
HOME_SEQUENCE = 1
|
||||
|
||||
[AXIS_Z]
|
||||
MIN_LIMIT = -2.0
|
||||
MAX_LIMIT = 4.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
|
||||
[JOINT_2]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
MIN_LIMIT = -2.0
|
||||
MAX_LIMIT = 4.0
|
||||
HOME_OFFSET = 1.0
|
||||
HOME_SEARCH_VEL = 5.0
|
||||
HOME_LATCH_VEL = 1.0
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
[AXIS_A]
|
||||
MAX_VELOCITY = 90.0
|
||||
MAX_ACCELERATION = 1200.0
|
||||
|
||||
[JOINT_3]
|
||||
TYPE = ANGULAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 90.0
|
||||
MAX_ACCELERATION = 1200.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 0.0
|
||||
HOME_LATCH_VEL = 0.0
|
||||
HOME_SEQUENCE = 1
|
||||
|
||||
[AXIS_B]
|
||||
MAX_VELOCITY = 90.0
|
||||
MAX_ACCELERATION = 1200.0
|
||||
LOCKING_INDEXER_JOINT = 4
|
||||
|
||||
[JOINT_4]
|
||||
TYPE = ANGULAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 90.0
|
||||
MAX_ACCELERATION = 1200.0
|
||||
HOME_OFFSET = 45.0
|
||||
HOME_SEARCH_VEL = 0.0
|
||||
HOME_LATCH_VEL = 0.0
|
||||
HOME_SEQUENCE = 1
|
||||
LOCKING_INDEXER = 1
|
||||
|
||||
[AXIS_C]
|
||||
MAX_VELOCITY = 90.0
|
||||
MAX_ACCELERATION = 1200.0
|
||||
|
||||
[JOINT_5]
|
||||
TYPE = ANGULAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 90.0
|
||||
MAX_ACCELERATION = 1200.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 0.0
|
||||
HOME_LATCH_VEL = 0.0
|
||||
HOME_SEQUENCE = 1
|
||||
|
||||
[AXIS_U]
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
|
||||
[JOINT_6]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 0.0
|
||||
HOME_LATCH_VEL = 0.0
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
[AXIS_V]
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
|
||||
[JOINT_7]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
MIN_LIMIT = -10.0
|
||||
MAX_LIMIT = 10.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 0.0
|
||||
HOME_LATCH_VEL = 0.0
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
[AXIS_W]
|
||||
MIN_LIMIT = -2.0
|
||||
MAX_LIMIT = 4.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
|
||||
[JOINT_8]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.0
|
||||
MAX_VELOCITY = 1.2
|
||||
MAX_ACCELERATION = 20.0
|
||||
MIN_LIMIT = -2.0
|
||||
MAX_LIMIT = 4.0
|
||||
HOME_OFFSET = 0.0
|
||||
HOME_SEARCH_VEL = 0.0
|
||||
HOME_LATCH_VEL = 0.0
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
|
||||
[PYTHON]
|
||||
# code specific for this configuration
|
||||
PATH_PREPEND=./python
|
||||
# generic support code
|
||||
PATH_APPEND=../../nc_files/remap_lib/python-stdglue
|
||||
|
||||
# import the following Python module
|
||||
TOPLEVEL=python/toplevel.py
|
||||
|
||||
# the higher the more verbose tracing of the Python plugin
|
||||
LOG_LEVEL = 0
|
||||
14
configs/sim/axis/remap/cycle/nc_files/examples.ngc
Normal file
14
configs/sim/axis/remap/cycle/nc_files/examples.ngc
Normal file
@@ -0,0 +1,14 @@
|
||||
s300 f20
|
||||
|
||||
g84.2 x1 y2 z3 q5 r1
|
||||
|
||||
x321 y452 p12
|
||||
z23 x10 q3
|
||||
|
||||
g84.3 x1 y2 z3 q5 r2
|
||||
|
||||
x321 y452 p12
|
||||
z23 x10 q3
|
||||
|
||||
|
||||
m2
|
||||
13
configs/sim/axis/remap/cycle/nc_subroutines/g843.ngc
Normal file
13
configs/sim/axis/remap/cycle/nc_subroutines/g843.ngc
Normal file
@@ -0,0 +1,13 @@
|
||||
o<g843> sub
|
||||
|
||||
(debug, in g843 x=#<x> y=#<y> z=#<z> p=#<p> q=#<q>)
|
||||
|
||||
O100 if [exists[#<p>] NE 1.]
|
||||
(debug, the P word was not set)
|
||||
O100 endif
|
||||
|
||||
; signal success be returning a value > 0:
|
||||
o<g843> endsub [1]
|
||||
|
||||
m2
|
||||
|
||||
79
configs/sim/axis/remap/cycle/python/remap.py
Normal file
79
configs/sim/axis/remap/cycle/python/remap.py
Normal file
@@ -0,0 +1,79 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2012, 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 interpreter import *
|
||||
from emccanon import MESSAGE
|
||||
|
||||
from stdglue import cycle_prolog, cycle_epilog, init_stdglue
|
||||
|
||||
# This shows how to create a remapped G-code which can be used as a cycle
|
||||
# written in Python
|
||||
#
|
||||
# Example:
|
||||
# Assume G84.2 is remapped to Python g842 like so in the [RS274NGC] ini section:
|
||||
# REMAP=G84.2 argspec=xyzqp python=g842 modalgroup=1
|
||||
#
|
||||
# then executing
|
||||
#
|
||||
# G84.2 x1 y1 (line1)
|
||||
# x3 y3 (line2)
|
||||
# y5 (line3)
|
||||
# ...
|
||||
#
|
||||
# will execute like:
|
||||
# *G84.2 x1 y1
|
||||
# G84.2 x3 y3
|
||||
# G84.2 x3 y5
|
||||
#
|
||||
# until motion is cleared with G80 or some other motion is executed.
|
||||
#
|
||||
# This enables writing cycles in Python, or as Oword procedures; in the
|
||||
# latter case the self.motion_mode should be set in the Python epilog.
|
||||
#
|
||||
# for a more through example of a cycle prolog, see cycle_prolog in stdglue.py
|
||||
|
||||
_sticky_params = dict()
|
||||
|
||||
def g842(self,**words):
|
||||
|
||||
global _sticky_params
|
||||
|
||||
firstcall = False
|
||||
|
||||
# determine whether this is the first or a subsequent call
|
||||
c = self.blocks[self.remap_level]
|
||||
r = c.executing_remap
|
||||
if c.g_modes[1] == r.motion_code:
|
||||
# this was the first call.
|
||||
# clear the dict to remember all sticky parameters.
|
||||
_sticky_params[r.name] = dict()
|
||||
text = "*" + r.name
|
||||
else:
|
||||
text = r.name
|
||||
# merge in new parameters
|
||||
_sticky_params[r.name].update(words)
|
||||
|
||||
# insert your cycle actions here
|
||||
for (key,value) in _sticky_params[r.name].items():
|
||||
text += "%s%.1f " % (key, value)
|
||||
MESSAGE(text)
|
||||
|
||||
# retain the current motion mode
|
||||
self.motion_mode = c.executing_remap.motion_code
|
||||
return INTERP_OK
|
||||
|
||||
29
configs/sim/axis/remap/cycle/python/toplevel.py
Normal file
29
configs/sim/axis/remap/cycle/python/toplevel.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# This is a component of LinuxCNC
|
||||
# Copyright 2011, 2012, 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 remap
|
||||
import os
|
||||
|
||||
def __init__(self):
|
||||
# handle any per-module initialisation tasks here
|
||||
remap.init_stdglue(self)
|
||||
print("interp __init__",self.task,os.getpid())
|
||||
|
||||
def __delete__(self):
|
||||
# handle any per-module shutdown tasks here
|
||||
print("interp __delete__",self.task,os.getpid())
|
||||
4
configs/sim/axis/remap/cycle/tool.tbl
Normal file
4
configs/sim/axis/remap/cycle/tool.tbl
Normal file
@@ -0,0 +1,4 @@
|
||||
T1 P11 D0.125000 Z+0.511000 ;1/8 end mill
|
||||
T2 P12 D0.062500 Z+0.100000 ;1/16 end mill
|
||||
T3 P13 D0.201000 Z+1.273000 ;#7 tap drill
|
||||
T4 P14 D0.345 Z+1.11 ;#random drill
|
||||
Reference in New Issue
Block a user