Import LinuxCNC source tree
This commit is contained in:
3
tests/tlo/.gitignore
vendored
Normal file
3
tests/tlo/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
sim.var
|
||||
sim.var.bak
|
||||
simpockets.tbl
|
||||
2
tests/tlo/checkresult
Executable file
2
tests/tlo/checkresult
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exit 0 # test failure is indicated by test.sh exit value
|
||||
102
tests/tlo/g43-test.ini
Normal file
102
tests/tlo/g43-test.ini
Normal file
@@ -0,0 +1,102 @@
|
||||
[EMC]
|
||||
VERSION = 1.1
|
||||
DEBUG = 0x0
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./test-ui.py
|
||||
|
||||
[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
|
||||
MDI_QUEUED_COMMANDS=10000
|
||||
|
||||
[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
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = simpockets.tbl
|
||||
TOOL_CHANGE_QUILL_UP = 1
|
||||
RANDOM_TOOLCHANGER = 0
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins
|
||||
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 = -4.0
|
||||
MAX_LIMIT = 4.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 = -4.0
|
||||
MAX_LIMIT = 4.0
|
||||
FERROR = 0.050
|
||||
MIN_FERROR = 0.010
|
||||
63
tests/tlo/mod_core_sim.hal
Normal file
63
tests/tlo/mod_core_sim.hal
Normal file
@@ -0,0 +1,63 @@
|
||||
setexact_for_test_suite_only
|
||||
|
||||
# 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-prepare => iocontrol.0.tool-prepared
|
||||
|
||||
net tool-change <= iocontrol.0.tool-change
|
||||
net tool-change => 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
|
||||
|
||||
3
tests/tlo/postgui.hal
Normal file
3
tests/tlo/postgui.hal
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
net tool-number => python-ui.tool-number
|
||||
|
||||
11
tests/tlo/simpockets.tbl.original
Normal file
11
tests/tlo/simpockets.tbl.original
Normal file
@@ -0,0 +1,11 @@
|
||||
T100 P1 D0.125000 X+2.000000 Z+1.000000 ;
|
||||
T200 P3 D0.125000 X+0.200000 Z+0.100000 ;
|
||||
T300 P5 D0.125000 X+0.020000 Z+0.010000 ;
|
||||
T400 P7 D0.125000 X+0.002000 Z+0.001000 ;
|
||||
T500 P9 D0.125000 X+0.000200 Z+0.000100 ;
|
||||
T600 P11 D0.125000 X+0.000020 Z+0.000010 ;
|
||||
T700 P13 D0.125000 X+0.000002 Z+0.000001 ;
|
||||
T800 P15 D0.125000 X+0.000000 Z+0.000000 ;
|
||||
T900 P17 D0.125000 X+0.000000 Z+0.000000 ;
|
||||
T999 P2 D0.500000 X+0.000000 Z+0.000000 ;
|
||||
T99999 P50 Z+2.000000 ;
|
||||
350
tests/tlo/test-ui.py
Executable file
350
tests/tlo/test-ui.py
Executable file
@@ -0,0 +1,350 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import hal
|
||||
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import math
|
||||
|
||||
|
||||
# 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 didn't get to %f" % (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, expected %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)
|
||||
while c.wait_complete() == -1:
|
||||
pass
|
||||
|
||||
# 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 math.fabs(param_value - expected_value) > 0.000001:
|
||||
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, pin[pin_name]))
|
||||
sys.exit(1)
|
||||
time.sleep(0.010)
|
||||
|
||||
|
||||
def verify_tool(tool, x, y, z, a, b, c, u, v, w, diameter, front_angle, back_angle):
|
||||
wait_for_pin_value('tool-number', tool)
|
||||
verify_interp_param(5400, tool)
|
||||
|
||||
# verify the current location, as offset by TLO
|
||||
verify_interp_param(5420, x)
|
||||
verify_interp_param(5421, y)
|
||||
verify_interp_param(5422, z)
|
||||
verify_interp_param(5423, a)
|
||||
verify_interp_param(5424, b)
|
||||
verify_interp_param(5425, c)
|
||||
verify_interp_param(5426, u)
|
||||
verify_interp_param(5427, v)
|
||||
verify_interp_param(5428, w)
|
||||
|
||||
# verify tool diameter & angles
|
||||
verify_interp_param(5410, diameter)
|
||||
verify_interp_param(5411, front_angle)
|
||||
verify_interp_param(5412, back_angle)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# connect to HAL
|
||||
# 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.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()
|
||||
|
||||
|
||||
#
|
||||
# this is a non-random toolchanger, so it starts with no tool in the spindle
|
||||
# make sure the startup condition is sane
|
||||
#
|
||||
|
||||
print("*** starting up, expecting T0 in spindle & no TLO")
|
||||
|
||||
verify_tool(
|
||||
tool=0,
|
||||
x=0, y=0, z=0,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** load T100 but dont apply TLO")
|
||||
|
||||
c.mdi('t100 m6')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=0, y=0, z=0,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** apply TLO of loaded tool (T100)")
|
||||
|
||||
c.mdi('g43')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2, y=0, z=-1,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** apply TLO of T200 instead")
|
||||
|
||||
c.mdi('g43 h200')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-0.2, y=0, z=-0.1,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** try to add in TLO with no H-word, should fail")
|
||||
|
||||
# first drain the error queue
|
||||
start = time.time()
|
||||
while (time.time() - start) < 2:
|
||||
error = e.poll()
|
||||
if error == None:
|
||||
# no more queued errors, continue with test
|
||||
break
|
||||
|
||||
c.mdi('g43.2')
|
||||
c.wait_complete()
|
||||
error = e.poll()
|
||||
if error[1] != "G43.2: No axes specified and H word missing":
|
||||
print("G43.2 with missing H-word did not produce expected error")
|
||||
print("got [%s]" % error[1])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
print("*** add in TLO of T100")
|
||||
|
||||
c.mdi('g43.2 h100')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2.2, y=0, z=-1.1,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** add in TLO of T300")
|
||||
|
||||
c.mdi('g43.2 h300')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2.22, y=0, z=-1.11,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** add in TLO of T400")
|
||||
|
||||
c.mdi('g43.2 h400')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2.222, y=0, z=-1.111,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
print("*** add in TLO of T400 again")
|
||||
|
||||
c.mdi('g43.2 h400')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2.224, y=0, z=-1.112,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
print("*** now let's try it rotated. first, just rotate but don't change the tlo")
|
||||
|
||||
c.mdi('g10 l2 p1 r33')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2.224 * math.cos(math.radians(33)), y=2.224 * math.sin(math.radians(33)), z=-1.112,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
print("*** clear tlo")
|
||||
|
||||
c.mdi('g49')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-0, y=0, z=0,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
print("*** apply t100")
|
||||
|
||||
c.mdi('g43 h100')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2*math.cos(math.radians(33)), y=2*math.sin(math.radians(33)), z=-1,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
print("*** add in t200")
|
||||
|
||||
c.mdi('g43.2 h200')
|
||||
c.wait_complete()
|
||||
|
||||
verify_tool(
|
||||
tool=100,
|
||||
x=-2.2*math.cos(math.radians(33)), y=2.2*math.sin(math.radians(33)), z=-1.1,
|
||||
a=0, b=0, c=0,
|
||||
u=0, v=0, w=0,
|
||||
diameter=0.125,
|
||||
front_angle=0,
|
||||
back_angle=0
|
||||
)
|
||||
|
||||
|
||||
|
||||
# if we get here it all worked!
|
||||
sys.exit(0)
|
||||
|
||||
6
tests/tlo/test.sh
Executable file
6
tests/tlo/test.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp -f simpockets.tbl.original simpockets.tbl
|
||||
rm -f sim.var
|
||||
|
||||
exec linuxcnc -r g43-test.ini
|
||||
Reference in New Issue
Block a user