Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

5
tests/toolchanger/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
sim.var
sim.var.bak
simpockets.tbl
stdout
gcode-output

14
tests/toolchanger/README Normal file
View File

@@ -0,0 +1,14 @@
The tests in this directory attempt to verify the correct behavior of
the tool table and the tool changer.
Two tests are run: one on a random toolchanger and one on a nonrandom
toolchanger. Both tests perform the same operations, and expect (nearly)
the same results.
A full LinuxCNC instance is started, with linuxcncrsh as the UI. A bunch
of gcode commands are run via MDI, and the internal state of LinuxCNC
is accessed via numbered parameters. A custom M-code shell script is
used to write these parameter values to a file, which is then compared
to a hand-crafted "expected values" file.

1
tests/toolchanger/m61/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
sim.var.bak

View File

@@ -0,0 +1,2 @@
#!/bin/sh
exit 0 # test failure is indicated by test.sh exit value

View File

@@ -0,0 +1,106 @@
[EMC]
DEBUG = 0x0
VERSION = 1.1
[DISPLAY]
DISPLAY = ./test-ui.py
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
MDI_QUEUED_COMMANDS=10000
[RS274NGC]
PARAMETER_FILE = sim.var
USER_M_PATH = ./subs
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[HAL]
HALUI = halui
HALFILE = mod_core_sim.hal
POSTGUI_HALFILE = postgui.hal
[TRAJ]
NO_FORCE_HOMING=1
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_VELOCITY = 4
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_X]
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
[AXIS_Y]
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
[AXIS_Z]
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 0

View File

@@ -0,0 +1,61 @@
# core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt trivkins
# motion controller, get name and thread periods from INI file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
# load 6 differentiators (for velocity and accel signals
loadrt ddt count=6
# load additional blocks
loadrt hypot count=2
loadrt comp count=3
loadrt or2 count=1
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# link the differentiator functions into the code
addf ddt.0 servo-thread
addf ddt.1 servo-thread
addf ddt.2 servo-thread
addf ddt.3 servo-thread
addf ddt.4 servo-thread
addf ddt.5 servo-thread
addf hypot.0 servo-thread
addf hypot.1 servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt.0.in
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt.2.in
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt.4.in
# send the position commands thru differentiators to
# generate velocity and accel signals
net Xvel ddt.0.out => ddt.1.in hypot.0.in0
net Xacc <= ddt.1.out
net Yvel ddt.2.out => ddt.3.in hypot.0.in1
net Yacc <= ddt.3.out
net Zvel ddt.4.out => ddt.5.in hypot.1.in0
net Zacc <= ddt.5.out
# Cartesian 2- and 3-axis velocities
net XYvel hypot.0.out => hypot.1.in1
net XYZvel <= hypot.1.out
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prepare <= iocontrol.0.tool-prepare
net tool-prepared => iocontrol.0.tool-prepared
net tool-change <= iocontrol.0.tool-change
net tool-changed => iocontrol.0.tool-changed
net tool-number <= iocontrol.0.tool-number
net tool-prep-number <= iocontrol.0.tool-prep-number
net tool-prep-pocket <= iocontrol.0.tool-prep-pocket
net tool-from-pocket <= iocontrol.0.tool-from-pocket

View File

@@ -0,0 +1,12 @@
net tool-prepare => python-ui.tool-prepare
net tool-prepared <= python-ui.tool-prepared
net tool-change => python-ui.tool-change
net tool-changed <= python-ui.tool-changed
net tool-number => python-ui.tool-number
net tool-prep-number => python-ui.tool-prep-number
net tool-prep-pocket => python-ui.tool-prep-pocket
net tool-from-pocket => python-ui.tool-from-pocket

313
tests/toolchanger/m61/test-ui.py Executable file
View File

