This commit is contained in:
gac-S_Changer
2018-06-29 11:27:20 +02:00
parent 51858eb819
commit 4371d9c6d8
38 changed files with 379 additions and 61 deletions
+33 -8
View File
@@ -4,6 +4,9 @@ class BarcodeReader(DeviceBase):
def doInitialize(self):
self.disable()
self.readout = None
self.processing = False
self.task_callable=None
def enable(self):
microscan_cmd.write("<H>")
@@ -17,6 +20,7 @@ class BarcodeReader(DeviceBase):
self.state.assertReady()
try:
self.setState(State.Busy)
microscan.flush()
ret = microscan.waitString(int(timeout * 1000))
self.setCache(ret, None)
return ret
@@ -31,17 +35,38 @@ class BarcodeReader(DeviceBase):
def read(self,timeout=1.0):
initial = self.state
if initial == State.Disabled:
self.enable()
if self.processing:
raise Exception("Ongoing read operation")
self.processing = True
try:
return self.get()
finally:
initial = self.state
if initial == State.Disabled:
self.disable()
self.enable()
try:
return self.get(timeout)
finally:
if initial == State.Disabled:
self.disable()
finally:
self.processing = False
def _read_task(self, timeout):
global readout
self.readout = self.read(timeout)
return self.readout
def start_read(self, timeout=1.0):
self.readout = None
self.task_callable = fork((self._read_task, (timeout,)))
def get_readout(self):
return self.readout
def wait_readout(self):
if self.task_callable is not None:
join(self.task_callable)
self.task_callable = None
return self.readout
add_device(BarcodeReader("barcode_reader"), force = True)
+22 -9
View File
@@ -19,12 +19,11 @@ simulation = False
joint_forces = False
class RobotSC(RobotTCP):
def __init__(self, name, server, timeout = 1000, retries = 1):
RobotTCP.__init__(self, name, server, timeout, retries)
self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "movePark", "moveGonio","moveHeater", "moveScanner"])
self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom"])
self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop"])
self.setPolling(DEFAULT_ROBOT_POLLING)
def move_dewar(self):
@@ -60,6 +59,16 @@ class RobotSC(RobotTCP):
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_scanner()
def move_scanner(self):
self.start_task('moveScanner')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_scanner()
#def do_scan(self):
# self.start_task('doScan')
# self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
# self.assert_scan_stop()
def move_gonio(self):
self.start_task('moveGonio')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
@@ -156,6 +165,9 @@ class RobotSC(RobotTCP):
def is_scanner(self):
return self.is_in_point("pScanHome")
#def is_scan_stop(self):
# return self.is_in_point("pScanStop")
def is_cleared(self):
#return self.is_home() or self.is_park() or self.is_dewar() or self.is_dewar_home()
return self.get_current_point() is not None
@@ -187,9 +199,15 @@ class RobotSC(RobotTCP):
def assert_scanner(self):
self.assert_in_point("pScanHome")
#def assert_scan_stop(self):
# self.assert_in_point("pScanStop")
def assert_cleared(self):
if not self.is_cleared():
raise Exception("Robot not in cleared position")
raise Exception("Robot not in cleared position")
def wait_ready(self):
robot.waitState(State.Ready, 1000) #robot.state.assertReady()
if simulation:
#add_device(RobotSC("robot","129.129.126.92:1000"),force = True)
@@ -234,9 +252,4 @@ if joint_forces:
add_device(jf4(), force = True)
add_device(jf5(), force = True)
add_device(jf6(), force = True)
add_device(jfc(), force = True)
"""
add_device(jfc(), force = True)
+3 -2
View File
@@ -3,6 +3,7 @@ import threading
FRAME_DEFAULT = "world"
FLANGE = "flange"
MAX_NUMBER_PARAMETERS = 20
run("devices/RobotMotors")
@@ -129,7 +130,7 @@ class RobotTCP(TcpDevice, Stoppable):
def execute(self, command, *args, **kwargs):
timeout = None if (kwargs is None) or (not kwargs.has_key("timeout")) else kwargs["timeout"]
msg = str(command)
if len(args)>10:
if len(args)>MAX_NUMBER_PARAMETERS:
raise Exception("Exceeded maximum number of parameters")
for i in range(len(args)):
msg += (self.cmd_separator if (i==0) else self.array_separator) + str(args[i])
@@ -671,7 +672,7 @@ class RobotTCP(TcpDevice, Stoppable):
#for task in tasks:
# if self.get_task_status(task)[0]>=0:
# raise Exception("Ongoing high-level task: " + task)
ts = robot.get_tasks_status(*tasks)
ts = self.get_tasks_status(*tasks)
for i in range(len(ts)):
if ts[i] > 0:
raise Exception("Ongoing high-level task: " + tasks[i])
+2 -2
View File
@@ -10,7 +10,7 @@ class SmartMagnet(DeviceBase):
}))
def doInitialize(self):
DeviceBase.doInitialize(self)
super(SmartMagnet, self).doInitialize()
self.get_current()
def set_current(self, current):
@@ -93,7 +93,7 @@ class SmartMagnet(DeviceBase):
def set_remanence_current(self):
self.set_current(self.config.getFieldValue("remanenceCurrent"))
def set_default_current():
def set_default_current(self):
if self.is_mounted():
self.set_holding_current()
else:
+3
View File
@@ -43,6 +43,7 @@ run("motion/move_park")
run("motion/move_scanner")
run("motion/dry")
run("motion/homing_hexiposi")
run("motion/robot_recover")
run("imgproc/Utils")
run("tools/Math")
@@ -129,6 +130,8 @@ except:
print >> sys.stderr, traceback.format_exc()
#gripper_cam.paused = True
###################################################################################################
# Global variables
###################################################################################################
+1 -1
View File
@@ -34,7 +34,7 @@ def dry(heat_time, speed):
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+1 -1
View File
@@ -7,7 +7,7 @@ def get_dewar(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
+1 -1
View File
@@ -6,7 +6,7 @@ def get_gonio(force=False):
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+1 -1
View File
@@ -5,7 +5,7 @@ def homing_hexiposi():
#Initial checks
robot.assert_no_task()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
#location = robot.get_current_point()
+11 -2
View File
@@ -1,4 +1,4 @@
def mount(segment, puck, sample, force=False):
def mount(segment, puck, sample, force=False, read_dm=False):
"""
"""
print "mount: ", segment, puck, sample, force
@@ -7,7 +7,7 @@ def mount(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
@@ -29,8 +29,17 @@ def mount(segment, puck, sample, force=False):
robot.move_dewar()
robot.get_dewar(segment, puck, sample)
if read_dm:
barcode_reader.start_read(10.0)
robot.move_scanner()
robot.move_gonio()
if read_dm:
dm = barcode_reader.get_readout()
print "Datamatrix: " , dm
smart_magnet.set_mount_current()
try:
robot.put_gonio()
+1 -1
View File
@@ -6,7 +6,7 @@ def move_dewar():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+1 -1
View File
@@ -6,7 +6,7 @@ def move_gonio():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+1 -1
View File
@@ -6,7 +6,7 @@ def move_heater():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+1 -1
View File
@@ -6,7 +6,7 @@ def move_home():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+1 -1
View File
@@ -6,7 +6,7 @@ def move_park():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+10 -2
View File
@@ -6,13 +6,21 @@ def move_scanner():
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
#Enabling
enable_motion()
enable_motion()
#barcode_reader.start_read(20.0)
if not robot.is_scanner():
robot.move_scanner()
#robot.do_scan()
#dm = barcode_reader.get_readout()
dm = barcode_reader.read(0.5)
print "Datamatrix: " , dm
#print "Datamatrix: " , barcode_reader.wait_readout()
+1 -1
View File
@@ -7,7 +7,7 @@ def put_dewar(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
+1 -1
View File
@@ -6,7 +6,7 @@ def put_gonio(segment, puck, sample, force=False):
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
+16
View File
@@ -0,0 +1,16 @@
def robot_recover():
"""
"""
print "robot_recover"
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.wait_ready()
#Enabling
enable_motion()
#barcode_reader.start_read(20.0)
robot.robot_recover()
+13 -4
View File
@@ -7,11 +7,15 @@ def unmount(segment, puck, sample, force=False):
assertValidAddress(segment, puck, sample)
robot.assert_no_task()
robot.reset_motion()
robot.state.assertReady()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
hexiposi.assert_homed()
if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == False:
raise Exception("No pin detected on gonio")
#Enabling
enable_motion()
@@ -25,6 +29,11 @@ def unmount(segment, puck, sample, force=False):
if not robot.is_gonio():
robot.move_gonio()
robot.get_gonio()
robot.move_dewar()
robot.put_dewar(segment, puck, sample)
smart_magnet.set_unmount_current()
try:
robot.get_gonio()
robot.move_dewar()
robot.put_dewar(segment, puck, sample)
finally:
smart_magnet.set_default_current()
+4
View File
@@ -0,0 +1,4 @@
while True:
img.initialize()
img.waitNext(10000)
time.sleep(2.0)
+30
View 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
View File
@@ -0,0 +1,6 @@
import ch.psi.pshell.imaging.MjpegSource as MjpegSource
MjpegSource2 = get_context().pluginManager.getDynamicClass("MjpegSource2")
add_device(MjpegSource2("gripper_cam", "http://129.129.110.114/axis-cgi/mjpg/video.cgi"), True)
gripper_cam.polling=100
#gripper_cam.monitored = True
show_panel(gripper_cam)
+4
View File
@@ -0,0 +1,4 @@
while True:
img.initialize()
img.waitNext(1000)
time.sleep(0.1)
+2
View File
@@ -4,3 +4,5 @@ CMD= "sudo systemctl stop puck_detection.service;sudo systemctl start puck_detec
ret = run("tools/SshExec")
set_return(ret)
puck_detection.initialize()