Import LinuxCNC source tree
This commit is contained in:
2
tests/mqtt/checkresult
Executable file
2
tests/mqtt/checkresult
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exit 0 # test failure is indicated by test.sh exit value
|
||||
53
tests/mqtt/display.py
Executable file
53
tests/mqtt/display.py
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
|
||||
import linuxcnc
|
||||
import linuxcnc_util
|
||||
import hal
|
||||
|
||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w')
|
||||
|
||||
c = linuxcnc.command()
|
||||
s = linuxcnc.stat()
|
||||
e = linuxcnc.error_channel
|
||||
l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)
|
||||
|
||||
print("info: Turning machine on")
|
||||
c.state(linuxcnc.STATE_ESTOP_RESET)
|
||||
c.state(linuxcnc.STATE_ON)
|
||||
c.wait_complete()
|
||||
|
||||
c.home(0)
|
||||
c.home(1)
|
||||
c.home(2)
|
||||
|
||||
print("info: Waiting for homing to complete")
|
||||
l.wait_for_home([1, 1, 1, 0, 0, 0, 0, 0, 0])
|
||||
|
||||
c.mode(linuxcnc.MODE_MDI)
|
||||
|
||||
print("info: Moving to X1")
|
||||
c.mdi("G0 X1Y0Z0")
|
||||
c.wait_complete()
|
||||
s.poll()
|
||||
|
||||
h = hal.component("python-ui")
|
||||
|
||||
# Wait for next MQTT publication
|
||||
name='mqtt-publisher.lastpublish'
|
||||
timeout = 10
|
||||
lastpublish = hal.get_value(name)
|
||||
start_time = time.time()
|
||||
while (time.time() - start_time) < timeout and \
|
||||
hal.get_value(name) == lastpublish:
|
||||
time.sleep(0.1)
|
||||
if hal.get_value(name) == lastpublish:
|
||||
raise RuntimeError(f"error: no MQTT publishing happened within {timeout} seconds")
|
||||
|
||||
print("info: Turning machine off")
|
||||
c.state(linuxcnc.STATE_OFF)
|
||||
|
||||
sys.exit(0)
|
||||
17
tests/mqtt/simulator.hal
Normal file
17
tests/mqtt/simulator.hal
Normal file
@@ -0,0 +1,17 @@
|
||||
loadrt [KINS]KINEMATICS
|
||||
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
|
||||
|
||||
addf motion-command-handler servo-thread
|
||||
addf motion-controller 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
|
||||
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb
|
||||
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb
|
||||
|
||||
# estop loopback
|
||||
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
|
||||
|
||||
# Set up MQTT publisher
|
||||
loadusr -W mqtt-publisher [MQTT]DRYRUN --mqtt-broker=[MQTT]BROKER --mqtt-user=[MQTT]USERNAME --mqtt-password=[MQTT]PASSWORD keys=Xpos,Ypos,Zpos,halui.axis.a.pos-feedback,halui.axis.b.pos-feedback,halui.axis.c.pos-feedback,halui.axis.u.pos-feedback,halui.axis.v.pos-feedback,halui.axis.w.pos-feedback,halui.axis.x.pos-feedback,halui.axis.y.pos-feedback,halui.axis.z.pos-feedback,halui.estop.is-activated,halui.joint.0.is-homed,halui.joint.1.is-homed,halui.joint.2.is-homed,halui.joint.3.is-homed,halui.joint.4.is-homed,halui.joint.5.is-homed,halui.joint.6.is-homed,halui.joint.7.is-homed,halui.joint.8.is-homed,halui.machine.is-on,halui.max-velocity.value,halui.mode.is-auto,halui.mode.is-manual,halui.mode.is-mdi,halui.mode.is-teleop,halui.program.is-running
|
||||
108
tests/mqtt/simulator.ini
Normal file
108
tests/mqtt/simulator.ini
Normal file
@@ -0,0 +1,108 @@
|
||||
[EMC]
|
||||
VERSION = 1.1
|
||||
|
||||
#DEBUG = 0x0
|
||||
#DEBUG = 0xffffffff
|
||||
|
||||
[DISPLAY]
|
||||
DISPLAY = ./display.py
|
||||
|
||||
[FILTER]
|
||||
#No Content
|
||||
|
||||
[RS274NGC]
|
||||
PARAMETER_FILE = simulator.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
|
||||
|
||||
[HAL]
|
||||
HALUI = halui
|
||||
HALFILE = simulator.hal
|
||||
|
||||
[HALUI]
|
||||
#No Content
|
||||
|
||||
[TRAJ]
|
||||
AXES = 3
|
||||
COORDINATES = X Y Z
|
||||
HOME = 0 0 0
|
||||
LINEAR_UNITS = mm
|
||||
ANGULAR_UNITS = degree
|
||||
DEFAULT_LINEAR_VELOCITY = 10
|
||||
MAX_LINEAR_ACCELERATION = 1000
|
||||
MAX_LINEAR_VELOCITY = 100
|
||||
|
||||
[EMCIO]
|
||||
TOOL_TABLE = simpockets.tbl
|
||||
TOOL_CHANGE_QUILL_UP = 1
|
||||
RANDOM_TOOLCHANGER = 0
|
||||
|
||||
[KINS]
|
||||
KINEMATICS = trivkins
|
||||
JOINTS = 3
|
||||
|
||||
[MQTT]
|
||||
DRYRUN = --dryrun
|
||||
BROKER = broker.local
|
||||
USERNAME = username
|
||||
PASSWORD = password
|
||||
|
||||
[AXIS_X]
|
||||
MIN_LIMIT = -1000
|
||||
MAX_LIMIT = 1000
|
||||
MAX_VELOCITY = 100
|
||||
MAX_ACCELERATION = 1000
|
||||
|
||||
[JOINT_0]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
HOME_ABSOLUTE_ENCODER = 1
|
||||
MAX_VELOCITY = 100
|
||||
MAX_ACCELERATION = 1000
|
||||
BACKLASH = 0.000
|
||||
MIN_LIMIT = -1000
|
||||
MAX_LIMIT = 1000
|
||||
FERROR = 0.001
|
||||
|
||||
[AXIS_Y]
|
||||
MIN_LIMIT = -1000
|
||||
MAX_LIMIT = 1000
|
||||
MAX_VELOCITY = 100
|
||||
MAX_ACCELERATION = 1000
|
||||
|
||||
[JOINT_1]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
HOME_ABSOLUTE_ENCODER = 1
|
||||
MAX_VELOCITY = 100
|
||||
MAX_ACCELERATION = 1000
|
||||
BACKLASH = 0.000
|
||||
MIN_LIMIT = -1000
|
||||
MAX_LIMIT = 1000
|
||||
FERROR = 0.001
|
||||
|
||||
[AXIS_Z]
|
||||
MIN_LIMIT = -1000
|
||||
MAX_LIMIT = 1000
|
||||
MAX_VELOCITY = 100
|
||||
MAX_ACCELERATION = 1000
|
||||
|
||||
[JOINT_2]
|
||||
TYPE = LINEAR
|
||||
HOME = 0.000
|
||||
HOME_ABSOLUTE_ENCODER = 1
|
||||
MAX_VELOCITY = 100
|
||||
MAX_ACCELERATION = 1000
|
||||
BACKLASH = 0.000
|
||||
MIN_LIMIT = -1000
|
||||
MAX_LIMIT = 1000
|
||||
FERROR = 0.001
|
||||
7
tests/mqtt/test.sh
Executable file
7
tests/mqtt/test.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
linuxcnc -r simulator.ini
|
||||
rm -f simulator.var
|
||||
exit 0
|
||||
Reference in New Issue
Block a user