@@ -0,0 +1,313 @@
#!/usr/bin/env python3
import linuxcnc
import hal
import time
import sys
import os
# this is how long we wait for linuxcnc to do our bidding
timeout = 1.0
def introspect():
os.system("halcmd show pin python-ui")
def wait_for_pin_value(pin_name, value, timeout=1):
print("waiting for %s to go to %f (timeout=%f)" % (pin_name, value, timeout))
start = time.time()
while (h[pin_name] != value) and ((time.time() - start) < timeout):
time.sleep(0.1)
if h[pin_name] != value:
print("timeout! pin %s is %f, didn't get to %f" % (pin_name, h[pin_name], value))
introspect()
sys.exit(1)
print("pin %s went to %f!" % (pin_name, value))
def verify_pin_value(pin_name, value):
if (h[pin_name] != value):
print("pin %s is %f, not %f" % (pin_name, h[pin_name], value))
sys.exit(1);
print("pin %s is %f" % (pin_name, value))
def get_interp_param(param_number):
c.mdi("(debug, #%d)" % param_number)
c.wait_complete()
# wait up to 2 seconds for a reply
start = time.time()
while (time.time() - start) < 2:
error = e.poll()
if error == None:
time.sleep(0.010)
continue
kind, text = error
if kind == linuxcnc.OPERATOR_DISPLAY:
return float(text)
print(text)
print("error getting parameter %d" % param_number)
return None
def verify_interp_param(param_number, expected_value):
param_value = get_interp_param(param_number)
print("interp param #%d = %f (expecting %f)" % (param_number, param_value, expected_value))
if param_value != expected_value:
print("ERROR: interp param #%d = %f, expected %f" % (param_number, param_value, expected_value))
sys.exit(1)
def verify_stable_pin_values(pins, duration=1):
start = time.time()
while (time.time() - start) < duration:
for pin_name in list(pins.keys()):
val = h[pin_name]
if val != pins[pin_name]:
print("ERROR: pin %s = %f (expected %f)" % (pin_name, val, pins[pin_name]))
sys.exit(1)
time.sleep(0.010)
def verify_tool_number(tool_number):
verify_interp_param(5400, tool_number) # 5400 == tool in spindle
verify_pin_value('tool-number', tool_number) # pin from iocontrol
# verify stat buffer
s.poll()
if s.tool_in_spindle != tool_number:
print("ERROR: stat buffer .tool_in_spindle is %f, should be %f" % (s.tool_in_spindle, tool_number))
sys.exit(1)
print("stat buffer .tool_in_spindle is %f" % s.tool_in_spindle)
def do_tool_change_handshake(tool_number, pocket_number):
# prepare for tool change
wait_for_pin_value('tool-prepare', 1)
verify_pin_value('tool-prep-number', tool_number)
verify_pin_value('tool-prep-pocket', pocket_number)
h['tool-prepared'] = 1
wait_for_pin_value('tool-prepare', 0)
h['tool-prepared'] = 0
time.sleep(0.1)
s.poll()
print("tool prepare done, s.pocket_prepped = ", s.pocket_prepped)
if s.pocket_prepped != pocket_number:
print("ERROR: wrong pocket prepped in stat buffer (got %d, expected %d)" % (s.pocket_prepped, pocket_number))
sys.exit(1)
# change tool
wait_for_pin_value('tool-change', 1)
h['tool-changed'] = 1
wait_for_pin_value('tool-change', 0)
h['tool-changed'] = 0
#
# set up pins
# shell out to halcmd to net our pins to where they need to go
#
h = hal.component("python-ui")
h.newpin("tool-number", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prep-pocket", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-from-pocket", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_IN)
h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT)
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
h.ready() # mark the component as 'ready'
os.system("halcmd source ./postgui.hal")
#
# connect to LinuxCNC
#
c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.mode(linuxcnc.MODE_MDI)
c.wait_complete()
# at startup, we should have the special tool 0 in the spindle, meaning
# "no tool" or "unknown tool"
verify_tool_number(0)
#
# test m6 to get a baseline
#
print("*** starting 'T1 M6' tool change")
c.mdi('t1 m6')
c.wait_complete()
do_tool_change_handshake(tool_number=1, pocket_number=1)
print("*** tool change complete")
verify_tool_number(1)
verify_interp_param(5401, 0) # tlo x
verify_interp_param(5402, 0) # tlo y
verify_interp_param(5403, 1) # tlo z
verify_interp_param(5404, 0) # tlo a
verify_interp_param(5405, 0) # tlo b
verify_interp_param(5406, 0) # tlo c
verify_interp_param(5407, 0) # tlo u
verify_interp_param(5408, 0) # tlo v
verify_interp_param(5409, 0) # tlo w
verify_interp_param(5410, 0.125) # tool diameter
verify_interp_param(5411, 0) # front angle
verify_interp_param(5412, 0) # back angle
verify_interp_param(5413, 0) # tool orientation
verify_interp_param(5420, 0) # current x
verify_interp_param(5421, 0) # current y
verify_interp_param(5422, 0) # current z
verify_interp_param(5423, 0) # current a
verify_interp_param(5424, 0) # current b
verify_interp_param(5425, 0) # current c
verify_interp_param(5426, 0) # current u
verify_interp_param(5427, 0) # current v
verify_interp_param(5428, 0) # current w
c.mdi('g43')
c.wait_complete()
verify_interp_param(5420, 0) # current x
verify_interp_param(5421, 0) # current y
verify_interp_param(5422, -1) # current z
verify_interp_param(5423, 0) # current a
verify_interp_param(5424, 0) # current b
verify_interp_param(5425, 0) # current c
verify_interp_param(5426, 0) # current u
verify_interp_param(5427, 0) # current v
verify_interp_param(5428, 0) # current w
introspect()
#
# now finally test m61
#
print("*** starting 'M61 Q10' tool change")
c.mdi('m61 q10')
c.wait_complete()
verify_stable_pin_values(
{
'tool-change': 0,
'tool-prep-number': 0,
'tool-prep-pocket': 0,
'tool-prepare': 0,
'tool-from-pocket': 1
},
duration=1
)
verify_tool_number(10)
verify_interp_param(5401, 0) # tlo x
verify_interp_param(5402, 0) # tlo y
verify_interp_param(5403, 3) # tlo z
verify_interp_param(5404, 0) # tlo a
verify_interp_param(5405, 0) # tlo b
verify_interp_param(5406, 0) # tlo c
verify_interp_param(5407, 0) # tlo u
verify_interp_param(5408, 0) # tlo v
verify_interp_param(5409, 0) # tlo w
verify_interp_param(5410, 0.500) # tool diameter
verify_interp_param(5411, 0) # front angle
verify_interp_param(5412, 0) # back angle
verify_interp_param(5413, 0) # tool orientation
verify_interp_param(5420, 0) # current x
verify_interp_param(5421, 0) # current y
verify_interp_param(5422, -1) # current z
verify_interp_param(5423, 0) # current a
verify_interp_param(5424, 0) # current b
verify_interp_param(5425, 0) # current c
verify_interp_param(5426, 0) # current u
verify_interp_param(5427, 0) # current v
verify_interp_param(5428, 0) # current w
c.mdi('g43')
c.wait_complete()
verify_interp_param(5420, 0) # current x
verify_interp_param(5421, 0) # current y
verify_interp_param(5422, -3) # current z
verify_interp_param(5423, 0) # current a
verify_interp_param(5424, 0) # current b
verify_interp_param(5425, 0) # current c
verify_interp_param(5426, 0) # current u
verify_interp_param(5427, 0) # current v
verify_interp_param(5428, 0) # current w
#
# use M6 to unload the spindle (T0)
#
print("*** using 'T0 M6' to unload the spindle")
c.mdi("t0 m6")
c.wait_complete()
do_tool_change_handshake(tool_number=0, pocket_number=0)
verify_tool_number(0)
#
# use M61 to load T1 in the spindle again
#
print("*** using 'M61 Q1' to load a tool again")
c.mdi("m61 q1")
c.wait_complete()
verify_tool_number(1)
#
# use M61 to unload the spindle (T0)
#
print("*** using 'M61 Q0' to unload the spindle again")
c.mdi("m61 q0")
c.wait_complete()
verify_tool_number(0)
# if we get here it all worked!
sys.exit(0)

