Import LinuxCNC source tree
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user