Startup
This commit is contained in:
71
script/test/CameraCalibration.py
Normal file
71
script/test/CameraCalibration.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import ch.psi.pshell.device.Camera as Camera
|
||||
import ch.psi.pshell.imaging.RendererMode as RendererMode
|
||||
from ch.psi.pshell.imaging.Overlays import *
|
||||
|
||||
"""
|
||||
img.camera.setColorMode(Camera.ColorMode.Mono)
|
||||
img.camera.setDataType(Camera.DataType.UInt8)
|
||||
img.camera.setGrabMode(Camera.GrabMode.Continuous)
|
||||
img.camera.setTriggerMode(Camera.TriggerMode.Fixed_Rate)
|
||||
img.camera.setExposure(50.00)
|
||||
img.camera.setAcquirePeriod(200.00)
|
||||
img.camera.setGain(0.0)
|
||||
img.config.rotationCrop=True
|
||||
|
||||
|
||||
"""
|
||||
#img.camera.setROI(200, 0,1200,1200)
|
||||
|
||||
img.camera.setROI(0, 0,1600,1200)
|
||||
img.config.rotation=0
|
||||
img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight =0,0,-1,-1
|
||||
img.config.setCalibration(None)
|
||||
img.camera.stop()
|
||||
img.camera.start()
|
||||
|
||||
#img.camera.setROI(300, 200,1000,1000)
|
||||
#img.config.rotation=17
|
||||
#img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight = 50,50,900,900
|
||||
|
||||
p = show_panel(img)
|
||||
p.setMode(RendererMode.Fit)
|
||||
ov_text = Text(Pen(java.awt.Color.GREEN.darker()), "", java.awt.Font("Verdana", java.awt.Font.PLAIN, 24), java.awt.Point(20,20))
|
||||
ov_text.setFixed(True)
|
||||
|
||||
|
||||
|
||||
p.addOverlay(ov_text)
|
||||
try:
|
||||
ov_text.update("Click on upper reference...")
|
||||
p1 = p.waitClick(60000)
|
||||
print p1
|
||||
ov_text.update("Click on left reference...")
|
||||
p2 = p.waitClick(60000)
|
||||
print p2
|
||||
ov_text.update("Click on right reference...")
|
||||
p3 = p.waitClick(60000)
|
||||
print p3
|
||||
|
||||
x, y, z = p1.x+p1.y*1j, p2.x+p2.y*1j, p3.x+p3.y*1j
|
||||
w = z-x
|
||||
w /= y-x
|
||||
c = (x-y)*(w-abs(w)**2)/2j/w.imag-x
|
||||
cx, cy, r = -c.real, -c.imag, abs(c+x)
|
||||
a = math.degrees(math.atan((cx-p1.x)/(p1.y-cy)))
|
||||
|
||||
print cx, cy, r, a
|
||||
|
||||
#img.camera.setROI(int((1600-cx)/2),int((1200-cy)/2),1000,1000)
|
||||
img.camera.setROI(int(cx-r),int(cy-r),int(2*r),int(2*r))
|
||||
img.config.rotation=-a
|
||||
#remove rotation border
|
||||
d=int(r/11)
|
||||
img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight =d,d, int(2*r-2*d), int(2*r-2*d)
|
||||
#img.config.setCalibration(None)
|
||||
img.camera.stop()
|
||||
img.camera.start()
|
||||
|
||||
finally:
|
||||
p.removeOverlay(ov_text)
|
||||
|
||||
|
||||
116
script/test/CoverDetection.py
Normal file
116
script/test/CoverDetection.py
Normal file
@@ -0,0 +1,116 @@
|
||||
###################################################################################################
|
||||
# Procedure to detect the cover orientation
|
||||
###################################################################################################
|
||||
import ch.psi.pshell.imaging.Utils.integrateVertically as integrateVertically
|
||||
img.backgroundEnabled=False
|
||||
|
||||
REF = (0,96,125)
|
||||
|
||||
line = load_image("{images}/line.png", title="Line")
|
||||
#line = load_image("{images}/line360.png", title="Line")
|
||||
|
||||
line.getProcessor().setBackgroundValue(0.0)
|
||||
|
||||
|
||||
#ip = get_image()
|
||||
ip = integrate_frames(10)
|
||||
ip = grayscale(ip, True)
|
||||
|
||||
|
||||
smooth(ip)
|
||||
#bandpass_filter(ip, 30, 1000)
|
||||
edges(ip)
|
||||
|
||||
#invert(ip)
|
||||
#auto_threshold(ip, method = "Default")
|
||||
|
||||
|
||||
#auto_threshold(ip, method = "Li")
|
||||
auto_threshold(ip, method = "MaxEntropy")
|
||||
|
||||
"""
|
||||
for m in AutoThresholder.getMethods():
|
||||
print m
|
||||
aux = ip.duplicate()
|
||||
auto_threshold(aux, method = m)
|
||||
binary_fill_holes(aux, dark_background=False)
|
||||
renderer = show_panel(aux.bufferedImage)
|
||||
time.sleep(1.0)
|
||||
"""
|
||||
#binary_dilate(ip, dark_background=False)
|
||||
#binary_fill_holes(ip, dark_background=False)
|
||||
#binary_open(ip, dark_background=Tr)
|
||||
|
||||
renderer = show_panel(ip.bufferedImage)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line = sub_image(line, 325, 325, 512, 512)
|
||||
#ip = sub_image(ip, 325, 325, 512, 512)
|
||||
line = sub_image(line, 453, 453, 256, 256)
|
||||
ip = sub_image(ip, 453, 453, 256, 256)
|
||||
#op = op_fft(ip, line, "correlate")
|
||||
|
||||
|
||||
renderer = show_panel(ip.bufferedImage)
|
||||
|
||||
#renderer = show_panel(op.bufferedImage)
|
||||
#line.show()
|
||||
ydata = []
|
||||
xdata = range (0,180,1)
|
||||
for i in xdata:
|
||||
l = line.duplicate()
|
||||
l.getProcessor().setBackgroundValue(0.0)
|
||||
l.getProcessor().rotate(float(i))
|
||||
op = op_fft(ip, l, "correlate")
|
||||
bi = op.getBufferedImage()
|
||||
p = integrateVertically(bi)
|
||||
ydata.append(sum(p))
|
||||
|
||||
#renderer = show_panel(op.bufferedImage)
|
||||
#time.sleep(0.001)
|
||||
|
||||
def moving_average(arr, n) :
|
||||
ret = []
|
||||
for i in range(len(arr)):
|
||||
ret.append(mean(arr[max(i-n,0):min(i+n,len(arr)-1)]))
|
||||
return ret
|
||||
av = moving_average(ydata, 1)
|
||||
|
||||
p = plot(ydata, xdata=xdata)[0]
|
||||
|
||||
p.addSeries(LinePlotSeries("Moving Average"))
|
||||
p.getSeries(1).setData(xdata, av)
|
||||
|
||||
peaks = estimate_peak_indexes(ydata, xdata, (min(ydata) + max(ydata))/2, 25.0)
|
||||
left, right = min(peaks), max(peaks)
|
||||
if xdata[left]<5 and xdata[right]>(xdata[-1]-5):
|
||||
#del peaks[0 if ydata[right] > ydata[left] else -1]
|
||||
peaks.remove(right if ydata[right] > ydata[left] else left)
|
||||
|
||||
peaks = sorted(peaks[:3])
|
||||
peaks_x = map(lambda x:xdata[x], peaks)
|
||||
peaks_y = map(lambda x:ydata[x], peaks)
|
||||
|
||||
print "Peaks", peaks
|
||||
print "Peak indexes: " + str(peaks_x)
|
||||
print "Peak values: " + str(peaks_y)
|
||||
|
||||
|
||||
for i in range(len(peaks)):
|
||||
peak = xdata[peaks[i]]
|
||||
p.addMarker(peak, None, "N="+str(round(peak,2)), Color(80,0,80))
|
||||
if ((peaks[i]>160) and (REF[i]<20)):
|
||||
peaks[i] = peaks[i] - 180.0
|
||||
|
||||
print "Peaks x: " + str(peaks_x)
|
||||
|
||||
|
||||
d = mean(arrabs(arrsub(REF, peaks_x)))
|
||||
|
||||
print "Angle = ", d
|
||||
24
script/test/PuckDetection.py
Normal file
24
script/test/PuckDetection.py
Normal file
@@ -0,0 +1,24 @@
|
||||
###################################################################################################
|
||||
# Example of using ImageJ functionalities through ijutils.
|
||||
###################################################################################################
|
||||
|
||||
from ijutils import *
|
||||
import java.awt.Color as Color
|
||||
|
||||
|
||||
#Image Loading
|
||||
ip = load_image("{images}/test2.png", title="Image")
|
||||
|
||||
|
||||
#Puck Detection
|
||||
aux = grayscale(ip, in_place=False)
|
||||
aux.show()
|
||||
plot(get_histogram(aux))
|
||||
|
||||
subtract_background(aux)
|
||||
threshold(aux,0,50); aux.repaintWindow()
|
||||
binary_fill_holes(aux); aux.repaintWindow()
|
||||
(results,output_img)=analyse_particles(aux, 10000,50000,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.0, maxCirc = 1.0)
|
||||
output_img.show()
|
||||
11
script/test/PuckDetectionTest.py
Normal file
11
script/test/PuckDetectionTest.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import datetime
|
||||
index = 0
|
||||
prefix = str(datetime.datetime.now().strftime("%Y%m%d_%H%M%S"))
|
||||
|
||||
while True:
|
||||
suffix = "%04d - " % index
|
||||
print (suffix),
|
||||
run("imgproc/LedDetectionProc.py")
|
||||
index=index+1
|
||||
save_image(image, "{images}/" +prefix + "_" + suffix +".png", "png")
|
||||
|
||||
28
script/test/RobotCartesianScan.py
Normal file
28
script/test/RobotCartesianScan.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import plotutils
|
||||
from mathutils import fit_gaussian, Gaussian
|
||||
|
||||
robot.enable()
|
||||
move_to_laser()
|
||||
|
||||
#robot.reset_motion("jLaser")
|
||||
|
||||
#import ch.psi.pshell.device.Timestamp as Timestamp
|
||||
#sensor = Timestamp()
|
||||
|
||||
#ret = lscan(robot_z, sensor, -50.0, 0.0, 0.5, latency = 0, relative = True)
|
||||
#ret = lscan(robot_x, sensor, -50.0, 0.0, 0.5, latency = 0, relative = True)
|
||||
|
||||
robot.set_motors_enabled(True)
|
||||
ret = lscan(robot_x, ue.readable, -1.5, 1.5, 0.1, latency = 0.01, relative = True)
|
||||
|
||||
x,y = ret.getPositions(0), ret.getReadable(0)
|
||||
y = [100.0-v for v in y]
|
||||
(norm, mea, sigma) = fit(y, xdata=x)
|
||||
print "Maximum at " + str(mea)
|
||||
|
||||
|
||||
|
||||
robot.set_motors_enabled(True)
|
||||
ret = lscan(robot_rz, ue.readable, 0.0, 40.0, 1.0, latency = 0.01, relative = True, range = "auto")
|
||||
|
||||
|
||||
1861
script/test/SampleDataInput.py
Normal file
1861
script/test/SampleDataInput.py
Normal file
File diff suppressed because it is too large
Load Diff
1862
script/test/SampleDataInput_Dominik.py
Normal file
1862
script/test/SampleDataInput_Dominik.py
Normal file
File diff suppressed because it is too large
Load Diff
23
script/test/SampleDetection.py
Normal file
23
script/test/SampleDetection.py
Normal file
@@ -0,0 +1,23 @@
|
||||
###################################################################################################
|
||||
# Example of using ImageJ functionalities through ijutils.
|
||||
###################################################################################################
|
||||
|
||||
from ijutils import *
|
||||
import java.awt.Color as Color
|
||||
|
||||
#Image Loading
|
||||
ip = load_image("{images}/test2.png", title="Image")
|
||||
|
||||
aux = grayscale(ip, in_place=False)
|
||||
aux.show()
|
||||
|
||||
invert(aux); aux.repaintWindow()
|
||||
#gaussian_blur(aux); aux.repaintWindow()
|
||||
subtract_background(aux); aux.repaintWindow()
|
||||
auto_threshold(aux); aux.repaintWindow()
|
||||
binary_open(aux); aux.repaintWindow()
|
||||
#binary_fill_holes(aux); aux.repaintWindow()
|
||||
(results,output_img)=analyse_particles(aux, 250,1000,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.7, maxCirc = 1.0)
|
||||
output_img.show()
|
||||
9
script/test/TestAlign.py
Normal file
9
script/test/TestAlign.py
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
v = 2.0
|
||||
#while(true):
|
||||
for i in range(100):
|
||||
v = v * (-1.0)
|
||||
robot_j4.initialize()
|
||||
robot_j4.moveRel(v)
|
||||
robot.align()
|
||||
|
||||
4
script/test/TestBugPcAPI
Normal file
4
script/test/TestBugPcAPI
Normal file
@@ -0,0 +1,4 @@
|
||||
while True:
|
||||
img.initialize()
|
||||
img.waitNext(10000)
|
||||
time.sleep(2.0)
|
||||
30
script/test/TestBugPcAPI.py
Normal file
30
script/test/TestBugPcAPI.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import ch.psi.pshell.prosilica.Prosilica as Prosilica
|
||||
import ch.psi.pshell.device.Camera as Camera
|
||||
|
||||
|
||||
add_device(Prosilica("img", 25001, "PacketSize=1522;PixelFormat=Mono8;BinningX=1;BinningY=1;RegionX=300;RegionY=200;Width=1000;Height=1000;MulticastEnable=Off"), True)
|
||||
|
||||
img.camera.setGrabMode(Camera.GrabMode.Continuous)
|
||||
img.camera.setTriggerMode(Camera.TriggerMode.Fixed_Rate)
|
||||
img.camera.setExposure(50.00)
|
||||
img.camera.setAcquirePeriod(200.00)
|
||||
img.camera.setGain(0.0)
|
||||
#img.camera.setROI(200, 0,1200,1200)
|
||||
"""
|
||||
img.camera.setROI(300, 200,1000,1000)
|
||||
img.config.rotation=17
|
||||
img.config.rotationCrop=True
|
||||
img.config.roiX,img.config.roiY, img.config.roiWidth,img.config.roiHeight = 50,50,900,900
|
||||
"""
|
||||
img.camera.setROI(int(get_setting("roi_x")), int(get_setting("roi_y")), int(get_setting("roi_w")), int(get_setting("roi_h")))
|
||||
|
||||
img.camera.stop()
|
||||
img.camera.start()
|
||||
|
||||
|
||||
show_panel(img)
|
||||
#while True:
|
||||
# img.initialize()
|
||||
# img.waitNext(1000)
|
||||
# time.sleep(0.1)
|
||||
|
||||
6
script/test/TestBugPcAPI2.py
Normal file
6
script/test/TestBugPcAPI2.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import ch.psi.pshell.imaging.MjpegSource as MjpegSource
|
||||
MjpegSource2 = get_context().pluginManager.getDynamicClass("MjpegSource2")
|
||||
add_device(MjpegSource("gripper_cam", "http://axis-accc8e9cc87b.psi.ch/axis-cgi/mjpg/video.cgi"), True)
|
||||
#gripper_cam.polling=1000
|
||||
gripper_cam.monitored = True
|
||||
show_panel(gripper_cam)
|
||||
4
script/test/TestBugPcAPI3.py
Normal file
4
script/test/TestBugPcAPI3.py
Normal file
@@ -0,0 +1,4 @@
|
||||
while True:
|
||||
img.initialize()
|
||||
img.waitNext(1000)
|
||||
time.sleep(0.1)
|
||||
30
script/test/TestCalib.py
Normal file
30
script/test/TestCalib.py
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
print "calibrate_tool"
|
||||
|
||||
#Initial checks
|
||||
robot.assert_no_task()
|
||||
robot.reset_motion()
|
||||
robot.wait_ready()
|
||||
robot.assert_cleared()
|
||||
#robot.assert_in_known_point()
|
||||
|
||||
#Enabling
|
||||
enable_motion()
|
||||
|
||||
(detected, dm) = move_scanner()
|
||||
|
||||
if detected:
|
||||
print "Pin detected, trashing..."
|
||||
trash()
|
||||
(detected, dm) = move_scanner()
|
||||
if detected:
|
||||
raise Exception("Cannot trash pin")
|
||||
|
||||
robot.open_tool()
|
||||
robot.get_calibration_tool()
|
||||
|
||||
run("calibration/ToolCalibration3")
|
||||
|
||||
robot.put_calibration_tool()
|
||||
|
||||
robot.save_program()
|
||||
11
script/test/TestCameraStability1.py
Normal file
11
script/test/TestCameraStability1.py
Normal file
@@ -0,0 +1,11 @@
|
||||
for i in range(10):
|
||||
time.sleep(2)
|
||||
move_home()
|
||||
time.sleep(1)
|
||||
move_park()
|
||||
start = time.time()
|
||||
while get_img_cover_pos() != 'A':
|
||||
print ".",
|
||||
time.sleep(0.001)
|
||||
print "Time = " , ( time.time() - start)
|
||||
|
||||
14
script/test/TestCameraStability2.py
Normal file
14
script/test/TestCameraStability2.py
Normal file
@@ -0,0 +1,14 @@
|
||||
cover_detection_debug=True
|
||||
while True:
|
||||
for pos in ['A', 'B', 'C', 'D', 'E', 'F']:
|
||||
print "Moving to ", pos
|
||||
hexiposi.move(pos)
|
||||
move_home()
|
||||
move_park()
|
||||
time.sleep(2.0)
|
||||
ret = run("imgproc/CoverDetection")
|
||||
det = ret[0]
|
||||
print "Detected: ", det
|
||||
if det != pos:
|
||||
raise Exception("Position error")
|
||||
|
||||
9
script/test/TestCameraStability3.py
Normal file
9
script/test/TestCameraStability3.py
Normal file
@@ -0,0 +1,9 @@
|
||||
for i in range(10):
|
||||
time.sleep(1)
|
||||
move_home()
|
||||
time.sleep(1)
|
||||
move_park()
|
||||
start = time.time()
|
||||
time.sleep(1.0)
|
||||
print run("imgproc/LedDetectionProc.py")
|
||||
|
||||
32
script/test/TestCmdSynchronization.py
Normal file
32
script/test/TestCmdSynchronization.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import java.util.logging.Level
|
||||
|
||||
def get_pos_str():
|
||||
return "point: " + str(robot.get_current_point()) + " - here: " + str(robot.here()) + " - herej: " + str(robot.herej())
|
||||
|
||||
enable_motion()
|
||||
|
||||
get_context().setLogLevel(java.util.logging.Level.FINER)
|
||||
try:
|
||||
while True:
|
||||
#robot.move_dewar()
|
||||
#robot.move_park()
|
||||
|
||||
log("Moving dewar", False)
|
||||
flag = robot.start_task('moveDewar')
|
||||
print "moveDewar: ", flag
|
||||
log("Waiting", False)
|
||||
ret = robot.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
log("Moving dewar finished (" + str(ret) + ") - pos: " + get_pos_str(), False)
|
||||
robot.assert_dewar()
|
||||
|
||||
|
||||
log("Moving park", False)
|
||||
flag = robot.start_task('movePark')
|
||||
print "movePark: ", flag
|
||||
log("Waiting", False)
|
||||
ret = robot.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
log("Moving park finished (" + str(ret) + ") - pos: " + get_pos_str(), False)
|
||||
robot.assert_park()
|
||||
|
||||
finally:
|
||||
get_context().setLogLevel(java.util.logging.Level.INFO)
|
||||
19
script/test/TestCoverDetection.py
Normal file
19
script/test/TestCoverDetection.py
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
ca = []
|
||||
aa = []
|
||||
pa = []
|
||||
|
||||
#for i in range(6):
|
||||
#index = i+1
|
||||
for i in ['A', 'B', 'C', 'D', 'E', 'F']:
|
||||
hexiposi.move(i)
|
||||
[position, angle, confidence] = run("imgproc/CoverDetection")
|
||||
print [position, angle, confidence]
|
||||
pa.append(position)
|
||||
aa.append(angle)
|
||||
ca.append(confidence)
|
||||
|
||||
print "---"
|
||||
print "Position: " ,pa
|
||||
print "Angle: " ,aa
|
||||
print "Confidence: " ,ca, " mean: ", mean(ca)
|
||||
23
script/test/TestEuclidean.py
Normal file
23
script/test/TestEuclidean.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import org.apache.commons.math3.geometry.euclidean.threed.Segment as Segment
|
||||
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D as Vector3D
|
||||
import org.apache.commons.math3.geometry.euclidean.threed.Line as Line
|
||||
|
||||
|
||||
p = Vector3D(0, 0, 3)
|
||||
|
||||
p1 = Vector3D(0,0,0)
|
||||
p2 = Vector3D(0,1,1 )
|
||||
tolerance = 0.001
|
||||
|
||||
l = Line(p1, p2, tolerance)
|
||||
|
||||
|
||||
print l.distance(p)
|
||||
print p1.distance(p)
|
||||
print p2.distance(p)
|
||||
print "---"
|
||||
|
||||
print l.getAbscissa(p)
|
||||
print l.pointAt(l.getAbscissa(p))
|
||||
|
||||
#print l.closestPoint(Line(p, p, 0.01))
|
||||
12
script/test/TestLaserScan.py
Normal file
12
script/test/TestLaserScan.py
Normal file
@@ -0,0 +1,12 @@
|
||||
robot.set_motors_enabled(True)
|
||||
steps_x = 10
|
||||
steps_y = 8
|
||||
#ret = ascan([robot_x, robot_z], ue.readable, [-10.0, -10.0], [10.0, 10.0], [10,10], latency = 0.01, relative = True , zigzag=True)
|
||||
ret = ascan([robot_x, robot_z], ue.readable, [-10.0, -10.0], [10.0, 10.0], [steps_y,steps_x], latency = 0.01, relative = True , zigzag=False)
|
||||
data = Convert.transpose(Convert.toBidimensional(to_array(ret.getReadable(0),'d'),steps_x+1,steps_y+1))
|
||||
plot(data, title="data")
|
||||
|
||||
data = ret.getData(0)
|
||||
plot(data, title="data2")
|
||||
|
||||
|
||||
21
script/test/TestLayout.py
Normal file
21
script/test/TestLayout.py
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
|
||||
points = [(100, 140), (130, 77), (120, 130), (110, 100)]
|
||||
clear_detection()
|
||||
detect_pucks(points)
|
||||
#detect_pucks(points, 'A')
|
||||
#detect_pucks(points, '4')
|
||||
plot_base_plate(points)
|
||||
|
||||
|
||||
|
||||
#plot_detected_leds(points)
|
||||
|
||||
|
||||
|
||||
block_id = None
|
||||
print get_unipucks(block_id)
|
||||
print get_minispines(block_id)
|
||||
print get_empties(block_id)
|
||||
print get_det_errors(block_id)
|
||||
10
script/test/TestMicrohawk.py
Normal file
10
script/test/TestMicrohawk.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import ch.psi.pshell.serial.TcpDevice as TcpDevice
|
||||
import ch.psi.pshell.serial.UdpDevice as UdpDevice
|
||||
|
||||
|
||||
microscan = TcpDevice("microscan", "MicroHAWK38C528:2001")
|
||||
#microscan = UdpDevice("microscan", "MicroHAWK38C528:2001")
|
||||
microscan.initialize()
|
||||
|
||||
|
||||
|
||||
15
script/test/TestRecover.py
Normal file
15
script/test/TestRecover.py
Normal file
@@ -0,0 +1,15 @@
|
||||
print "Pos=" + str(robot.get_cartesian_pos())
|
||||
for p in robot.get_known_points():
|
||||
print p + " = " + str(get_pnt(p))
|
||||
|
||||
print "-------------"
|
||||
|
||||
for segment in known_segments:
|
||||
is_on_segment(segment)
|
||||
|
||||
print "-------------"
|
||||
for segment in known_segments:
|
||||
try:
|
||||
move_to_segment(segment)
|
||||
except:
|
||||
print sys.exc_info()[1]
|
||||
12
script/test/TestRelays.py
Normal file
12
script/test/TestRelays.py
Normal file
@@ -0,0 +1,12 @@
|
||||
for i in range(500):
|
||||
relay1.write(True)
|
||||
time.sleep(1.2)
|
||||
relay1.write(False)
|
||||
time.sleep(1.2)
|
||||
"""
|
||||
for i in range(5):
|
||||
relays.write(to_array([True,]*16, 'z'))
|
||||
time.sleep(0.2)
|
||||
relays.write(to_array([False,]*16, 'z'))
|
||||
time.sleep(0.2)
|
||||
"""
|
||||
31
script/test/TestRemoveBackground.py
Normal file
31
script/test/TestRemoveBackground.py
Normal file
@@ -0,0 +1,31 @@
|
||||
number_frames = 5
|
||||
number_backgrounds = 5
|
||||
minimum_size = 78 # r = 5 # 150
|
||||
maximum_size = 750 # r = 15 #1500
|
||||
min_circ = 0.2
|
||||
|
||||
threshold_method = "MaxEntropy"
|
||||
threshold_method,threshold_range = "Manual", (0, 215)
|
||||
|
||||
exclude_edges = True
|
||||
led_latency = 0.5 #0.1
|
||||
|
||||
set_led_state(False)
|
||||
time.sleep(led_latency)
|
||||
img.waitNext(2000)
|
||||
|
||||
background = average_frames(number_backgrounds)
|
||||
#background = integrate_frames(number_backgrounds)
|
||||
|
||||
set_led_state(True)
|
||||
time.sleep(led_latency)
|
||||
img.waitNext(2000)
|
||||
image = average_frames(number_frames)
|
||||
#image = integrate_frames(number_frames)
|
||||
|
||||
set_led_state(False)
|
||||
|
||||
op_image(image, background, "subtract", float_result=True, in_place=True)
|
||||
image=grayscale(image)
|
||||
|
||||
show_panel(image.getBufferedImage())
|
||||
41
script/test/TestRobot.py
Normal file
41
script/test/TestRobot.py
Normal file
@@ -0,0 +1,41 @@
|
||||
robot.task_create("simulateEvents",3, name = "test", priority = 20)
|
||||
print robot.get_task_status("test")
|
||||
print robot.get_task_status("tests")
|
||||
|
||||
robot.task_suspend("test")
|
||||
print robot.get_task_status("test")
|
||||
robot.task_resume("test")
|
||||
print robot.get_task_status("test")
|
||||
|
||||
robot.task_kill("test")
|
||||
print robot.get_task_status("test")
|
||||
|
||||
|
||||
print robot.is_powered()
|
||||
print robot.get_monitor_speed()
|
||||
#print robot.set_monitor_speed(20)
|
||||
#print robot.enable()
|
||||
print robot.disable()
|
||||
print robot.is_calibrated()
|
||||
print robot.read_working_mode()
|
||||
print robot.get_emergency_stop_sts()
|
||||
print robot.get_safety_fault_signal()
|
||||
print robot.stop()
|
||||
print robot.resume()
|
||||
print robot.reset_motion()
|
||||
print robot.is_empty()
|
||||
print robot.is_settled()
|
||||
print robot.get_move_id()
|
||||
print robot.set_move_id(10)
|
||||
print robot.get_joint_forces()
|
||||
#print robot.open("gripper")
|
||||
#print robot.close("gripper")
|
||||
print robot.herej()
|
||||
print robot.distance_t("t", "t")
|
||||
print robot.distance_p("p", "p")
|
||||
print robot.compose( "p", "world", "t")
|
||||
print robot.here("gripper", "world")
|
||||
print robot.joint_to_point("gripper", "world", "j")
|
||||
print robot.point_to_joint("gripper", "j", "p")
|
||||
print robot.position("p", "world")
|
||||
print robot.mount(1, 2)
|
||||
72
script/test/TestRobot2.py
Normal file
72
script/test/TestRobot2.py
Normal file
@@ -0,0 +1,72 @@
|
||||
import traceback
|
||||
|
||||
robot.task_create("simulateEvents",3, name = "test", priority = 20)
|
||||
|
||||
step = 0
|
||||
try:
|
||||
while(True):
|
||||
start = time.time()
|
||||
step = 1
|
||||
robot.is_powered()
|
||||
step = 2
|
||||
robot.get_task_status("test")
|
||||
step = 3
|
||||
robot.get_monitor_speed()
|
||||
step = 4
|
||||
#robot.set_monitor_speed(20)
|
||||
#robot.enable()
|
||||
step = 5
|
||||
#robot.disable()
|
||||
step = 6
|
||||
robot.is_calibrated()
|
||||
step = 7
|
||||
robot.read_working_mode()
|
||||
step = 8
|
||||
robot.get_emergency_stop_sts()
|
||||
step = 9
|
||||
robot.get_safety_fault_signal()
|
||||
step = 10
|
||||
robot.stop()
|
||||
step = 11
|
||||
robot.resume()
|
||||
step = 12
|
||||
robot.reset_motion()
|
||||
step = 13
|
||||
robot.is_empty()
|
||||
step = 14
|
||||
robot.is_settled()
|
||||
step = 15
|
||||
robot.get_move_id()
|
||||
step = 16
|
||||
robot.set_move_id(10)
|
||||
step = 17
|
||||
robot.get_joint_forces()
|
||||
step = 18
|
||||
#robot.open_tool("gripper")
|
||||
#robot.close_tool("gripper")
|
||||
robot.herej()
|
||||
step = 19
|
||||
robot.distance_t("t", "t")
|
||||
step = 20
|
||||
robot.distance_p("p", "p")
|
||||
step = 21
|
||||
robot.compose( "p", "world", "t")
|
||||
step = 22
|
||||
robot.here("gripper", "world")
|
||||
step = 23
|
||||
robot.joint_to_point("gripper", "world", "j")
|
||||
step = 24
|
||||
robot.point_to_joint("gripper", "j", "p")
|
||||
step = 25
|
||||
robot.position("p", "world")
|
||||
step = 26
|
||||
robot.mount(1, 2)
|
||||
#print time.time()-start
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
finally:
|
||||
print "Step: " + str(step)
|
||||
try:
|
||||
robot.task_kill("test")
|
||||
except:
|
||||
pass
|
||||
32
script/test/TestRobotCmds.py
Normal file
32
script/test/TestRobotCmds.py
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
import java.lang.System as System
|
||||
|
||||
index = 0
|
||||
max_time = 0
|
||||
while True:
|
||||
start = System.currentTimeMillis()
|
||||
robot.execute(1,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(2,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(1,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(2,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(1,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(2,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(1,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(2,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(1,1,1)
|
||||
time.sleep(0.01)
|
||||
robot.execute(2,1,1)
|
||||
time.sleep(0.01)
|
||||
cur_time = System.currentTimeMillis() - start
|
||||
max_time = max(cur_time, max_time)
|
||||
print index, cur_time, max_time
|
||||
index = index + 1
|
||||
|
||||
25
script/test/TestRobotCmds2.py
Normal file
25
script/test/TestRobotCmds2.py
Normal file
@@ -0,0 +1,25 @@
|
||||
if robot_req.read() != 0:
|
||||
raise Exception("Ongoing command")
|
||||
if robot_ack.read() != 0:
|
||||
raise Exception("Robot is not ready")
|
||||
robot_cmd.write(1)
|
||||
args = [0,0,0,0,0,0]
|
||||
|
||||
robot_args.write(to_array(args, 'i'))
|
||||
|
||||
|
||||
robot_req.write(1)
|
||||
while robot_ack.read() == 0:
|
||||
time.sleep(0.001)
|
||||
|
||||
err = robot_ack.take()
|
||||
if err == 1:
|
||||
ret = robot_ret.read()
|
||||
print ret
|
||||
if err == 2:
|
||||
print ("Invalid command: " + str(command))
|
||||
print ("Unknown error: " + str(err))
|
||||
robot_req.write(0)
|
||||
while robot_ack.read() != 0:
|
||||
time.sleep(0.001)
|
||||
|
||||
4
script/test/cycle_time
Normal file
4
script/test/cycle_time
Normal file
@@ -0,0 +1,4 @@
|
||||
start =time.time()
|
||||
unmount('A',2,5, force=True)
|
||||
mount('A',2,5, force=True, read_dm=False)
|
||||
print time.time()-start
|
||||
47
script/test/imgtest.py
Normal file
47
script/test/imgtest.py
Normal file
@@ -0,0 +1,47 @@
|
||||
###################################################################################################
|
||||
# Example of using ImageJ functionalities through ijutils.
|
||||
###################################################################################################
|
||||
|
||||
from ijutils import *
|
||||
import java.awt.Color as Color
|
||||
|
||||
import ch.psi.pshell.imaging.Filter as Filter
|
||||
from ch.psi.pshell.imaging.Overlays import *
|
||||
import ch.psi.pshell.imaging.Pen as Pen
|
||||
|
||||
|
||||
|
||||
def detect_pucks(ip):
|
||||
aux = grayscale(ip, in_place=False)
|
||||
threshold(aux,0,50)
|
||||
binary_fill_holes(aux)
|
||||
return analyse_particles(aux, 10000,50000,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.4, maxCirc = 1.0)
|
||||
|
||||
def detect_samples(ip):
|
||||
aux = grayscale(ip, in_place=False)
|
||||
invert(aux)
|
||||
subtract_background(aux)
|
||||
auto_threshold(aux)
|
||||
binary_open(aux)
|
||||
return analyse_particles(aux, 300,800,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.4
|
||||
, maxCirc = 1.0)
|
||||
|
||||
|
||||
class MyFilter(Filter):
|
||||
def process(self, image, data):
|
||||
ip = load_image(image)
|
||||
(results_puck,output_puck) = detect_pucks(ip)
|
||||
(results_samples,output_samples) = detect_samples(ip)
|
||||
set_lut(output_puck, outline_lut1[0], outline_lut1[1], outline_lut1[2])
|
||||
set_lut(output_samples, outline_lut2[0], outline_lut2[1], outline_lut2[2])
|
||||
op_image(ip, output_samples, "xor")
|
||||
op_image(ip, output_puck, "xor")
|
||||
return ip.getBufferedImage()
|
||||
|
||||
#Setting the filter to a source
|
||||
img.setFilter(MyFilter())
|
||||
|
||||
15
script/test/ip
Normal file
15
script/test/ip
Normal file
@@ -0,0 +1,15 @@
|
||||
from ijutils import *
|
||||
import java.awt.Color as Color
|
||||
|
||||
ip = load_image(img.getImage())
|
||||
grayscale(ip)
|
||||
#ip=binning(ip,2)
|
||||
gaussian_blur(ip)
|
||||
#bandpass_filter(ip,20, 100)
|
||||
auto_threshold(ip)
|
||||
|
||||
#Particle Analysis
|
||||
(results,output_img)=analyse_particles(ip, 500,2000, print_table=True)
|
||||
output_img.show()
|
||||
|
||||
ip.show()
|
||||
144
script/test/mount_profile.py
Normal file
144
script/test/mount_profile.py
Normal file
@@ -0,0 +1,144 @@
|
||||
mount_sample_id = None
|
||||
mount_sample_detected = None
|
||||
|
||||
def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False):
|
||||
"""
|
||||
"""
|
||||
global mount_sample_id, mount_sample_detected
|
||||
print "mount: ", segment, puck, sample, force
|
||||
|
||||
start = time.time()
|
||||
|
||||
#time.sleep(2)
|
||||
is_aux = (segment == AUX_SEGMENT)
|
||||
|
||||
#ZACH
|
||||
needs_chilling = not is_aux and (not robot.is_cold())
|
||||
needs_drying = is_aux and robot.is_cold()
|
||||
|
||||
puck_address = get_puck_address(puck)
|
||||
if puck_address is None:
|
||||
puck_obj = get_puck_obj_by_id(puck)
|
||||
if puck_obj is not None:
|
||||
puck_address = puck_obj.name
|
||||
if puck_address is not None:
|
||||
print "puck address: ", puck_address
|
||||
segment = puck_address[:1]
|
||||
puck = int(puck_address[1:])
|
||||
#Initial checks
|
||||
assert_valid_address(segment, puck, sample)
|
||||
assert_puck_detected(segment, puck)
|
||||
|
||||
if robot.simulated:
|
||||
time.sleep(3.0)
|
||||
mount_sample_detected = True
|
||||
mount_sample_id = "YYY0001"
|
||||
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id)
|
||||
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
|
||||
return [mount_sample_detected, mount_sample_id]
|
||||
|
||||
robot.assert_no_task()
|
||||
robot.reset_motion()
|
||||
robot.wait_ready()
|
||||
robot.assert_cleared()
|
||||
#robot.assert_in_known_point()
|
||||
hexiposi.assert_homed()
|
||||
assert_mount_position()
|
||||
|
||||
print "Pass 1: ", time.time() - start; start = time.time()
|
||||
try:
|
||||
#ZACH
|
||||
if needs_chilling:
|
||||
robot.move_cold()
|
||||
time.sleep(30.0)
|
||||
|
||||
if smart_magnet.get_supress() == True:
|
||||
smart_magnet.set_supress(False)
|
||||
time.sleep(0.2)
|
||||
#To better dectect sample
|
||||
smart_magnet.apply_resting()
|
||||
time.sleep(0.5)
|
||||
if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True:
|
||||
print "Pass 1b: ", time.time() - start; start = time.time()
|
||||
if auto_unmount and (get_setting("mounted_sample_position") is not None):
|
||||
#auto_unmount set to true so detection remains enabled
|
||||
unmount(force = True, auto_unmount = True)
|
||||
else:
|
||||
raise Exception("Pin detected on gonio")
|
||||
print "Pass 2: ", time.time() - start; start = time.time()
|
||||
set_status("Mounting: " + str(segment) + str(puck) + str(sample))
|
||||
#location = robot.get_current_point()
|
||||
|
||||
#Enabling
|
||||
enable_motion()
|
||||
|
||||
print "Pass 3: ", time.time() - start; start = time.time()
|
||||
#ZACH
|
||||
# a room temp pin is being mounted but the gripper is cold
|
||||
if needs_drying:
|
||||
dry(wait_cold=-1) # move to park after dry
|
||||
|
||||
if is_aux:
|
||||
if not robot.is_aux():
|
||||
robot.move_aux()
|
||||
print "Pass 3b: ", time.time() - start; start = time.time()
|
||||
robot.get_aux(sample)
|
||||
|
||||
else:
|
||||
set_hexiposi(segment)
|
||||
print "Pass 4: ", time.time() - start; start = time.time()
|
||||
if not force:
|
||||
visual_check_hexiposi(segment)
|
||||
|
||||
if not robot.is_dewar():
|
||||
robot.move_dewar()
|
||||
print "Pass 4b: ", time.time() - start; start = time.time()
|
||||
robot.get_dewar(segment, puck, sample)
|
||||
print "Pass 5: ", time.time() - start; start = time.time()
|
||||
|
||||
if read_dm:
|
||||
barcode_reader.start_read(10.0)
|
||||
robot.move_scanner()
|
||||
#time.sleep(1.0)
|
||||
|
||||
robot.move_gonio()
|
||||
|
||||
if read_dm:
|
||||
mount_sample_id = barcode_reader.get_readout()
|
||||
print "Datamatrix: " , mount_sample_id
|
||||
else:
|
||||
mount_sample_id = None
|
||||
print "Pass 6: ", time.time() - start; start = time.time()
|
||||
|
||||
robot.put_gonio()
|
||||
print "Pass 7: ", time.time() - start; start = time.time()
|
||||
|
||||
try:
|
||||
dry_mount_count = int(get_setting("dry_mount_counter"))
|
||||
except:
|
||||
dry_mount_count = 0
|
||||
set_setting("dry_mount_counter", dry_mount_count+1)
|
||||
|
||||
if is_aux:
|
||||
robot.move_home()
|
||||
else:
|
||||
robot.move_cold()
|
||||
print "Pass 8: ", time.time() - start; start = time.time()
|
||||
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
||||
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id)
|
||||
if mount_sample_detected == False:
|
||||
raise Exception("No pin detected on gonio")
|
||||
|
||||
|
||||
if is_force_dry():
|
||||
smart_magnet.set_default_current()
|
||||
print "Auto dry"
|
||||
log("Starting auto dry", False)
|
||||
set_exec_pars(then = "dry()")
|
||||
print "Pass 9: " , time.time() - start; start = time.time()
|
||||
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
|
||||
return [mount_sample_detected, mount_sample_id]
|
||||
finally:
|
||||
smart_magnet.set_default_current()
|
||||
smart_magnet.set_supress(True)
|
||||
|
||||
122
script/test/onewire.py
Normal file
122
script/test/onewire.py
Normal file
@@ -0,0 +1,122 @@
|
||||
import traceback
|
||||
|
||||
class Detector(ReadonlyRegisterBase):
|
||||
def __init__(self, name):
|
||||
ReadonlyRegisterBase.__init__(self, name)
|
||||
self.id = None
|
||||
self.sn = None
|
||||
self.status = None
|
||||
self.type = None
|
||||
self.set_inputs({})
|
||||
|
||||
def set_inputs(self, inputs):
|
||||
self.inputs = inputs
|
||||
self.setCache(inputs.values(), None)
|
||||
if (len(self.take()) == 0):
|
||||
self.setState(State.Offline)
|
||||
else:
|
||||
self.setState(State.Ready)
|
||||
|
||||
def set_input(self, index, val):
|
||||
self.inputs[index] = val
|
||||
self.set_inputs(self.inputs)
|
||||
|
||||
class Esera(TcpDevice):
|
||||
def __init__(self, name, server, timeout = 1000, retries = 1):
|
||||
TcpDevice.__init__(self, name, server)
|
||||
self.setMode(self.Mode.FullDuplex)
|
||||
self.detectors = []
|
||||
self.complete = False
|
||||
|
||||
def start(self):
|
||||
self.write("set,sys,run,1\n")
|
||||
|
||||
def stop(self):
|
||||
self.write("set,sys,run,0\n")
|
||||
|
||||
def list(self):
|
||||
self.write("get,owb,listall1\n")
|
||||
|
||||
def req_data(self):
|
||||
self.write("get,sys,data\n")
|
||||
|
||||
def doInitialize(self):
|
||||
super(Esera, self).doInitialize()
|
||||
try:
|
||||
self.setState(State.Ready) #So can communicate
|
||||
#self.stop()
|
||||
#time.sleep(0.1)
|
||||
#self.flush()
|
||||
self.detectors = []
|
||||
for i in range(30):
|
||||
self.detectors.append(Detector("Detector " + str(i+1)))
|
||||
self.list()
|
||||
time.sleep(0.5)
|
||||
self.start()
|
||||
self.req_data()
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
getLogger().log(traceback.format_exc())
|
||||
raise
|
||||
|
||||
def doUpdate(self):
|
||||
if not self.complete:
|
||||
init = True
|
||||
for det in self.detectors:
|
||||
if det.id == None:
|
||||
init = False
|
||||
break
|
||||
if init:
|
||||
self.complete = True
|
||||
self.start()
|
||||
|
||||
self.req_data()
|
||||
#def onByte(self, rx):
|
||||
# print rx
|
||||
|
||||
def onString(self, msg):
|
||||
print msg
|
||||
tokens = msg.split("|")
|
||||
if len(tokens)>1:
|
||||
try:
|
||||
if msg[:3] == "LST":
|
||||
#LST|1_OWD1|3AF361270000009E|S_0|DS2413|
|
||||
if tokens[1] > 1:
|
||||
index = int(tokens[1].split("_")[1][3:]) - 1
|
||||
if index < len(self.detectors):
|
||||
det = self.detectors[index]
|
||||
det.id = tokens[1]
|
||||
det.sn= tokens[2] if len(tokens)>2 else None
|
||||
det.status = int(tokens[3][2:]) if len(tokens)>3 else None
|
||||
det.type = tokens[4] if len(tokens)>4 else None
|
||||
if det.status!= 0:
|
||||
det.set_inputs({})
|
||||
else:
|
||||
for det in self.detectors:
|
||||
if det.id is not None and msg.startswith(det.id):
|
||||
det_id = int(tokens[0][len(det.id)+1:])
|
||||
det.set_input(det_id, int(tokens[1]))
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
getLogger().log(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
|
||||
#count = 1
|
||||
#while (True):
|
||||
# print onewire.waitString("\n", 1000)#
|
||||
#
|
||||
# print count
|
||||
# count = count + 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add_device(Esera("onewire", "129.129.126.83:5000"), force = True)
|
||||
onewire.setPolling(1000)
|
||||
add_device(onewire.detectors[0], force = True)
|
||||
add_device(onewire.detectors[1], force = True)
|
||||
add_device(onewire.detectors[2], force = True)
|
||||
24
script/test/test.py
Normal file
24
script/test/test.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from ijutils import *
|
||||
import java.awt.Color as Color
|
||||
|
||||
|
||||
#ip = load_array(img.getData().getMatrix())
|
||||
ip = load_image(img.getOutput())
|
||||
#ip = load_image("{images}/test3.png", title="Image")
|
||||
|
||||
|
||||
aux = grayscale(ip, in_place=False)
|
||||
aux.show()
|
||||
|
||||
#convolve(aux, KERNEL_SOBEL); aux.repaintWindow()
|
||||
|
||||
invert(aux); aux.repaintWindow()
|
||||
subtract_background(aux); aux.repaintWindow()
|
||||
auto_threshold(aux); aux.repaintWindow()
|
||||
binary_open(aux); aux.repaintWindow()
|
||||
|
||||
(table, image) = analyse_particles(aux, 250,1000,
|
||||
fill_holes = False, exclude_edges = True,print_table=True,
|
||||
output_image = "outlines", minCirc = 0.82, maxCirc = 1.0)
|
||||
|
||||
image.show()
|
||||
8
script/test/test_hexiposi.py
Normal file
8
script/test/test_hexiposi.py
Normal file
@@ -0,0 +1,8 @@
|
||||
index = 1
|
||||
while(True):
|
||||
for pos in ['A', 'B', 'C', 'D', 'E', 'F']:
|
||||
hexiposi.move(pos)
|
||||
visual_check_hexiposi(pos)
|
||||
print "Ok: " + pos
|
||||
print index
|
||||
index = index + 1
|
||||
16
script/test/test_segments.py
Normal file
16
script/test/test_segments.py
Normal file
@@ -0,0 +1,16 @@
|
||||
p=robot.get_cartesian_pos()
|
||||
print "Pos: ", p
|
||||
print "Cache pos:", robot.cartesian_pos
|
||||
print "Cache dest: ", robot.cartesian_destination
|
||||
|
||||
|
||||
print "Points: ", robot.get_current_points()
|
||||
for segment in known_segments:
|
||||
if is_on_segment(segment):
|
||||
print " On : " + str(segment) + " - Dist:" + str(get_dist_to_segment(segment))
|
||||
|
||||
|
||||
|
||||
p2 = robot.get_cartesian_pos()
|
||||
if arrsub( p2, p) != [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]:
|
||||
print "Pos: ", p2
|
||||
24
script/test/test_swingutils.py
Normal file
24
script/test/test_swingutils.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import ch.psi.pshell.imaging.RendererMode as RendererMode
|
||||
import ch.psi.pshell.imaging.Calibration as Calibration
|
||||
from ch.psi.pshell.imaging.Overlays import *
|
||||
import ch.psi.utils.swing.SwingUtils as SwingUtils
|
||||
import javax.swing.SwingUtilities as SwingUtilities
|
||||
from swingutils.threads.swing import callSwing
|
||||
|
||||
|
||||
p = show_panel(img)
|
||||
dlg = SwingUtilities.getWindowAncestor(p)
|
||||
dlg.setSize(800,800)
|
||||
frm=SwingUtils.getFrame(p)
|
||||
dlg.setLocationRelativeTo(frm)
|
||||
|
||||
def update_frame(frm):
|
||||
SwingUtilities.updateComponentTreeUI(frm)
|
||||
frm.validate()
|
||||
frm.repaint()
|
||||
#$callSwing(update_frame, frm)
|
||||
|
||||
|
||||
x=0
|
||||
for i in range(0,10000000):
|
||||
x=x+1
|
||||
3
script/test/then.py
Normal file
3
script/test/then.py
Normal file
@@ -0,0 +1,3 @@
|
||||
time.sleep(3.0)
|
||||
|
||||
set_exec_pars(then = "time.sleep(5.0)")
|
||||
23
script/test/transfer_profile.py
Normal file
23
script/test/transfer_profile.py
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
measures = []
|
||||
#smart_magnet.measures = []
|
||||
|
||||
|
||||
for m in range(1):
|
||||
print "Step ", m
|
||||
start = time.time()
|
||||
#mount('A',3,m+1, force=True, read_dm=False, auto_unmount=True)
|
||||
#mount('A',5,m+1, force=True, read_dm=False, auto_unmount=True)
|
||||
|
||||
#mount('A',3,1, force=True, read_dm=False, auto_unmount=True)
|
||||
#unmount('A',3,1, force=True)
|
||||
#mount('A',3,1, force=True, read_dm=False, auto_unmount=True)
|
||||
measures.append( time.time()-start)
|
||||
|
||||
print "Total transfer: ", measures
|
||||
print "Time: ", mean(measures), "+-", stdev(measures)
|
||||
|
||||
|
||||
#print "SM cehck: ", smart_magnet.measures
|
||||
#print "Time: ", mean(smart_magnet.measures), "+-", stdev(smart_magnet.measures)
|
||||
98
script/test/unmount_profile.py
Normal file
98
script/test/unmount_profile.py
Normal file
@@ -0,0 +1,98 @@
|
||||
def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False):
|
||||
"""
|
||||
"""
|
||||
print "unmount: ", segment, puck, sample, force
|
||||
start = time.time()
|
||||
#ZACH
|
||||
is_aux = (segment == AUX_SEGMENT)
|
||||
needs_chilling = not is_aux and (not robot.is_cold())
|
||||
needs_drying = is_aux and robot.is_cold()
|
||||
|
||||
if (segment is None) or (puck is None) or (sample is None):
|
||||
pos = get_setting("mounted_sample_position")
|
||||
if pos is None:
|
||||
raise Exception("Mounted sample position is not defined")
|
||||
segment, puck , sample = pos[0:1], int(pos[1]), int(pos[2:])
|
||||
print "Mounted sample position: ", segment, puck , sample
|
||||
|
||||
#Initial checks
|
||||
print "assert valid address"
|
||||
assert_valid_address(segment, puck, sample)
|
||||
print "asser puck detected"
|
||||
assert_puck_detected(segment, puck)
|
||||
|
||||
if robot.simulated:
|
||||
time.sleep(3.0)
|
||||
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
|
||||
set_setting("mounted_sample_position", None)
|
||||
return
|
||||
|
||||
print "assert no task"
|
||||
robot.assert_no_task()
|
||||
print "reset motion"
|
||||
robot.reset_motion()
|
||||
print "wait ready"
|
||||
robot.wait_ready()
|
||||
print "assert cleared"
|
||||
robot.assert_cleared()
|
||||
#robot.assert_in_known_point()
|
||||
print "assert homed"
|
||||
hexiposi.assert_homed()
|
||||
print "assert mount pos"
|
||||
assert_mount_position()
|
||||
print "Pass A: " , time.time() - start; start = time.time()
|
||||
set_status("Umounting: " + str(segment) + str(puck) + str(sample))
|
||||
|
||||
try:
|
||||
if smart_magnet.get_supress() == True:
|
||||
smart_magnet.set_supress(False)
|
||||
time.sleep(0.2)
|
||||
|
||||
smart_magnet.apply_resting()
|
||||
|
||||
if not force:
|
||||
if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False:
|
||||
raise Exception("No pin detected on gonio")
|
||||
print "Pass B: " , time.time() - start; start = time.time()
|
||||
#Enabling
|
||||
enable_motion()
|
||||
print "Pass C: " , time.time() - start; start = time.time()
|
||||
|
||||
if not is_aux:
|
||||
set_hexiposi(segment)
|
||||
print "Pass D: " , time.time() - start; start = time.time()
|
||||
if not force:
|
||||
visual_check_hexiposi(segment)
|
||||
if needs_chilling:
|
||||
robot.move_cold()
|
||||
time.sleep(30.)
|
||||
else:
|
||||
if needs_drying:
|
||||
dry(wait_cold=-1)
|
||||
#location = robot.get_current_point()
|
||||
print "Pass E: " , time.time() - start; start = time.time()
|
||||
if not robot.is_gonio():
|
||||
robot.move_gonio()
|
||||
print "Pass F: " , time.time() - start; start = time.time()
|
||||
#smart_magnet.set_unmount_current()
|
||||
|
||||
robot.get_gonio()
|
||||
print "Pass G: " , time.time() - start; start = time.time()
|
||||
#smart_magnet.apply_reverse()
|
||||
#smart_magnet.apply_resting()
|
||||
|
||||
if is_aux:
|
||||
robot.move_aux()
|
||||
robot.put_aux( sample)
|
||||
else:
|
||||
#TODO: Shuld check if smart magnet detection is off?
|
||||
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
|
||||
robot.move_dewar()
|
||||
print "Pass H: " , time.time() - start; start = time.time()
|
||||
robot.put_dewar(segment, puck, sample)
|
||||
print "Pass I: " , time.time() - start; start = time.time()
|
||||
set_setting("mounted_sample_position", None)
|
||||
finally:
|
||||
if not auto_unmount:
|
||||
smart_magnet.set_default_current()
|
||||
smart_magnet.set_supress(True)
|
||||
Reference in New Issue
Block a user