5
tests/toolchanger/m61/test.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
cp -f ../simpockets.tbl.original simpockets.tbl
exec linuxcnc -r m61-test.ini

View File

@@ -0,0 +1,3 @@
This test reproduces https://github.com/LinuxCNC/linuxcnc/issues/330.
It tests the behavior for both random and non-random toolchanger machines.

View File

@@ -0,0 +1,2 @@
#!/bin/sh
exit 0 # test failure is indicated by test.sh exit value

View File

@@ -0,0 +1,62 @@
# core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
#autoconverted trivkins
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# load 6 differentiators (for velocity and accel signals
loadrt ddt count=6
# load additional blocks
loadrt hypot count=2
loadrt comp count=3
loadrt or2 count=1
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# link the differentiator functions into the code
addf ddt.0 servo-thread
addf ddt.1 servo-thread
addf ddt.2 servo-thread
addf ddt.3 servo-thread
addf ddt.4 servo-thread
addf ddt.5 servo-thread
addf hypot.0 servo-thread
addf hypot.1 servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt.0.in
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt.2.in
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt.4.in
# send the position commands thru differentiators to
# generate velocity and accel signals
net Xvel ddt.0.out => ddt.1.in hypot.0.in0
net Xacc <= ddt.1.out
net Yvel ddt.2.out => ddt.3.in hypot.0.in1
net Yacc <= ddt.3.out
net Zvel ddt.4.out => ddt.5.in hypot.1.in0
net Zacc <= ddt.5.out
# Cartesian 2- and 3-axis velocities
net XYvel hypot.0.out => hypot.1.in1
net XYZvel <= hypot.1.out
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prepare <= iocontrol.0.tool-prepare
net tool-prepared => iocontrol.0.tool-prepared
net tool-change <= iocontrol.0.tool-change
net tool-changed => iocontrol.0.tool-changed
net tool-number <= iocontrol.0.tool-number
net tool-prep-number <= iocontrol.0.tool-prep-number
net tool-prep-pocket <= iocontrol.0.tool-prep-pocket
net tool-from-pocket <= iocontrol.0.tool-from-pocket

View File

@@ -0,0 +1 @@
../checkresult

View File

@@ -0,0 +1 @@
../core_sim.hal

View File

@@ -0,0 +1 @@
../postgui.hal

View File

