Import LinuxCNC source tree
This commit is contained in:
2
tests/motion/jogwheel-axis/.gitignore
vendored
Normal file
2
tests/motion/jogwheel-axis/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
sim.var
|
||||
sim.var.bak
|
||||
2
tests/motion/jogwheel-axis/checkresult
Executable file
2
tests/motion/jogwheel-axis/checkresult
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exit 0 # test failure is indicated by test.sh exit value
|
||||
99
tests/motion/jogwheel-axis/motion-test.ini
Normal file
99
tests/motion/jogwheel-axis/motion-test.ini
Normal file
@@ -0,0 +1,99 @@
|
||||
[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]
|
||||
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
|
||||
|
||||
[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
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
[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
|
||||
HOME_SEQUENCE = 0
|
||||
|
||||
[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
|
||||
HOME_SEQUENCE = 0
|
||||
48
tests/motion/jogwheel-axis/postgui.hal
Normal file
48
tests/motion/jogwheel-axis/postgui.hal
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#
|
||||
# axis x
|
||||
#
|
||||
|
||||
net axis-x-jog-enable <= test-ui.axis-x-jog-enable
|
||||
net axis-x-jog-enable => axis.x.jog-enable
|
||||
|
||||
net axis-x-jog-counts <= test-ui.axis-x-jog-counts
|
||||
net axis-x-jog-counts => axis.x.jog-counts
|
||||
|
||||
net axis-x-jog-scale <= test-ui.axis-x-jog-scale
|
||||
net axis-x-jog-scale => axis.x.jog-scale
|
||||
|
||||
net Xpos => test-ui.axis-x-position
|
||||
|
||||
|
||||
#
|
||||
# axis y
|
||||
#
|
||||
|
||||
net axis-y-jog-enable <= test-ui.axis-y-jog-enable
|
||||
net axis-y-jog-enable => axis.y.jog-enable
|
||||
|
||||
net axis-y-jog-counts <= test-ui.axis-y-jog-counts
|
||||
net axis-y-jog-counts => axis.y.jog-counts
|
||||
|
||||
net axis-y-jog-scale <= test-ui.axis-y-jog-scale
|
||||
net axis-y-jog-scale => axis.y.jog-scale
|
||||
|
||||
net Ypos => test-ui.axis-y-position
|
||||
|
||||
|
||||
#
|
||||
# axis z
|
||||
#
|
||||
|
||||
net axis-z-jog-enable <= test-ui.axis-z-jog-enable
|
||||
net axis-z-jog-enable => axis.z.jog-enable
|
||||
|
||||
net axis-z-jog-counts <= test-ui.axis-z-jog-counts
|
||||
net axis-z-jog-counts => axis.z.jog-counts
|
||||
|
||||
net axis-z-jog-scale <= test-ui.axis-z-jog-scale
|
||||
net axis-z-jog-scale => axis.z.jog-scale
|
||||
|
||||
net Zpos => test-ui.axis-z-position
|
||||
|
||||
119
tests/motion/jogwheel-axis/test-ui.py
Executable file
119
tests/motion/jogwheel-axis/test-ui.py
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import linuxcnc
|
||||
import linuxcnc_util
|
||||
import hal
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import math
|
||||
|
||||
|
||||
def close_enough(a, b, epsilon=0.000001):
|
||||
return math.fabs(a - b) < epsilon
|
||||
|
||||
|
||||
def jog_axis(axis_letter, counts=1, scale=0.001):
|
||||
timeout = 5.0
|
||||
|
||||
start_pos = { }
|
||||
for a in 'xyz':
|
||||
start_pos[a] = h['axis-%c-position' % a]
|
||||
|
||||
target = h['axis-%c-position' % axis_letter] + (counts * scale)
|
||||
|
||||
h['axis-%c-jog-scale' % axis_letter] = scale
|
||||
h['axis-%c-jog-enable' % axis_letter] = 1
|
||||
h['axis-%c-jog-counts' % axis_letter] += counts
|
||||
|
||||
start_time = time.time()
|
||||
while not close_enough(h['axis-%c-position' % axis_letter], target) and (time.time() - start_time < timeout):
|
||||
#print "axis %c is at %.9f" % (axis_letter, h['axis-%c-position' % axis_letter])
|
||||
time.sleep(0.010)
|
||||
|
||||
h['axis-%c-jog-enable' % axis_letter] = 0
|
||||
|
||||
print("axis %c jogged from %.6f to %.6f (%d counts at scale %.6f)" % (axis_letter, start_pos[axis_letter], h['axis-%c-position' % axis_letter], counts, scale))
|
||||
|
||||
success = True
|
||||
for a in 'xyz':
|
||||
pin_name = 'axis-%c-position' % a
|
||||
if a == axis_letter:
|
||||
if not close_enough(h[pin_name], target):
|
||||
print("axis %c didn't get to target (start=%.6f, target=%.6f, got to %.6f)" % (axis_letter, start_pos[axis_letter], target, h['axis-%c-position' % axis_letter]))
|
||||
success = False
|
||||
else:
|
||||
if h[pin_name] != start_pos[a]:
|
||||
print("axis %c moved from %.6f to %.6f but should not have!" % (a, start_pos[a], h[pin_name]))
|
||||
success = False
|
||||
|
||||
l.wait_for_axis_to_stop(axis_letter)
|
||||
|
||||
if not success:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
#
|
||||
# set up pins
|
||||
# shell out to halcmd to make nets to halui and motion
|
||||
#
|
||||
|
||||
h = hal.component("test-ui")
|
||||
|
||||
h.newpin("axis-x-jog-enable", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("axis-x-jog-counts", hal.HAL_S32, hal.HAL_OUT)
|
||||
h.newpin("axis-x-jog-scale", hal.HAL_FLOAT, hal.HAL_OUT)
|
||||
h.newpin("axis-x-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
|
||||
h.newpin("axis-y-jog-enable", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("axis-y-jog-counts", hal.HAL_S32, hal.HAL_OUT)
|
||||
h.newpin("axis-y-jog-scale", hal.HAL_FLOAT, hal.HAL_OUT)
|
||||
h.newpin("axis-y-position", hal.HAL_FLOAT, hal.HAL_IN)
|
||||
|
||||
h.newpin("axis-z-jog-enable", hal.HAL_BIT, hal.HAL_OUT)
|
||||
h.newpin("axis-z-jog-counts", hal.HAL_S32, hal.HAL_OUT)
|
||||
h.newpin("axis-z-jog-scale", hal.HAL_FLOAT, hal.HAL_OUT)
|
||||
h.newpin("axis-z-position", hal.HAL_FLOAT, 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()
|
||||
|
||||
l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)
|
||||
|
||||
c.state(linuxcnc.STATE_ESTOP_RESET)
|
||||
c.state(linuxcnc.STATE_ON)
|
||||
|
||||
|
||||
# must home to use Teleop mode
|
||||
|
||||
c.home(-1)
|
||||
c.wait_complete()
|
||||
|
||||
l.wait_for_home([1, 1, 1, 0, 0, 0, 0, 0, 0])
|
||||
|
||||
c.mode(linuxcnc.MODE_MANUAL)
|
||||
|
||||
|
||||
#
|
||||
# run the test
|
||||
#
|
||||
# These jog_joint() functions will exit with a return value of 1 if
|
||||
# something goes wrong.
|
||||
#
|
||||
|
||||
jog_axis('x', counts=1, scale=0.001)
|
||||
jog_axis('y', counts=10, scale=-0.025)
|
||||
jog_axis('z', counts=-100, scale=0.100)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
3
tests/motion/jogwheel-axis/test.sh
Executable file
3
tests/motion/jogwheel-axis/test.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec linuxcnc -r motion-test.ini
|
||||
Reference in New Issue
Block a user