Import LinuxCNC source tree
This commit is contained in:
2
tests/halui/.gitignore
vendored
Normal file
2
tests/halui/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
sim.var.bak
|
||||
sim.var
|
||||
2
tests/halui/checkresult
Executable file
2
tests/halui/checkresult
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exit 0 # test failure is indicated by test.sh exit value
|
||||
1
tests/halui/jogging/checkresult
Symbolic link
1
tests/halui/jogging/checkresult
Symbolic link
@@ -0,0 +1 @@
|
||||
../checkresult
|
||||
101
tests/halui/jogging/halui.ini
Normal file
101
tests/halui/jogging/halui.ini
Normal file
@@ -0,0 +1,101 @@
|
||||
[EMC]
|
||||
DEBUG = 0x7fffffff
|
||||
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 = LIB: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
|
||||
|
||||
[AXIS_X]
|
||||
HOME = 0.000
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
|
||||
[AXIS_Y]
|
||||
HOME = 0.000
|
||||
MIN_LIMIT = -40.0
|
||||
MAX_LIMIT = 40.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
|
||||
[AXIS_Z]
|
||||
HOME = 0.0
|
||||
MIN_LIMIT = -4.0
|
||||
MAX_LIMIT = 4.0
|
||||
MAX_VELOCITY = 4
|
||||
MAX_ACCELERATION = 1000.0
|
||||
|
||||
[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
|
||||
|
||||
89
tests/halui/jogging/postgui.hal
Normal file
89
tests/halui/jogging/postgui.hal
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
|
||||
setp halui.joint.jog-speed 100
|
||||
|
||||
|
||||
net jog-selected-minus <= python-ui.jog-selected-minus
|
||||
net jog-selected-minus => halui.joint.selected.minus
|
||||
|
||||
net jog-selected-plus <= python-ui.jog-selected-plus
|
||||
net jog-selected-plus => halui.joint.selected.plus
|
||||
|
||||
|
||||
net joint-0-home <= python-ui.joint-0-home
|
||||
net joint-0-home => halui.joint.0.home
|
||||
|
||||
net joint-0-homed <= halui.joint.0.is-homed
|
||||
net joint-0-homed => python-ui.joint-0-homed
|
||||
|
||||
net joint-0-select <= python-ui.joint-0-select
|
||||
net joint-0-select => halui.joint.0.select
|
||||
|
||||
net joint-0-selected <= halui.joint.0.is-selected
|
||||
net joint-0-selected => python-ui.joint-0-selected
|
||||
|
||||
net joint-0-velocity <= joint.0.vel-cmd
|
||||
net joint-0-velocity => python-ui.joint-0-velocity
|
||||
|
||||
net joint-0-jog-plus <= python-ui.joint-0-jog-plus
|
||||
net joint-0-jog-plus => halui.joint.0.plus
|
||||
|
||||
net joint-0-jog-minus <= python-ui.joint-0-jog-minus
|
||||
net joint-0-jog-minus => halui.joint.0.minus
|
||||
|
||||
net Xpos => python-ui.joint-0-position
|
||||
|
||||
|
||||
net joint-1-home <= python-ui.joint-1-home
|
||||
net joint-1-home => halui.joint.1.home
|
||||
|
||||
net joint-1-homed <= halui.joint.1.is-homed
|
||||
net joint-1-homed => python-ui.joint-1-homed
|
||||
|
||||
net joint-1-select <= python-ui.joint-1-select
|
||||
net joint-1-select => halui.joint.1.select
|
||||
|
||||
net joint-1-selected <= halui.joint.1.is-selected
|
||||
net joint-1-selected => python-ui.joint-1-selected
|
||||
|
||||
net joint-1-velocity <= joint.1.vel-cmd
|
||||
net joint-1-velocity => python-ui.joint-1-velocity
|
||||
|
||||
net joint-1-jog-plus <= python-ui.joint-1-jog-plus
|
||||
net joint-1-jog-plus => halui.joint.1.plus
|
||||
|
||||
net joint-1-jog-minus <= python-ui.joint-1-jog-minus
|
||||
net joint-1-jog-minus => halui.joint.1.minus
|
||||
|
||||
net Ypos => python-ui.joint-1-position
|
||||
|
||||
|
||||
net joint-2-home <= python-ui.joint-2-home
|
||||
net joint-2-home => halui.joint.2.home
|
||||
|
||||
net joint-2-homed <= halui.joint.2.is-homed
|
||||
net joint-2-homed => python-ui.joint-2-homed
|
||||
|
||||
net joint-2-select <= python-ui.joint-2-select
|
||||
net joint-2-select => halui.joint.2.select
|
||||
|
||||
net joint-2-selected <= halui.joint.2.is-selected
|
||||
net joint-2-selected => python-ui.joint-2-selected
|
||||
|
||||
net joint-2-velocity <= joint.2.vel-cmd
|
||||
net joint-2-velocity => python-ui.joint-2-velocity
|
||||
|
||||
net joint-2-jog-plus <= python-ui.joint-2-jog-plus
|
||||
net joint-2-jog-plus => halui.joint.2.plus
|
||||
|
||||
net joint-2-jog-minus <= python-ui.joint-2-jog-minus
|
||||
net joint-2-jog-minus => halui.joint.2.minus
|
||||
|
||||
net Zpos => python-ui.joint-2-position
|
||||
|
||||
net motion-mode-joint <= python-ui.motion-mode-joint
|
||||
net motion-mode-joint => halui.mode.joint
|
||||
|
||||
net motion-mode-is-joint <= python-ui.motion-mode-is-joint
|
||||
net motion-mode-is-joint => halui.mode.is-joint
|
||||
|
||||
387
tests/halui/jogging/test-ui.py
Executable file
387
tests/halui/jogging/test-ui.py
Executable file
@@ -0,0 +1,387 @@
|
||||
#!/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 = 10.0
|
||||
|
||||
|
||||
# unbuffer stdout
|
||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w')
|
||||
|
||||
|
||||
program_start = time.time()
|
||||
|
||||
def log(msg):
|
||||
delta_t = time.time() - program_start;
|
||||
print("%.3f: %s" % (delta_t, msg))
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def introspect(h):
|
||||
os.system("halcmd show pin halui")
|
||||
os.system("halcmd show pin python-ui")
|
||||
os.system("halcmd show sig")
|
||||
|
||||
|
||||
def home_joint(name):
|
||||
log(" homing %s" % name)
|
||||
|
||||
h[name + '-home'] = 1
|
||||
start = time.time()
|
||||
while (h[name + '-homed'] == 0) and ((time.time() - start) < timeout):
|
||||
time.sleep(0.1)
|
||||
|
||||
if h[name + '-homed'] == 0:
|
||||
log("failed to home %s in halui" % name)
|
||||
introspect(h)
|
||||
sys.exit(1)
|
||||
|
||||
h[name + '-home'] = 0
|
||||
|
||||
|
||||
def select_joint(name, deassert=True):
|
||||
log(" selecting %s" % name)
|
||||
|
||||
h[name + '-select'] = 1
|
||||
start = time.time()
|
||||
while (h[name + '-selected'] == 0) and ((time.time() - start) < timeout):
|
||||
time.sleep(0.1)
|
||||
|
||||
if h[name + '-selected'] == 0:
|
||||
log("failed to select %s in halui" % name)
|
||||
introspect(h)
|
||||
sys.exit(1)
|
||||
|
||||
if deassert:
|
||||
h[name + '-select'] = 0
|
||||
|
||||
|
||||
def jog_minus(name, target):
|
||||
start_position = h[name + '-position']
|
||||
log(" jogging %s negative: to %.3f" % (name, target))
|
||||
|
||||
h['jog-selected-minus'] = 1
|
||||
|
||||
start = time.time()
|
||||
while (h[name + '-position'] > target) and ((time.time() - start) < timeout):
|
||||
time.sleep(0.1)
|
||||
|
||||
if h[name + '-position'] > target:
|
||||
log("failed to jog %s to %.3f (timed out at %.3f after %.3f seconds)" % (name, target, h[name + '-position'], timeout))
|
||||
introspect(h)
|
||||
sys.exit(1)
|
||||
|
||||
h['jog-selected-minus'] = 0
|
||||
|
||||
log(" jogged %s negative past target %.3f" % (name, target))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def jog_plus(name, target):
|
||||
start_position = h[name + '-position']
|
||||
log(" jogging %s positive: to %.3f" % (name, target))
|
||||
|
||||
h['jog-selected-plus'] = 1
|
||||
|
||||
start = time.time()
|
||||
while (h[name + '-position'] < target) and ((time.time() - start) < timeout):
|
||||
time.sleep(0.1)
|
||||
|
||||
if h[name + '-position'] < target:
|
||||
log("failed to jog %s to %.3f (timed out at %.3f after %.3f seconds)" % (name, target, h[name + '-position'], timeout))
|
||||
introspect(h)
|
||||
sys.exit(1)
|
||||
|
||||
h['jog-selected-plus'] = 0
|
||||
|
||||
log(" jogged %s positive past target %.3f" % (name, target))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def wait_for_pin_value(pin_name, target_value, timeout=2.0):
|
||||
start_time = time.time()
|
||||
while h[pin_name] != target_value:
|
||||
if (time.time() - start_time) > timeout:
|
||||
log("Error: pin %s didn't reach target value %s!" % (pin_name, target_value))
|
||||
log("pin value is %s at timeout after %.3f seconds" % (h[pin_value], timeout))
|
||||
sys.exit(1)
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
def wait_for_joint_to_stop(joint_number):
|
||||
pos_pin = 'joint-%d-position' % joint_number
|
||||
vel_pin = 'joint-%d-velocity' % joint_number
|
||||
start_time = time.time()
|
||||
prev_pos = h[pos_pin]
|
||||
while (time.time() - start_time) < timeout:
|
||||
time.sleep(0.1)
|
||||
new_pos = h[pos_pin]
|
||||
if new_pos == prev_pos and h[vel_pin] == 0.0:
|
||||
log("joint %d stopped jogging" % joint_number)
|
||||
return
|
||||
prev_pos = new_pos
|
||||
log("Error: joint didn't stop jogging!")
|
||||
log("joint %d is at %.3f %.3f seconds after reaching target (prev_pos=%.3f, val=%.3f)" % (joint_number, h[pos_pin], timeout, prev_pos, h[vel_pin]))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def jog_joint(joint_number, target):
|
||||
success = True
|
||||
|
||||
joint = []
|
||||
for j in range(0,3):
|
||||
joint.append(h['joint-%d-position' % j])
|
||||
|
||||
name = 'joint-%d' % joint_number
|
||||
|
||||
log("jogging %s to %.3f" % (name, target))
|
||||
select_joint(name)
|
||||
|
||||
if h[name + '-position'] > target:
|
||||
jog_minus(name, target)
|
||||
else:
|
||||
jog_plus(name, target)
|
||||
|
||||
for j in range(0,3):
|
||||
pin_name = 'joint-%d-position' % j
|
||||
if j == joint_number:
|
||||
if joint[j] == h[pin_name]:
|
||||
log("joint %d didn't move but should have!" % j)
|
||||
success = False
|
||||
else:
|
||||
if joint[j] != h[pin_name]:
|
||||
log("joint %d moved from %.3f to %.3f but should not have!" % (j, joint[j], h[pin_name]))
|
||||
success = False
|
||||
|
||||
wait_for_joint_to_stop(joint_number)
|
||||
|
||||
if not success:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
#
|
||||
# set up pins
|
||||
# shell out to halcmd to make nets to halui and motion
|
||||
#
|
||||
|
||||
h = hal.component("python-ui")
|
||||
|
||||
h.newpin("joint-0-home", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-0-homed", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("joint-0-select", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-0-selected", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("joint-0-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-0-velocity", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-0-jog-plus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-0-jog-minus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
|
||||
h.newpin("joint-1-home", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-1-homed", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("joint-1-select", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-1-selected", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("joint-1-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-1-velocity", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-1-jog-plus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-1-jog-minus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
|
||||
h.newpin("joint-2-home", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-2-homed", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("joint-2-select", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-2-selected", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("joint-2-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-2-velocity", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-2-jog-plus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("joint-2-jog-minus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
|
||||
h.newpin("jog-selected-minus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("jog-selected-plus", hal.HAL_BIT, hal.HAL_OUT)
|
||||
|
||||
h.newpin("motion-mode-joint", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("motion-mode-is-joint", hal.HAL_BIT, 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.wait_complete()
|
||||
|
||||
# Select joints 1 and 2, but do not de-assert the .select pins.
|
||||
select_joint('joint-1', deassert=False)
|
||||
select_joint('joint-2', deassert=False)
|
||||
|
||||
# Home all the joints. This should work fine.
|
||||
home_joint('joint-0')
|
||||
home_joint('joint-1')
|
||||
home_joint('joint-2')
|
||||
|
||||
# Deassert the .select pins for joints 1 and 2.
|
||||
h['joint-1-select'] = 0
|
||||
h['joint-2-select'] = 0
|
||||
|
||||
# The machine is homed and all the .joint.N.select pins are deasserted.
|
||||
c.mode(linuxcnc.MODE_MANUAL)
|
||||
c.wait_complete()
|
||||
|
||||
h['motion-mode-joint'] = 1
|
||||
wait_for_pin_value('motion-mode-is-joint', 1, 2.0)
|
||||
h['motion-mode-joint'] = 0
|
||||
|
||||
|
||||
#
|
||||
# First some simple single-axis jog & stop. Test each axis jogging in each
|
||||
# direction, one at a time.
|
||||
#
|
||||
# These jog_joint() functions will exit with a return value of 1 if
|
||||
# something goes wrong, signalling test failure.
|
||||
#
|
||||
|
||||
jog_joint(0, -0.5)
|
||||
jog_joint(0, 0.0)
|
||||
|
||||
jog_joint(1, -0.5)
|
||||
jog_joint(1, 0.0)
|
||||
|
||||
jog_joint(2, -0.5)
|
||||
jog_joint(2, 0.0)
|
||||
|
||||
|
||||
#
|
||||
# Next try selecting a joint and jogging it with the "jog selected" pins,
|
||||
# then changing which joint is selected. The expected behavior when
|
||||
# changing which joint is selected is that the old joint stops jogging and
|
||||
# the new one starts jogging.
|
||||
#
|
||||
# We do this while jogging yet a third joint using its private, per-joint
|
||||
# jog pins, to verify that it is unaffected by all the drama.
|
||||
#
|
||||
|
||||
name0 = 'joint-0'
|
||||
name1 = 'joint-1'
|
||||
name2 = 'joint-2'
|
||||
|
||||
start_position0 = h[name0 + '-position']
|
||||
start_position1 = h[name1 + '-position']
|
||||
start_position2 = h[name2 + '-position']
|
||||
|
||||
print("%s starting at %.3f" % (name0, start_position0))
|
||||
print("%s starting at %.3f" % (name1, start_position1))
|
||||
print("%s starting at %.3f" % (name2, start_position2))
|
||||
|
||||
|
||||
#
|
||||
# start joint0 jogging in the positive direction
|
||||
#
|
||||
|
||||
print("jogging %s positive using the private per-joint jog pins" % name0)
|
||||
h[name0 + '-jog-plus'] = 1
|
||||
|
||||
# wait for this joint to come up to speed
|
||||
start = time.time()
|
||||
while (h[name0 + '-velocity'] <= 0) and ((time.time() - start) < timeout):
|
||||
time.sleep(0.1)
|
||||
if h[name0 + '-velocity'] <= 0:
|
||||
print("%s did not start jogging" % name0)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
#
|
||||
# start the selected joint1 jogging in the negative direction
|
||||
#
|
||||
|
||||
print("jogging selected joint (%s) negative" % (name1))
|
||||
select_joint(name1)
|
||||
h['jog-selected-minus'] = 1
|
||||
|
||||
# wait for this joint to start moving
|
||||
start = time.time()
|
||||
while (h[name1 + '-velocity'] >= 0) and ((time.time() - start) < timeout):
|
||||
time.sleep(0.1)
|
||||
if h[name1 + '-velocity'] >= 0:
|
||||
print("%s did not start jogging" % name1)
|
||||
sys.exit(1)
|
||||
|
||||
if h[name0 + '-velocity'] <= 0:
|
||||
print("%s stopped jogging" % name0)
|
||||
sys.exit(1)
|
||||
|
||||
if h[name1 + '-position'] >= start_position1:
|
||||
print("%s was selected but did not jog negative (start=%.3f, end=%.3f)" % (name1, start_position1, h[name1 + '-position']))
|
||||
sys.exit(1)
|
||||
|
||||
if h[name2 + '-position'] != start_position2:
|
||||
print("%s was not selected but moved (start=%.3f, end=%.3f)" % (name2, start_position2, h[name2 + '-position']))
|
||||
sys.exit(1)
|
||||
|
||||
print("%s was selected and jogged, %s was not selected and stayed still" % (name1, name2))
|
||||
|
||||
|
||||
start_position1 = h[name1 + '-position']
|
||||
start_position2 = h[name2 + '-position']
|
||||
|
||||
start_velocity1 = h[name1 + '-velocity']
|
||||
start_velocity2 = h[name2 + '-velocity']
|
||||
|
||||
print("selecting %s" % name2)
|
||||
select_joint(name2)
|
||||
|
||||
wait_for_joint_to_stop(1)
|
||||
|
||||
if h[name0 + '-velocity'] <= 0:
|
||||
print("%s stopped jogging" % name0)
|
||||
sys.exit(1)
|
||||
|
||||
if h[name1 + '-velocity'] != 0:
|
||||
print("%s was deselected but did not stop (start_vel=%.3f, end_vel=%.3f)" % (name1, start_velocity1, h[name1 + '-velocity']))
|
||||
sys.exit(1)
|
||||
|
||||
if h[name2 + '-velocity'] >= 0:
|
||||
print("%s was selected but did not move (start_vel=%.3f, end_vel=%.3f)" % (name2, start_velocity2, h[name2 + '-velocity']))
|
||||
sys.exit(1)
|
||||
|
||||
print("%s was deselected and stopped, %s was selected and jogged" % (name1, name2))
|
||||
|
||||
|
||||
start_velocity1 = h[name1 + '-velocity']
|
||||
start_velocity2 = h[name2 + '-velocity']
|
||||
|
||||
print("stopping jog")
|
||||
h['jog-selected-minus'] = 0
|
||||
|
||||
wait_for_joint_to_stop(2)
|
||||
|
||||
if h[name0 + '-velocity'] <= 0:
|
||||
print("%s stopped jogging" % name0)
|
||||
sys.exit(1)
|
||||
|
||||
if h[name1 + '-velocity'] != 0:
|
||||
print("%s started moving again (start_vel=%.3f, end_vel=%.3f)" % (name1, start_velocity1, h[name1 + '-velocity']))
|
||||
sys.exit(1)
|
||||
|
||||
if h[name2 + '-velocity'] != 0:
|
||||
print("%s did not stop (start_vel=%.3f, end_vel=%.3f)" % (name2, start_velocity2, h[name2 + '-velocity']))
|
||||
sys.exit(1)
|
||||
|
||||
print("%s stopped" % name2)
|
||||
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
1
tests/halui/jogging/test.sh
Symbolic link
1
tests/halui/jogging/test.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../shared-test.sh
|
||||
1
tests/halui/mdi/checkresult
Symbolic link
1
tests/halui/mdi/checkresult
Symbolic link
@@ -0,0 +1 @@
|
||||
../checkresult
|
||||
103
tests/halui/mdi/halui.ini
Normal file
103
tests/halui/mdi/halui.ini
Normal file
@@ -0,0 +1,103 @@
|
||||
[EMC]
|
||||
VERSION = 1.1
|
||||
DEBUG = 0x7fffffff
|
||||
|
||||
[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 = LIB:core_sim.hal
|
||||
POSTGUI_HALFILE = postgui.hal
|
||||
|
||||
[HALUI]
|
||||
MDI_COMMAND = g0 x-1 y0 z0
|
||||
MDI_COMMAND = g0 x1
|
||||
MDI_COMMAND = g0 y2
|
||||
MDI_COMMAND = g0 z3
|
||||
|
||||
[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
|
||||
|
||||
[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
|
||||
26
tests/halui/mdi/postgui.hal
Normal file
26
tests/halui/mdi/postgui.hal
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
net mdi-0 <= python-ui.mdi-0
|
||||
net mdi-0 => halui.mdi-command-00
|
||||
|
||||
net mdi-1 <= python-ui.mdi-1
|
||||
net mdi-1 => halui.mdi-command-01
|
||||
|
||||
net mdi-2 <= python-ui.mdi-2
|
||||
net mdi-2 => halui.mdi-command-02
|
||||
|
||||
net mdi-3 <= python-ui.mdi-3
|
||||
net mdi-3 => halui.mdi-command-03
|
||||
|
||||
net Xpos => python-ui.joint-0-position
|
||||
net Ypos => python-ui.joint-1-position
|
||||
net Zpos => python-ui.joint-2-position
|
||||
|
||||
net halui-mode-is-manual <= halui.mode.is-manual
|
||||
net halui-mode-is-manual => python-ui.is-manual
|
||||
|
||||
net halui-mode-is-auto <= halui.mode.is-auto
|
||||
net halui-mode-is-auto => python-ui.is-auto
|
||||
|
||||
net halui-mode-is-mdi <= halui.mode.is-mdi
|
||||
net halui-mode-is-mdi => python-ui.is-mdi
|
||||
|
||||
175
tests/halui/mdi/test-ui.py
Executable file
175
tests/halui/mdi/test-ui.py
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import hal
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import math
|
||||
|
||||
program_start = time.time()
|
||||
|
||||
def log(msg):
|
||||
delta_t = time.time() - program_start;
|
||||
print("%.3f: %s" % (delta_t, msg))
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def introspect():
|
||||
os.system("halcmd show pin halui")
|
||||
os.system("halcmd show pin python-ui")
|
||||
os.system("halcmd show sig")
|
||||
|
||||
|
||||
def wait_for_joint_to_stop_at(joint, target):
|
||||
timeout = 10.0
|
||||
tolerance = 0.0001
|
||||
|
||||
start = time.time()
|
||||
|
||||
curr_pos = 0;
|
||||
while ((time.time() - start) < timeout):
|
||||
prev_pos = curr_pos
|
||||
curr_pos = h['joint-%d-position' % joint]
|
||||
vel = curr_pos - prev_pos
|
||||
error = math.fabs(curr_pos - target)
|
||||
if (error < tolerance) and (vel == 0):
|
||||
log("joint %d stopped at %.3f" % (joint, target))
|
||||
return
|
||||
time.sleep(0.1)
|
||||
log("timeout waiting for joint %d to stop at %.3f (pos=%.3f, vel=%.3f)" % (joint, target, curr_pos, vel))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def wait_for_task_mode(target):
|
||||
timeout = 10.0
|
||||
start = time.time()
|
||||
|
||||
while ((time.time() - start) < timeout):
|
||||
s.poll()
|
||||
if s.task_mode == target:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
|
||||
log("timeout waiting for task mode to get to %d (it's %d)" % (target, s.task_mode))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def wait_for_halui_mode(pin_name):
|
||||
timeout = 10.0
|
||||
|
||||
start = time.time()
|
||||
|
||||
while ((time.time() - start) < timeout):
|
||||
if h[pin_name]:
|
||||
print("halui reports mode {}".format(pin_name))
|
||||
return
|
||||
time.sleep(0.1)
|
||||
print("timeout waiting for halui to report mode {}".format(pin_name))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# set up pins
|
||||
# shell out to halcmd to make nets to halui and motion
|
||||
#
|
||||
|
||||
h = hal.component("python-ui")
|
||||
|
||||
h.newpin("mdi-0", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("mdi-1", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("mdi-2", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("mdi-3", hal.HAL_BIT, hal.HAL_OUT)
|
||||
|
||||
h.newpin("joint-0-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-1-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
h.newpin("joint-2-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
|
||||
h.newpin("is-manual", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("is-auto", hal.HAL_BIT, hal.HAL_IN)
|
||||
h.newpin("is-mdi", hal.HAL_BIT, 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.wait_complete()
|
||||
|
||||
|
||||
#
|
||||
# run the test
|
||||
#
|
||||
# These functions will exit with a return value of 1 if something goes
|
||||
# wrong.
|
||||
#
|
||||
|
||||
log("setting mode to Manual")
|
||||
c.mode(linuxcnc.MODE_MANUAL)
|
||||
wait_for_halui_mode('is-manual')
|
||||
log("running MDI command 0")
|
||||
h['mdi-0'] = 1
|
||||
wait_for_joint_to_stop_at(0, -1);
|
||||
wait_for_joint_to_stop_at(1, 0);
|
||||
wait_for_joint_to_stop_at(2, 0);
|
||||
h['mdi-0'] = 0
|
||||
wait_for_task_mode(linuxcnc.MODE_MANUAL)
|
||||
wait_for_halui_mode('is-manual')
|
||||
|
||||
log("setting mode to Auto")
|
||||
c.mode(linuxcnc.MODE_AUTO)
|
||||
wait_for_halui_mode('is-auto')
|
||||
log("running MDI command 1")
|
||||
h['mdi-1'] = 1
|
||||
wait_for_joint_to_stop_at(0, 1);
|
||||
wait_for_joint_to_stop_at(1, 0);
|
||||
wait_for_joint_to_stop_at(2, 0);
|
||||
h['mdi-1'] = 0
|
||||
wait_for_task_mode(linuxcnc.MODE_AUTO)
|
||||
wait_for_halui_mode('is-auto')
|
||||
|
||||
log("setting mode to MDI")
|
||||
c.mode(linuxcnc.MODE_MDI)
|
||||
wait_for_halui_mode('is-mdi')
|
||||
log("running MDI command 2")
|
||||
h['mdi-2'] = 1
|
||||
wait_for_joint_to_stop_at(0, 1);
|
||||
wait_for_joint_to_stop_at(1, 2);
|
||||
wait_for_joint_to_stop_at(2, 0);
|
||||
h['mdi-2'] = 0
|
||||
s.poll()
|
||||
wait_for_task_mode(linuxcnc.MODE_MDI)
|
||||
wait_for_halui_mode('is-mdi')
|
||||
|
||||
log("running MDI command 3")
|
||||
h['mdi-3'] = 1
|
||||
wait_for_joint_to_stop_at(0, 1);
|
||||
wait_for_joint_to_stop_at(1, 2);
|
||||
wait_for_joint_to_stop_at(2, 3);
|
||||
h['mdi-3'] = 0
|
||||
wait_for_task_mode(linuxcnc.MODE_MDI)
|
||||
wait_for_halui_mode('is-mdi')
|
||||
|
||||
log("running MDI command 0")
|
||||
h['mdi-0'] = 1
|
||||
wait_for_joint_to_stop_at(0, -1);
|
||||
wait_for_joint_to_stop_at(1, 0);
|
||||
wait_for_joint_to_stop_at(2, 0);
|
||||
h['mdi-0'] = 0
|
||||
wait_for_task_mode(linuxcnc.MODE_MDI)
|
||||
wait_for_halui_mode('is-mdi')
|
||||
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
1
tests/halui/mdi/test.sh
Symbolic link
1
tests/halui/mdi/test.sh
Symbolic link
@@ -0,0 +1 @@
|
||||
../shared-test.sh
|
||||
4
tests/halui/shared-test.sh
Executable file
4
tests/halui/shared-test.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec linuxcnc -r halui.ini
|
||||
|
||||
Reference in New Issue
Block a user