@@ -0,0 +1,345 @@
#!/usr/bin/env python3
import linuxcnc
import linuxcnc_util
import hal
import math
import time
import sys
import subprocess
import os
import signal
import glob
import re
xtool = 0.111 # [EMCIO]TOOL_CHANGE_POSITION x
ytool = 0.222 # [EMCIO]TOOL_CHANGE_POSITION y
ztool = 0.333 # [EMCIO]TOOL_CHANGE_POSITION z
EPSILON = 1e-10
def wait_for_hal_pin(name, value, timeout=10):
start_time = time.time()
while (time.time() - start_time) < timeout:
if h[name] == value:
return
time.sleep(0.1)
raise RuntimeError("hal pin %s didn't get to %s after %.3f seconds" % (name, value, timeout))
# After doing something that should change the stat buffer, wait this
# long before polling to let the change propagate through.
# FIXME: this is bogus
stat_poll_wait = 0.100
c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
h = hal.component("test-ui")
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
h["tool-changed"] = False
h.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_IN)
h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT)
h["tool-prepared"] = False
h.newpin("tool-number", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prep-pocket", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-from-pocket", hal.HAL_S32, hal.HAL_IN)
h.ready()
os.system("halcmd source ./postgui.hal")
l = linuxcnc_util.LinuxCNC()
# Wait for LinuxCNC to initialize itself so the Status buffer stabilizes.
l.wait_for_linuxcnc_startup()
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(-1)
c.wait_complete()
c.mode(linuxcnc.MODE_MDI)
#
# At startup there's no tool in the spindle and no tool prep or change
# is being requested.
#
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 0)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 0)
s.poll()
assert(s.tool_in_spindle == 0)
assert(s.tool_from_pocket == 0);
assert(s.pocket_prepped == -1)
#
# Prepare T2
#
c.mdi('t2')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 0)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 0)
assert(s.tool_from_pocket == 0);
assert(s.pocket_prepped == -1)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 0)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 0)
assert(s.tool_from_pocket == 0);
assert(s.pocket_prepped == 6) # ugh, non-random tc gives you tool-table-array index, not pocket
#
# Change to T2
#
c.mdi('m6')
wait_for_hal_pin('tool-change', True)
assert(h['tool-change'] == True)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 0)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 0)
assert(s.tool_from_pocket == 0);
assert(s.pocket_prepped == 6)
h['tool-changed'] = True
wait_for_hal_pin('tool-change', False)
h['tool-changed'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == -1)
#
# Prepare T12
#
c.mdi('t12')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 12)
assert(h['tool-prep-pocket'] == 9)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == -1)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 12)
assert(h['tool-prep-pocket'] == 9)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 4)
#
# Prepare T2
# This tool is already in the spindle.
#
c.mdi('t2')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 4)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 6)
#
# Change to prepared tool (T2 again)
#
c.mdi('m6')
try:
wait_for_hal_pin('tool-change', True, timeout=5)
except RuntimeError:
# It *should* time out, no tool change should be performed since
# the prepared tool is already in the spindle.
pass
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 6)
assert(abs(s.joint_position[0] -xtool) < EPSILON)
assert(abs(s.joint_position[1] -ytool) < EPSILON)
assert(abs(s.joint_position[2] -ztool) < EPSILON)
#
# Prepare T0
#
c.mdi('t0')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 0)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 0)
#
# Change to T0
#
c.mdi('m6')
wait_for_hal_pin('tool-change', True)
assert(h['tool-change'] == True)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46);
assert(s.pocket_prepped == 0)
h['tool-changed'] = True
wait_for_hal_pin('tool-change', False)
h['tool-changed'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 0)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 0)
assert(s.tool_from_pocket == 0);
sys.exit(0)

View File

@@ -0,0 +1,115 @@
[EMC]
VERSION = 1.1
#DEBUG = 0x0
DEBUG = 0xffffffff
[DISPLAY]
DISPLAY = ./test-ui.py
[FILTER]
#No Content
[RS274NGC]
PARAMETER_FILE = sim.var
USER_M_PATH = ./subs
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[HAL]
HALFILE = core_sim.hal
[HALUI]
#No Content
[TRAJ]
NO_FORCE_HOMING=1
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_ACCELERATION = 123.45
MAX_LINEAR_VELOCITY = 45.67
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 0
TOOL_CHANGE_POSITION = 0.111 0.222 0.333
[KINS]
KINEMATICS = trivkins
#This is a best-guess at the number of joints, it should be checked
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_Y]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_Z]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010

View File

@@ -0,0 +1 @@
../shared-test.sh

View File

