Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions tests/kins-switch/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,64 @@ def drain():
return said
said.append(m)

# what c.wait_complete() waits for, task done with the last command sent,
# looked at every 2 ms rather than every 10: a step of several commands
# pays that wait on each
def done(timeout=60):
deadline = time.time() + timeout
while time.time() < deadline:
s.poll()
if s.echo_serial_number >= c.serial and s.state != linuxcnc.RCS_EXEC:
return
time.sleep(0.002)
error("timed out waiting for task")

# the move has ended when task has nothing left to run and motion is at
# rest; in position with an empty queue alone is also true before task has
# sent the move on. Status is a copy task writes once a cycle, so it only
# counts from a copy written two task cycles after the command, and the
# joints only count as still over two copies a servo cycle or more apart
def settled():
deadline = time.time() + 60
s.poll()
beat = s.taskbeat + 2
last = None
last_hb = None
while time.time() < deadline:
now = joints()
if s.inpos and not s.queue and now == last:
return now
last = now
time.sleep(0.05)
s.poll()
if s.taskbeat >= beat:
now = joints()
if (s.interp_state == linuxcnc.INTERP_IDLE and s.inpos and not s.queue
and now == last and s.heartbeat != last_hb):
return now
last = now
last_hb = s.heartbeat
time.sleep(0.002)
error("timed out waiting for the move")
return last

def mdi(cmd):
c.mdi(cmd)
c.wait_complete(60)
done(60)
return settled()

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.wait_complete(30)
done(30)
c.home(-1)
c.wait_complete(60)
done(60)
# start in identity every run, the abort's G13.1 may or may not have run yet
c.mode(linuxcnc.MODE_MDI)
c.wait_complete(30)
done(30)
mdi("G13.1")
c.mode(linuxcnc.MODE_AUTO)
c.wait_complete(30)
done(30)
drain()

# ---- the program, and what the joints do while it runs -------------------

c.program_open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test.ngc"))
c.wait_complete(30)
done(30)
last = kins_type()
c.auto(linuxcnc.AUTO_RUN, 0)

Expand Down Expand Up @@ -181,7 +205,7 @@ def mdi(cmd):

import math
c.mode(linuxcnc.MODE_MDI)
c.wait_complete(30)
done(30)
drain()

def pose():
Expand Down Expand Up @@ -283,7 +307,7 @@ def tool_length_check(what, before_joints, before_pose, after_joints, after_pose
def refused(cmd, needle):
drain()
c.mdi(cmd)
c.wait_complete(30)
done(30)
m = e.poll()
if not m or m[0] not in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR):
error("%s was accepted" % cmd)
Expand Down Expand Up @@ -349,7 +373,7 @@ def refused(cmd, needle):

drain()
c.mdi("G12.1 P-1")
c.wait_complete(30)
done(30)
m = poll()
if not m or m[0] not in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR):
error("G12.1 P-1 was accepted")
Expand All @@ -362,7 +386,7 @@ def refused(cmd, needle):
# ---- a kinematics the module does not provide is refused at read time ----

c.mdi("G12.1 P7")
c.wait_complete(30)
done(30)
m = poll()
if not m or m[0] not in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR):
error("G12.1 P7 was accepted")
Expand All @@ -384,7 +408,7 @@ def refused(cmd, needle):
if s.g5x_index != 2:
continue
c.abort()
c.wait_complete(30)
done(30)
deadline = time.time() + 10
while time.time() < deadline:
s.poll()
Expand Down
58 changes: 30 additions & 28 deletions tests/kins-switch/test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ JOINTS = 6
HALFILE = sim.hal

[TRAJ]
# A sim that moves fast, to keep the run short: the checks on the program's
# W stroke sample status, and W rests on a dwell at its end.
COORDINATES = XYZBCW
LINEAR_UNITS = mm
ANGULAR_UNITS = deg
DEFAULT_LINEAR_VELOCITY = 200
MAX_LINEAR_VELOCITY = 346
MAX_LINEAR_ACCELERATION = 800
DEFAULT_LINEAR_ACCELERATION = 800
DEFAULT_LINEAR_VELOCITY = 10000
MAX_LINEAR_VELOCITY = 10000
MAX_LINEAR_ACCELERATION = 100000
DEFAULT_LINEAR_ACCELERATION = 100000
MAX_ANGULAR_VELOCITY = 360

