Import LinuxCNC source tree
This commit is contained in:
4
tests/limit3/sunny-day/README
Normal file
4
tests/limit3/sunny-day/README
Normal file
@@ -0,0 +1,4 @@
|
||||
This test exposes limit3 to an input signal that it is capable of
|
||||
following perfectly (but just barely), and verifies that the output
|
||||
follows the input very closely, while not violating position, velocity,
|
||||
and acceleration constraints.
|
||||
57
tests/limit3/sunny-day/checkresult
Executable file
57
tests/limit3/sunny-day/checkresult
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import math
|
||||
|
||||
max_value = 0.0
|
||||
min_value = -100.0
|
||||
|
||||
max_vel = 315
|
||||
max_accel = 1975
|
||||
|
||||
result_filename = sys.argv[1]
|
||||
result_file = open(result_filename, 'r')
|
||||
|
||||
retval = 0
|
||||
|
||||
for line in result_file.readlines():
|
||||
(line, in_value, in_vel, in_accel, out_value, out_vel, out_accel) = line.split()
|
||||
in_value = float(in_value)
|
||||
in_vel = float(in_vel)
|
||||
in_accel = float(in_accel)
|
||||
out_value = float(out_value)
|
||||
out_vel = float(out_vel)
|
||||
out_accel = float(out_accel)
|
||||
|
||||
|
||||
#
|
||||
# constraints
|
||||
#
|
||||
|
||||
if out_value > max_value:
|
||||
print(("max=%.3f, out=%.3f, position violation on line %s" % (max_value, out_value, line)))
|
||||
retval = 1
|
||||
|
||||
if out_value < min_value:
|
||||
print(("min=%.3f, out=%.3f, position violation on line %s" % (min_value, out_value, line)))
|
||||
retval = 1
|
||||
|
||||
if math.fabs(out_vel) > max_vel:
|
||||
print(("max_vel=%.3f, out_vel=%.3f, velocity violation on line %s" % (max_vel, out_vel, line)))
|
||||
retval = 1
|
||||
|
||||
if math.fabs(out_accel) > max_accel:
|
||||
print(("max_accel=%.3f, out_accel=%.3f, acceleration violation on line %s" % (max_accel, out_accel, line)))
|
||||
retval = 1
|
||||
|
||||
|
||||
#
|
||||
# input -> output following
|
||||
#
|
||||
|
||||
error = math.fabs(in_value - out_value)
|
||||
if error > 0.0:
|
||||
print(("input=%.6f, output=%.6f, error=%.6f, threshold=%.6f, following failure on line %s" % (in_value, out_value, error, threshold, line)))
|
||||
retval = 1
|
||||
|
||||
sys.exit(retval)
|
||||
63
tests/limit3/sunny-day/test.hal
Normal file
63
tests/limit3/sunny-day/test.hal
Normal file
@@ -0,0 +1,63 @@
|
||||
setexact_for_test_suite_only
|
||||
|
||||
loadrt limit3
|
||||
|
||||
# These pos/vel/accel limits are just a hair above the limits of the
|
||||
# input sine wave.
|
||||
setp limit3.0.min -150
|
||||
setp limit3.0.max 50
|
||||
setp limit3.0.maxv 630
|
||||
setp limit3.0.maxa 4000
|
||||
|
||||
|
||||
loadrt siggen
|
||||
setp siggen.0.amplitude 50
|
||||
setp siggen.0.offset -50
|
||||
|
||||
|
||||
loadrt ddt names=ddt.in-accel,ddt.in-vel,ddt.out-accel,ddt.out-vel
|
||||
|
||||
|
||||
loadrt sampler depth=2000 cfg=ffffff
|
||||
|
||||
|
||||
# We use the cosine signal as the input so that the velocity and
|
||||
# acceleration start out at 0, and we offset it by the negative of the
|
||||
# amplitude so that position start out at 0 too.
|
||||
net input <= siggen.0.cosine
|
||||
net input => limit3.0.in
|
||||
net input => ddt.in-vel.in
|
||||
net input => sampler.0.pin.0
|
||||
|
||||
net in-vel <= ddt.in-vel.out
|
||||
net in-vel => ddt.in-accel.in
|
||||
net in-vel => sampler.0.pin.1
|
||||
|
||||
net in-accel <= ddt.in-accel.out
|
||||
net in-accel => sampler.0.pin.2
|
||||
|
||||
net output <= limit3.0.out
|
||||
net output => ddt.out-vel.in
|
||||
net output => sampler.0.pin.3
|
||||
|
||||
net out-vel <= ddt.out-vel.out
|
||||
net out-vel => ddt.out-accel.in
|
||||
net out-vel => sampler.0.pin.4
|
||||
|
||||
net out-accel <= ddt.out-accel.out
|
||||
net out-accel => sampler.0.pin.5
|
||||
|
||||
|
||||
loadrt threads name1=t period1=1000000
|
||||
|
||||
addf siggen.0.update t
|
||||
addf limit3.0 t
|
||||
addf ddt.in-vel t
|
||||
addf ddt.in-accel t
|
||||
addf ddt.out-vel t
|
||||
addf ddt.out-accel t
|
||||
addf sampler.0 t
|
||||
|
||||
start
|
||||
|
||||
loadusr -w halsampler -t -n 4000
|
||||
Reference in New Issue
Block a user