@@ -0,0 +1,24 @@
net tool-change <= iocontrol.0.tool-change
net tool-change => test-ui.tool-change
net tool-changed <= test-ui.tool-changed
net tool-changed => iocontrol.0.tool-changed
net tool-prepare <= iocontrol.0.tool-prepare
net tool-prepare => test-ui.tool-prepare
net tool-prepared <= test-ui.tool-prepared
net tool-prepared => iocontrol.0.tool-prepared
net tool-number <= iocontrol.0.tool-number
net tool-number => test-ui.tool-number
net tool-prep-number <= iocontrol.0.tool-prep-number
net tool-prep-number => test-ui.tool-prep-number
net tool-prep-pocket <= iocontrol.0.tool-prep-pocket
net tool-prep-pocket => test-ui.tool-prep-pocket
net tool-from-pocket <= iocontrol.0.tool-from-pocket
net tool-from-pocket => test-ui.tool-from-pocket

View File

@@ -0,0 +1 @@
../checkresult

View File

@@ -0,0 +1 @@
../core_sim.hal

View File

@@ -0,0 +1 @@
../postgui.hal

View File

@@ -0,0 +1,334 @@
#!/usr/bin/env python3
import linuxcnc
import linuxcnc_util
import hal
import math
import time
import sys
import subprocess
import os
import signal
import glob
import re
xtool = 0.111 # [EMCIO]TOOL_CHANGE_POSITION x
ytool = 0.222 # [EMCIO]TOOL_CHANGE_POSITION y
ztool = 0.333 # [EMCIO]TOOL_CHANGE_POSITION z
EPSILON = 1e-10
def wait_for_hal_pin(name, value, timeout=10):
start_time = time.time()
while (time.time() - start_time) < timeout:
if h[name] == value:
return
time.sleep(0.1)
raise RuntimeError("hal pin %s didn't get to %s after %.3f seconds" % (name, value, timeout))
# After doing something that should change the stat buffer, wait this
# long before polling to let the change propagate through.
# FIXME: this is bogus
stat_poll_wait = 0.100
c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
h = hal.component("test-ui")
h.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
h["tool-changed"] = False
h.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_IN)
h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_OUT)
h["tool-prepared"] = False
h.newpin("tool-number", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-prep-pocket", hal.HAL_S32, hal.HAL_IN)
h.newpin("tool-from-pocket", hal.HAL_S32, hal.HAL_IN)
h.ready()
os.system("halcmd source ./postgui.hal")
l = linuxcnc_util.LinuxCNC()
# Wait for LinuxCNC to initialize itself so the Status buffer stabilizes.
l.wait_for_linuxcnc_startup()
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(-1)
c.wait_complete()
c.mode(linuxcnc.MODE_MDI)
#
# At startup tool 3 is in the spindle and no tool prep or change is
# being requested.
#
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 3)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 0)
s.poll()
assert(s.tool_in_spindle == 3)
assert(s.tool_from_pocket == 0)
assert(s.pocket_prepped == -1)
#
# Prepare T2
#
c.mdi('t2')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 3)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 0)
s.poll()
assert(s.tool_in_spindle == 3)
assert(s.tool_from_pocket == 0)
assert(s.pocket_prepped == -1)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 3)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 3)
assert(s.tool_from_pocket == 0)
assert(s.pocket_prepped == 46) # random tc gives you pocket, which is the same as tool-table-array index
#
# Change to T2
#
c.mdi('m6')
wait_for_hal_pin('tool-change', True)
assert(h['tool-change'] == True)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 3)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 46)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 3)
assert(s.tool_from_pocket == 0)
assert(s.pocket_prepped == 46)
assert(abs(s.joint_position[0] -xtool) < EPSILON)
assert(abs(s.joint_position[1] -ytool) < EPSILON)
assert(abs(s.joint_position[2] -ztool) < EPSILON)
h['tool-changed'] = True
wait_for_hal_pin('tool-change', False)
h['tool-changed'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == -1)
#
# Prepare T12
#
c.mdi('t12')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 12)
assert(h['tool-prep-pocket'] == 9)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == -1)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 12)
assert(h['tool-prep-pocket'] == 9)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == 9)
#
# Prepare T2
# This tool is already in the spindle.
#
c.mdi('t2')
try:
wait_for_hal_pin('tool-prepare', True, timeout=5)
except RuntimeError:
# It *should* time out, no tool prep should be performed since the
# requested tool is already in the spindle.
pass
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == 0)
#
# Change to prepared tool (T2)
#
c.mdi('m6')
try:
wait_for_hal_pin('tool-change', True, timeout=5)
except RuntimeError:
# It *should* time out, no tool change should be performed since
# the prepared tool is already in the spindle.
pass
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 2)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == 0)
#
# Prepare T0
#
c.mdi('t0')
wait_for_hal_pin('tool-prepare', True)
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == True)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 2)
assert(h['tool-from-pocket'] == 46)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == 0)
h['tool-prepared'] = True
wait_for_hal_pin('tool-prepare', False)
h['tool-prepared'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 2)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == 2) # random tc gives you pocket, which is the same as tool-table-array index
#
# Change to T0
#
c.mdi('m6')
wait_for_hal_pin('tool-change', True)
assert(h['tool-change'] == True)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 2)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 2)
assert(h['tool-from-pocket'] == 46)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 2)
assert(s.tool_from_pocket == 46)
assert(s.pocket_prepped == 2)
h['tool-changed'] = True
wait_for_hal_pin('tool-change', False)
h['tool-changed'] = False
assert(h['tool-change'] == False)
assert(h['tool-prepare'] == False)
assert(h['tool-number'] == 0)
assert(h['tool-prep-number'] == 0)
assert(h['tool-prep-pocket'] == 0)
assert(h['tool-from-pocket'] == 0)
time.sleep(stat_poll_wait)
s.poll()
assert(s.tool_in_spindle == 0)
assert(s.tool_from_pocket == 0)
assert(s.pocket_prepped == -1)
sys.exit(0)