[EMCMOT]
Expand All @@ -44,89 +46,89 @@ TOOL_TABLE = tool.tbl
[AXIS_X]
MIN_LIMIT = -500
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000

[AXIS_Y]
MIN_LIMIT = -500
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000

[AXIS_Z]
MIN_LIMIT = -500
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000

[AXIS_B]
MIN_LIMIT = -120
MAX_LIMIT = 120
MAX_VELOCITY = 60
MAX_ACCELERATION = 200
MAX_VELOCITY = 36000
MAX_ACCELERATION = 360000

[AXIS_C]
MIN_LIMIT = -36000
MAX_LIMIT = 36000
MAX_VELOCITY = 60
MAX_ACCELERATION = 200
MAX_VELOCITY = 36000
MAX_ACCELERATION = 360000

[AXIS_W]
MIN_LIMIT = -100
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000

[JOINT_0]
TYPE = LINEAR
MIN_LIMIT = -500
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_1]
TYPE = LINEAR
MIN_LIMIT = -500
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_2]
TYPE = LINEAR
MIN_LIMIT = -500
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_3]
TYPE = ANGULAR
MIN_LIMIT = -120
MAX_LIMIT = 120
MAX_VELOCITY = 60
MAX_ACCELERATION = 200
MAX_VELOCITY = 36000
MAX_ACCELERATION = 360000
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_4]
TYPE = ANGULAR
MIN_LIMIT = -36000
MAX_LIMIT = 36000
MAX_VELOCITY = 60
MAX_ACCELERATION = 200
MAX_VELOCITY = 36000
MAX_ACCELERATION = 360000
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0

[JOINT_5]
TYPE = LINEAR
MIN_LIMIT = -100
MAX_LIMIT = 500
MAX_VELOCITY = 200
MAX_ACCELERATION = 800
MAX_VELOCITY = 10000
MAX_ACCELERATION = 100000
HOME_SEARCH_VEL = 0
HOME_SEQUENCE = 0
35 changes: 29 additions & 6 deletions tests/ptp-machine-frame/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,46 @@ def drain():
if m[0] in (linuxcnc.NML_ERROR, linuxcnc.OPERATOR_ERROR):
error("reported: %s" % m[1])

# what c.wait_complete() waits for, task done with the last command sent,
# looked at every 2 ms rather than every 10: a step of several commands
# pays that wait on each
def done(timeout=60):
deadline = time.time() + timeout
while time.time() < deadline:
s.poll()
if s.echo_serial_number >= c.serial and s.state != linuxcnc.RCS_EXEC:
return
time.sleep(0.002)
error("timed out waiting for task")

# the move has ended when task has nothing left to run and motion is at
# rest; in position with an empty queue alone is also true before task has
# sent the move on. Status is a copy task writes once a cycle, so it only
# counts from a copy written two task cycles after the command, and the
# joints only count as still over two copies a servo cycle or more apart
def settled():
deadline = time.time() + 60
s.poll()
beat = s.taskbeat + 2
last = None
last_hb = None
while time.time() < deadline:
s.poll()
now = [s.joint_position[i] for i in range(JOINTS)]
if s.inpos and not s.queue and now == last:
return now
last = now
time.sleep(0.05)
if s.taskbeat >= beat:
now = [s.joint_position[i] for i in range(JOINTS)]
if (s.interp_state == linuxcnc.INTERP_IDLE and s.inpos and not s.queue
and now == last and s.heartbeat != last_hb):
return now
last = now
last_hb = s.heartbeat
time.sleep(0.002)
error("timed out waiting for the move")
return last

def mdi(*cmds):
for cmd in cmds:
c.mdi(cmd)
c.wait_complete(60)
done(60)
return settled()

def kins_type():
Expand Down
Loading
Loading