View File

@@ -0,0 +1,115 @@
[EMC]
VERSION = 1.1
#DEBUG = 0x0
DEBUG = 0xffffffff
[DISPLAY]
DISPLAY = ./test-ui.py
[FILTER]
#No Content
[RS274NGC]
PARAMETER_FILE = sim.var
USER_M_PATH = ./subs
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[HAL]
HALFILE = core_sim.hal
[HALUI]
#No Content
[TRAJ]
NO_FORCE_HOMING=1
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_ACCELERATION = 123.45
MAX_LINEAR_VELOCITY = 45.67
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 1
TOOL_CHANGE_POSITION = .111 .222 .333
[KINS]
KINEMATICS = trivkins
#This is a best-guess at the number of joints, it should be checked
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_Y]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_Z]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010

View File

@@ -0,0 +1 @@
../shared-test.sh

View File

@@ -0,0 +1,5 @@
#!/bin/bash
rm -f sim.var
rm -f simpockets.tbl
cp ../simpockets.tbl.save simpockets.tbl
linuxcnc -r test.ini

View File

@@ -0,0 +1,16 @@
T3 P0 D2.250000 Z-6.595331 ;2-1/4 face mill
T10 P6 Z-3.406343 ;other big jacobs chuck
T16 P3 ;little jacobs chuck
T12 P9 Z-4.596806 ;1/2 2fl long em
T6 P51 Z-0.950266 ;big jacobs chuck
T2 P46 D0.750000 Z-6.366394 ;3/4 2 flute
T1 P37 D0.750000 Z-5.319396 ;3/4 roughing
T7 P28 Z-2.979905 ;big albrecht drill chuck .25 drill
T11 P19 D0.125000 Z-6.307857 ;1/8 2fl end mill
T15 P5 Z-3.730620 ;little albrecht chuck spot drill
T0 P2 ;no tool
T14 P11 Z-5.305736 ;
T8 P54 Z-7.213145 ;V engraving tool
T9 P44 Z-6.163994 ;90 deg 3/8 mill-drill
T5 P35 Z-2.825524 ;long ER40 collet chuck
T4 P26 D0.375000 Z-5.307185 ;3/8 4fl carbide

View File

@@ -0,0 +1,6 @@
#!/bin/bash
TEST_DIR=$(dirname "$1")
cd "$TEST_DIR" || { echo "E: Could not change directory to '$TEST_DIR'"; exit 1; }
diff -u expected-gcode-output gcode-output

View File

@@ -0,0 +1,3 @@
T1 P1 D0.125000 Z+1.000000 ;
T10 P3 D0.500000 Z+3.000000 ;
T99999 P50 Z+2.000000 ;

29
tests/toolchanger/subs/M100 Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# This script (M100) is called to log the current coordinates and the
# current tool number and Tool Length Offset information to a log file,
# for testing purposes
#
TEST_DIR=$(dirname INI_FILE_NAME)
OUT_FILE=$TEST_DIR/gcode-output
P=$1
Q=$2
#echo P is $P >> $OUT_FILE
#echo Q is $Q >> $OUT_FILE
case $P in
0.000000) echo "X = $Q" >> "$OUT_FILE" ;;
1.000000) echo "Y = $Q" >> "$OUT_FILE" ;;
2.000000) echo "Z = $Q" >> "$OUT_FILE" ;;
3.000000) echo "toolno = $Q" >> "$OUT_FILE" ;;
4.000000) echo "tlo_z = $Q" >> "$OUT_FILE" ;;
5.000000) echo "" >> "$OUT_FILE" ;;
6.000000) echo "sequence number $Q" >> "$OUT_FILE" ;;
*)
echo "unknown P=$P (Q=$Q)" >> "$OUT_FILE"
exit 1;;
esac

View File

@@ -0,0 +1 @@
../../shared-checkresult

View File

@@ -0,0 +1,217 @@
sequence number 0.000000
X = 0.000000
Y = 0.000000
Z = 0.000000
toolno = 0.000000
tlo_z = 0.000000
sequence number 1.000000
X = 0.111000
Y = 0.222000
Z = 0.333000
toolno = 1.000000
tlo_z = 1.000000
sequence number 2.000000
X = 0.111000
Y = 0.222000
Z = -0.667000
toolno = 1.000000
tlo_z = 1.000000
sequence number 3.000000
X = 0.111000
Y = 0.222000
Z = -0.667000
toolno = 1.000000
tlo_z = 0.233000
sequence number 4.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 5.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 6.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 7.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 8.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 9.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 10.000000
tlo_z = 0.183000
sequence number 10.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.183000
sequence number 11.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.183000
sequence number 12.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.183000
sequence number 13.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.229500
sequence number 14.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 10.000000
tlo_z = 0.229500
sequence number 15.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 10.000000
tlo_z = 0.229500
sequence number 16.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 10.000000
tlo_z = 0.229500
sequence number 17.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 99999.000000
tlo_z = 0.229000
sequence number 18.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 19.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 20.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 21.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 22.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 23.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = -0.067000
sequence number 24.000000
X = 0.111000
Y = 0.222000
Z = 0.400000
toolno = 99999.000000
tlo_z = -0.067000
sequence number 25.000000
X = 0.111000
Y = 0.222000
Z = 0.400000
toolno = 1.000000
tlo_z = 0.033000
sequence number 26.000000
X = 0.111000
Y = 0.222000
Z = 0.300000
toolno = 1.000000
tlo_z = 0.033000
sequence number 27.000000
X = 0.111000
Y = 0.222000
Z = 0.300000
toolno = 10.000000
tlo_z = -0.017000
sequence number 28.000000
X = 0.111000
Y = 0.222000
Z = 0.350000
toolno = 10.000000
tlo_z = -0.017000
sequence number 29.000000
X = 0.111000
Y = 0.222000
Z = 0.350000
toolno = 99999.000000
tlo_z = -0.067000
sequence number 30.000000
X = 0.111000
Y = 0.222000
Z = 0.400000
toolno = 99999.000000
tlo_z = -0.067000

View File

@@ -0,0 +1,107 @@
[EMC]
#DEBUG = 0
DEBUG = 0x7fffffff
VERSION = 1.1
[DISPLAY]
DISPLAY = linuxcncrsh
PROGRAM_PREFIX = ../../subs
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = sim.var
USER_M_PATH = ../../subs
SUBROUTINE_PATH = ../../subs
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[HAL]
HALFILE = LIB:core_sim.hal
[TRAJ]
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_VELOCITY = 4
NO_FORCE_HOMING = 1
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 0
TOOL_CHANGE_POSITION = 0.111 0.222 0.333
[AXIS_X]
HOME = 0.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[AXIS_Y]
HOME = 0.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[AXIS_Z]
HOME = 0.0
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010

View File

@@ -0,0 +1 @@
../shared-test.sh

View File

@@ -0,0 +1 @@
../../shared-checkresult

View File

@@ -0,0 +1,217 @@
sequence number 0.000000
X = 0.000000
Y = 0.000000
Z = 0.000000
toolno = -1.000000
tlo_z = 0.000000
sequence number 1.000000
X = 0.111000
Y = 0.222000
Z = 0.333000
toolno = 1.000000
tlo_z = 1.000000
sequence number 2.000000
X = 0.111000
Y = 0.222000
Z = -0.667000
toolno = 1.000000
tlo_z = 1.000000
sequence number 3.000000
X = 0.111000
Y = 0.222000
Z = -0.667000
toolno = 1.000000
tlo_z = 0.233000
sequence number 4.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 5.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 6.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 7.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 8.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 1.000000
tlo_z = 0.233000
sequence number 9.000000
X = 0.111000
Y = 0.222000
Z = 0.100000
toolno = 10.000000
tlo_z = 0.183000
sequence number 10.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.183000
sequence number 11.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.183000
sequence number 12.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.183000
sequence number 13.000000
X = 0.111000
Y = 0.222000
Z = 0.150000
toolno = 10.000000
tlo_z = 0.229500
sequence number 14.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 10.000000
tlo_z = 0.229500
sequence number 15.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 10.000000
tlo_z = 0.229500
sequence number 16.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 10.000000
tlo_z = 0.229500
sequence number 17.000000
X = 0.111000
Y = 0.222000
Z = 0.103500
toolno = 99999.000000
tlo_z = 0.229000
sequence number 18.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 19.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 20.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 21.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 22.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = 0.229000
sequence number 23.000000
X = 0.111000
Y = 0.222000
Z = 0.104000
toolno = 99999.000000
tlo_z = -0.067000
sequence number 24.000000
X = 0.111000
Y = 0.222000
Z = 0.400000
toolno = 99999.000000
tlo_z = -0.067000
sequence number 25.000000
X = 0.111000
Y = 0.222000
Z = 0.400000
toolno = 1.000000
tlo_z = 0.033000
sequence number 26.000000
X = 0.111000
Y = 0.222000
Z = 0.300000
toolno = 1.000000
tlo_z = 0.033000
sequence number 27.000000
X = 0.111000
Y = 0.222000
Z = 0.300000
toolno = 10.000000
tlo_z = -0.017000
sequence number 28.000000
X = 0.111000
Y = 0.222000
Z = 0.350000
toolno = 10.000000
tlo_z = -0.017000
sequence number 29.000000
X = 0.111000
Y = 0.222000
Z = 0.350000
toolno = 99999.000000
tlo_z = -0.067000
sequence number 30.000000
X = 0.111000
Y = 0.222000
Z = 0.400000
toolno = 99999.000000
tlo_z = -0.067000

View File

@@ -0,0 +1,107 @@
[EMC]
#DEBUG = 0
DEBUG = 0x7fffffff
VERSION = 1.1
[DISPLAY]
DISPLAY = linuxcncrsh
PROGRAM_PREFIX = ../../subs
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = sim.var
USER_M_PATH = ../../subs
SUBROUTINE_PATH = ../../subs
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[HAL]
HALFILE = LIB:core_sim.hal
[TRAJ]
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_VELOCITY = 4
NO_FORCE_HOMING = 1
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 1
TOOL_CHANGE_POSITION = 0.111 0.222 0.333
[AXIS_X]
HOME = 0.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[AXIS_Y]
HOME = 0.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[AXIS_Z]
HOME = 0.0
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010

View File

@@ -0,0 +1 @@
../shared-test.sh

View File

@@ -0,0 +1,164 @@
#!/bin/bash
set -x
rm -f sim.var
# reset the tool table to a known starting configuration
rm -f simpockets.tbl
cp ../../simpockets.tbl.original simpockets.tbl
rm -f gcode-output
if nc -z localhost 5007; then
echo "E: Process already listening on port 5007. Exiting"
exit 1
fi
linuxcnc -r sim.ini &
# let linuxcnc come up
TOGO=80
while [ $TOGO -gt 0 ]; do
echo "I: trying to connect to linuxcncrsh TOGO=$TOGO"
if nc -z localhost 5007; then
break
fi
sleep 0.25
TOGO=$((TOGO - 1))
done
if [ $TOGO -eq 0 ]; then
echo "I: connection to linuxcncrsh timed out"
exit 1
fi
(
function introspect() {
SEQUENCE_NUMBER=$1
echo "set mdi m100 P6 Q$SEQUENCE_NUMBER" # sequence number
echo "set mdi m100 P0 Q#5420" # X
echo "set mdi m100 P1 Q#5421" # Y
echo "set mdi m100 P2 Q#5422" # Z
echo "set mdi m100 P3 Q#5400" # toolno
echo "set mdi m100 P4 Q#5403" # TLO z
echo "set mdi m100 P5" # blank line
}
echo "hello EMC mt 1.0"
echo "set enable EMCTOO"
echo "set estop off"
echo "set machine on"
echo "set mode mdi"
introspect 0
echo "set mdi t1 m6"
introspect 1
echo "set mdi g43"
introspect 2
echo "set mdi g10 l10 p1 z.1"
introspect 3
echo "set mdi g43"
introspect 4
echo "set mdi g10 l10 p10 z.15"
introspect 5
echo "set mdi g43"
introspect 6
echo "set mdi g10 l10 p99999 z.2"
introspect 7
echo "set mdi g43"
introspect 8
echo "set mdi t10 m6"
introspect 9
echo "set mdi g43"
introspect 10
echo "set mdi g10 l10 p1 z.103"
introspect 11
echo "set mdi g43"
introspect 12
echo "set mdi g10 l10 p10 z.1035"
introspect 13
echo "set mdi g43"
introspect 14
echo "set mdi g10 l10 p99999 z.104"
introspect 15
echo "set mdi g43"
introspect 16
echo "set mdi t99999 m6"
introspect 17
echo "set mdi g43"
introspect 18
echo "set mdi g10 l10 p1 z.3"
introspect 19
echo "set mdi g43"
introspect 20
echo "set mdi g10 l10 p10 z.35"
introspect 21
echo "set mdi g43"
introspect 22
echo "set mdi g10 l10 p99999 z.4"
introspect 23
echo "set mdi g43"
introspect 24
echo "set mdi t1 m6"
introspect 25
echo "set mdi g43"
introspect 26
echo "set mdi t10 m6"
introspect 27
echo "set mdi g43"
introspect 28
echo "set mdi t99999 m6"
introspect 29
echo "set mdi g43"
introspect 30
# wait for linuxcnc to finish
echo "set wait done"
echo "shutdown"
) | nc localhost 5007
# wait for linuxcnc to finish
wait
exit 0