diff --git a/config/devices.properties b/config/devices.properties index 8333575..b7a74e9 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -38,7 +38,7 @@ gripperID_LSB=ch.psi.pshell.modbus.DigitalInput|wago 11||1000| gripperID_=ch.psi.pshell.modbus.DigitalInput|wago 12||1000| gripperID_MSB=ch.psi.pshell.modbus.DigitalInput|wago 13||1000| RT_gripper_open=ch.psi.pshell.modbus.DigitalInput|wago 14||1000| -RT_gripper_close\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020RT_gripper_close=ch.psi.pshell.modbus.DigitalInput|wago 15||1000| +RT_gripper_close=ch.psi.pshell.modbus.DigitalInput|wago 15||1000| RT_sample_detection=ch.psi.pshell.modbus.DigitalInput|wago 16||1000| smc_magnet_status=ch.psi.pshell.modbus.DigitalInput|wago 17||1000| smc_mounted_1=ch.psi.pshell.modbus.DigitalInput|wago 18||1000| diff --git a/config/settings.properties b/config/settings.properties index c67b086..149e438 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,4 +1,4 @@ -#Wed Apr 26 11:00:26 CEST 2023 +#Fri Apr 28 11:26:20 CEST 2023 dry_mount_counter=0 room_temperature_enabled=true pin_offset=0.0 diff --git a/plugins/Commands.form b/plugins/Commands.form index 9af5d1f..ca822ac 100644 --- a/plugins/Commands.form +++ b/plugins/Commands.form @@ -565,27 +565,32 @@ - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - + + + + + + + + + + + + @@ -635,7 +640,15 @@ - + + + + + + + + + @@ -778,6 +791,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -795,7 +832,7 @@ - + diff --git a/plugins/Commands.java b/plugins/Commands.java index ff54e04..d8157e0 100644 --- a/plugins/Commands.java +++ b/plugins/Commands.java @@ -185,6 +185,9 @@ public class Commands extends Panel { buttonGetRT = new javax.swing.JButton(); buttonPutRT = new javax.swing.JButton(); buttonMoveRT = new javax.swing.JButton(); + buttonMoveGonioWait = new javax.swing.JButton(); + buttonOpenLid = new javax.swing.JButton(); + buttonCloseLid = new javax.swing.JButton(); pnDatabase = new javax.swing.JPanel(); buttonClearSampleDb = new javax.swing.JButton(); buttonResetPuckIds = new javax.swing.JButton(); @@ -626,32 +629,57 @@ public class Commands extends Panel { } }); + buttonMoveGonioWait.setText("Move G Wait"); + buttonMoveGonioWait.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonMoveGonioWaitActionPerformed(evt); + } + }); + + buttonOpenLid.setText("Open Lid"); + buttonOpenLid.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonOpenLidActionPerformed(evt); + } + }); + + buttonCloseLid.setText("Close Lid"); + buttonCloseLid.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonCloseLidActionPerformed(evt); + } + }); + javax.swing.GroupLayout pnLowLevelLayout = new javax.swing.GroupLayout(pnLowLevel); pnLowLevel.setLayout(pnLowLevelLayout); pnLowLevelLayout.setHorizontalGroup( pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnLowLevelLayout.createSequentialGroup() .addContainerGap() + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(buttonMovePark, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE) + .addComponent(buttonMoveAux, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonMoveCold, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE) + .addComponent(buttonMoveHeater, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonGetGonio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonGetDewar, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE) + .addComponent(buttonGetAux, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE) + .addComponent(buttonGetRT, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE) + .addComponent(buttonMoveRT, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonOpenLid, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonMovePark, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveAux) - .addComponent(buttonMoveCold, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveHeater) - .addComponent(buttonGetGonio) - .addComponent(buttonGetDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonGetAux, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonGetRT, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveRT)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE) - .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonPutDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonPutGonio, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveGonio, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveHome, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonMoveScanner) - .addComponent(buttonPutAux, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonPutRT, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonPutDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonPutGonio, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveHome, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveDewar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveScanner) + .addComponent(buttonPutAux, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonPutRT, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(buttonMoveGonio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonMoveGonioWait, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonCloseLid, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); @@ -693,7 +721,13 @@ public class Commands extends Panel { .addComponent(buttonMoveHeater) .addComponent(buttonMoveScanner)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonMoveRT) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonMoveRT) + .addComponent(buttonMoveGonioWait)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnLowLevelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonOpenLid) + .addComponent(buttonCloseLid)) .addContainerGap()) ); @@ -720,7 +754,7 @@ public class Commands extends Panel { .addGroup(pnDatabaseLayout.createSequentialGroup() .addContainerGap() .addComponent(buttonClearSampleDb) - .addGap(18, 18, Short.MAX_VALUE) + .addGap(18, 68, Short.MAX_VALUE) .addComponent(buttonResetPuckIds) .addContainerGap()) ); @@ -979,8 +1013,21 @@ public class Commands extends Panel { onTimer(); }//GEN-LAST:event_buttonGripperDetectActionPerformed + private void buttonMoveGonioWaitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveGonioWaitActionPerformed + execute("move_gonio_wait()"); + }//GEN-LAST:event_buttonMoveGonioWaitActionPerformed + + private void buttonOpenLidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOpenLidActionPerformed + execute("open_lid()"); + }//GEN-LAST:event_buttonOpenLidActionPerformed + + private void buttonCloseLidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseLidActionPerformed + execute("close_lid()"); + }//GEN-LAST:event_buttonCloseLidActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonClearSampleDb; + private javax.swing.JButton buttonCloseLid; private javax.swing.JButton buttonDry; private javax.swing.JButton buttonEnableAll; private javax.swing.JButton buttonGetAux; @@ -994,11 +1041,13 @@ public class Commands extends Panel { private javax.swing.JButton buttonMoveCold; private javax.swing.JButton buttonMoveDewar; private javax.swing.JButton buttonMoveGonio; + private javax.swing.JButton buttonMoveGonioWait; private javax.swing.JButton buttonMoveHeater; private javax.swing.JButton buttonMoveHome; private javax.swing.JButton buttonMovePark; private javax.swing.JButton buttonMoveRT; private javax.swing.JButton buttonMoveScanner; + private javax.swing.JButton buttonOpenLid; private javax.swing.JButton buttonPutAux; private javax.swing.JButton buttonPutDewar; private javax.swing.JButton buttonPutGonio; diff --git a/plugins/MXSC-1.19.0.jar b/plugins/MXSC-1.19.0.jar index a6b3bf5..ac0c6f1 100644 Binary files a/plugins/MXSC-1.19.0.jar and b/plugins/MXSC-1.19.0.jar differ diff --git a/script/devices/RobotSCRT.py b/script/devices/RobotSCRT.py index b2e6c8c..d552b31 100644 --- a/script/devices/RobotSCRT.py +++ b/script/devices/RobotSCRT.py @@ -1,7 +1,3 @@ -TOOL_CALIBRATION = "tCalib" -TOOL_SUNA= "tSuna" -TOOL_DEFAULT= TOOL_SUNA - FRAME_TABLE = "fTable" DESC_FAST = "mFast" @@ -11,7 +7,6 @@ DESC_DEFAULT = DESC_FAST AUX_SEGMENT = "X" RT_SEGMENT = "R" -COLD_SEGMENTS = "ABCDEF" DEFAULT_ROBOT_POLLING = 500 TASK_WAIT_ROBOT_POLLING = 50 @@ -22,17 +17,17 @@ run("devices/RobotTCP") 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", "recover", "mvDewar", "mvCold", "mvPark", "mvGonio","mvHeater", "mvScanner","mvHome", "mvAux","mvRT","getAux","putAux"]) - self.set_known_points(["pPark", "pGonio", "pDewar", "pGonioG", "pScan", "pHeater", "pHeat", "pHeatB","pHe", "pHome", "pCold", "pAux", "pRT"]) + RobotTCP.__init__(self, name, server, timeout, retries) + self.set_tasks([ "mvGonio","putGonio", "getGonio", "recover", "mvPark", "mvGonioW","mvHome", "mvRT", "mvAux" "getRT", "putRT","getAux","putAux", "mvScanner", "openLid", "closeLid"]) + self.set_known_points(["pPark", "pGonio", "pGonioG","pHome", "pRTHome","pGonio", "pAux", "pScan"]) self.setPolling(DEFAULT_ROBOT_POLLING) self.last_command_timestamp = None self.last_command_position = None self.ongoing_task = None + #self.gripper_open_value = False #self.setSimulated() def wait_async_motion(self): @@ -44,29 +39,20 @@ class RobotSC(RobotTCP): self.last_command_timestamp = time.time() self.ongoing_task = None - def move_dewar_async(self): - self.start_task('mvDewar') - self.ongoing_task = ("dewar", self.assert_dewar) + def move_rt_async(self): + self.start_task('mvRT') + self.ongoing_task = ("rt", self.assert_rt) - def move_dewar(self): - #self.start_task('mvDewar') + def move_rt(self): + #self.start_task('mvRT') #self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) #self.assert_dewar() - self.move_dewar_async() - self.wait_async_motion() + self.move_rt_async() + self.wait_async_motion() + - def move_cold_async(self): - self.start_task('mvCold') - self.ongoing_task = ("cold", self.assert_cold) - - def move_cold(self): - #self.start_task('mvCold') - #self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - #self.assert_cold() - self.move_cold_async() - self.wait_async_motion() def move_home_async(self): - self.start_task('moveHome') + self.start_task('mvHome') self.ongoing_task = ("home", self.assert_home) def move_home(self): @@ -76,33 +62,28 @@ class RobotSC(RobotTCP): #self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) #self.assert_home() - def get_dewar(self, segment, puck, sample, mounting_in_same_segment=False): + def get_rt(self, segment, puck, sample, mounting_in_same_segment=False): segment = self.toSegmentNumber(segment) - self.start_task('getDewar',segment, puck, sample, is_room_temp(), mounting_in_same_segment) + self.start_task('getRT',segment, sample) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) if not mounting_in_same_segment: - self.assert_dewar() - self.last_command_position = "dewar" + self.assert_rt() + self.last_command_position = "rt" self.last_command_timestamp = time.time() - def put_dewar(self, segment, puck, sample, mounting_in_same_segment=False): + def put_rt(self, segment, puck, sample, mounting_in_same_segment=False): segment = self.toSegmentNumber(segment) - self.assert_dewar() - self.start_task('putDewar',segment, puck, sample, is_room_temp(), mounting_in_same_segment) + self.assert_rt() + self.start_task('putRT',segment, sample) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - #self.assert_dewar() - if not mounting_in_same_segment: - self.assert_cold() - self.last_command_position = "dewar" + #self.assert_rt() + self.last_command_position = "rt" self.last_command_timestamp = time.time() def put_gonio(self): pin_offset = get_pin_offset() pin_angle_offset = get_pin_angle_offset() print "Pin offset = " + str(pin_offset) - if is_valve_controlled(): - self.assert_gonio() - open_valve(10.0) self.start_task('putGonio', pin_offset) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_gonio() @@ -112,15 +93,10 @@ class RobotSC(RobotTCP): self.last_command_timestamp = time.time() def get_gonio(self): - pin_offset = get_pin_offset() - if is_valve_controlled(): - self.assert_gonio() - open_valve(10.0) + pin_offset = get_pin_offset() self.start_task('getGonio', pin_offset) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_gonio() - if is_valve_controlled(): - close_valve() self.last_command_position = "gonio" self.last_command_timestamp = time.time() @@ -139,22 +115,7 @@ class RobotSC(RobotTCP): self.assert_aux() self.last_command_position = "aux" self.last_command_timestamp = time.time() - - def get_rt(self, puck, sample): - self.assert_rt() - self.start_task('getRT', puck, sample) - self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - self.assert_rt() - self.last_command_position = "rt" - self.last_command_timestamp = time.time() - - def put_rt(self, puck, sample): - self.assert_rt() - self.start_task('putRT',puck, sample) - self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - self.assert_rt() - self.last_command_position = "rt" - self.last_command_timestamp = time.time() + def move_scanner(self): self.start_task('mvScanner') @@ -164,7 +125,7 @@ class RobotSC(RobotTCP): self.last_command_timestamp = time.time() def move_laser(self): - self.start_task('moveScanner') + self.start_task('mvScanner') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_laser() self.last_command_position = "scanner" @@ -187,6 +148,13 @@ class RobotSC(RobotTCP): #self.assert_gonio() + def move_gonio_wait(self): + self.start_task('mvGonioW') + self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) + self.assert_gonio_wait() + self.last_command_position = "gonio_wait" + self.last_command_timestamp = time.time() + def move_park_async(self): self.start_task('mvPark') self.ongoing_task = ("park", self.assert_park) @@ -198,17 +166,6 @@ class RobotSC(RobotTCP): #self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) #self.assert_park() - def move_heater(self, speed=-1, to_bottom=True): - self.start_task('mvHeater', speed, to_bottom) - self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - if to_bottom: - self.assert_heater_bottom() - else: - self.assert_heater() - self.last_command_position = "heater" - self.last_command_timestamp = time.time() - - def robot_recover(self): self.start_task('recover') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) @@ -227,19 +184,22 @@ class RobotSC(RobotTCP): #self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) #self.assert_rt() - def get_calibration_tool(self): - self.start_task('getCalTool') - self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - self.assert_scanner() - self.last_command_position = "scanner" - self.last_command_timestamp = time.time() - - def put_calibration_tool(self): - self.start_task('putCalTool') + def open_lid(self, segment): + segment = self.toSegmentNumber(segment) + self.start_task('openLid', segment) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - self.assert_scanner() + self.assert_rt() + self.last_command_position = "open_lid" + self.last_command_timestamp = time.time() + + def close_lid(self, segment): + segment = self.toSegmentNumber(segment) + self.start_task('closeLid', segment) + self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) + self.assert_rt() + self.last_command_position = "close_lid" + self.last_command_timestamp = time.time() - def toSegmentNumber(self, segment): if is_string(segment): @@ -250,21 +210,11 @@ class RobotSC(RobotTCP): def on_event(self,ev): #print "EVT: " + ev pass + def on_change_working_mode(self, working_mode): if get_device("hexiposi") is not None: hexiposi.moved = True #Force image processing on first sample - - def doUpdate(self): - #start = time.time() - RobotTCP.doUpdate(self) - global simulation - if not simulation: - if joint_forces: - if self.state != State.Offline: - self.get_joint_forces() - for dev in [jf1, jf2, jf3, jf4,jf5, jf6, jfc]: - dev.update() - #print time.time() -start + def start_task(self, program, *args, **kwargs): #TODO: Check safe position @@ -276,8 +226,9 @@ class RobotSC(RobotTCP): def gripper_has_sample(self): """checks gripper switches for presence of sample""" - hasSample, toolOpen = self.eval_bool("diToolHasSample"), self.eval_bool("diToolOpen") - return (not toolOpen) and hasSample + return RT_sample_detection.read() + #hasSample, toolOpen = self.eval_bool("diToolHasSample"), self.eval_bool("diToolOpen") + #return (not toolOpen) and hasSample def set_remote_mode(self): @@ -287,31 +238,17 @@ class RobotSC(RobotTCP): robot.set_profile("default") def is_park(self): - return self.is_in_point("pPark") + return self.is_in_point("pPark") - def is_cold(self): - return self.is_in_point("pCold") + def is_gonio_wait(self): + return self.is_in_point("pGonioW") def is_home(self): return self.is_in_point("pHome") - def is_dewar(self): - return self.is_in_point("pDewar") - - def is_heater(self): - return self.is_in_point("pHeat") - - def is_heater_home(self): - return self.is_in_point("pHeater") - - def is_heater_bottom(self): - return self.is_in_point("pHeatB") - def is_gonio(self): return self.is_in_point("pGonio") - def is_helium(self): - return self.is_in_point("pHe") def is_scanner(self): return self.is_in_point("pScan") @@ -320,7 +257,7 @@ class RobotSC(RobotTCP): return self.is_in_point("pAux") def is_rt(self): - return self.is_in_point("pRT") + return self.is_in_point("pRTHome") #def is_scan_stop(self): # return self.is_in_point("pScanStop") @@ -329,33 +266,18 @@ class RobotSC(RobotTCP): #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 - def assert_heater_home(self): - self.assert_in_point("pHeater") - - def assert_cold(self): - self.assert_in_point("pCold") - - def assert_heater(self): - self.assert_in_point("pHeat") - - def assert_heater_bottom(self): - self.assert_in_point("pHeatB") - def assert_park(self): self.assert_in_point("pPark") - + + def assert_gonio_wait(self): + self.assert_in_point("pGonio") + def assert_home(self): self.assert_in_point("pHome") - def assert_dewar(self): - self.assert_in_point("pDewar") - def assert_gonio(self): self.assert_in_point("pGonio") - def assert_helium(self): - self.assert_in_point("pHe") - def assert_scanner(self): self.assert_in_point("pScan") @@ -363,11 +285,7 @@ class RobotSC(RobotTCP): self.assert_in_point("pAux") def assert_rt(self): - self.assert_in_point("pRT") - - - def assert_p1(self): - self.assert_in_point("p1") + self.assert_in_point("pRTHome") def assert_cleared(self): if not self.is_cleared(): @@ -379,10 +297,6 @@ class RobotSC(RobotTCP): if simulation: add_device(RobotSC("robot","localhost:1000"),force = True) else: - #add_device(RobotSC("robot", "129.129.243.120:1000"), force = True) - #add_device(RobotSC("robot", "pcp068129.psi.ch:1000"), force = True) - #add_device(RobotSC("robot", "saresb-cons-06.psi.ch:1000"), force = True) - #Old IP from Bernina# add_device(RobotSC("robot", "129.129.243.90:1000"), force = True) add_device(RobotSC("robot", "129.129.244.40:1000"), force = True) @@ -394,37 +308,3 @@ update_robot_tool() robot.get_current_point() #TODO: REMOVE WHEN CURRENT POINT REPORTED BY POLLING MESSAGE -class jf1(ReadonlyRegisterBase): - def doRead(self): - return None if robot.joint_forces == None else robot.joint_forces[0] -class jf2(ReadonlyRegisterBase): - def doRead(self): - return None if robot.joint_forces == None else robot.joint_forces[1] -class jf3(ReadonlyRegisterBase): - def doRead(self): - return None if robot.joint_forces == None else robot.joint_forces[2] -class jf4(ReadonlyRegisterBase): - def doRead(self): - return None if robot.joint_forces == None else robot.joint_forces[3] -class jf5(ReadonlyRegisterBase): - def doRead(self): - return None if robot.joint_forces == None else robot.joint_forces[4] -class jf6(ReadonlyRegisterBase): - def doRead(self): - return None if robot.joint_forces == None else robot.joint_forces[5] -class jfc(ReadonlyRegisterBase): - def doRead(self): - if robot.joint_forces == None: - return float('NaN') - if robot.powered == False: - return float('NaN') - return (robot.joint_forces[1]+74)/4 + (robot.joint_forces[2]+30)/4 + (robot.joint_forces[4]-0.8)/0.2 - -if joint_forces: - add_device(jf1(), force = True) - add_device(jf2(), force = True) - add_device(jf3(), force = True) - add_device(jf4(), force = True) - add_device(jf5(), force = True) - add_device(jf6(), force = True) - add_device(jfc(), force = True) diff --git a/script/devices/RobotTCP.py b/script/devices/RobotTCP.py index 4727d68..126a786 100644 --- a/script/devices/RobotTCP.py +++ b/script/devices/RobotTCP.py @@ -50,6 +50,7 @@ class RobotTCP(TcpDevice, Stoppable): self.default_speed = 100 self.latency = 0 self.last_msg_timestamp = 0 + self.gripper_open_value = True self.task_start_retries = 3 self.exception_on_task_start_failure = True #Tasks may start and be finished when checked @@ -391,11 +392,11 @@ class RobotTCP(TcpDevice, Stoppable): def reset_motion(self, joint=None, timeout=None): #TODO: in new robot robot.resetMotion() is freezing controller - #self.evaluate("resetMotion()" if (joint is None) else ("resetMotion(" + joint + ")")) - if joint is None: - self.execute('reset', timeout=timeout) - else: - self.execute('reset', str(joint), timeout=timeout) + self.evaluate("resetMotion()" if (joint is None) else ("resetMotion(" + joint + ")")) + #if joint is None: + # self.execute('reset', timeout=timeout) + #else: + # self.execute('reset', str(joint), timeout=timeout) def is_empty(self): self.empty = self.eval_bool("isEmpty()") @@ -431,8 +432,8 @@ class RobotTCP(TcpDevice, Stoppable): joint_or_point = "tcp_p" #TODO: in new robot movel and movej is freezing controller - #ret = self.eval_int("movej(" + joint_or_point + ", " + tool + ", " + desc +")") - ret = int(self.execute('movej',joint_or_point, tool, desc)) + ret = self.eval_int("movej(" + joint_or_point + ", " + tool + ", " + desc +")") + #ret = int(self.execute('movej',joint_or_point, tool, desc)) if sync: self.wait_end_of_move() @@ -445,8 +446,8 @@ class RobotTCP(TcpDevice, Stoppable): robot.set_pnt(point , "tcp_p") point = "tcp_p" #TODO: in new robot movel and movej is freezing controller - #ret = self.eval_int("movel(" + point + ", " + tool + ", " + desc +")") - ret = int(self.execute('movel',point, tool, desc)) + ret = self.eval_int("movel(" + point + ", " + tool + ", " + desc +")") + #ret = int(self.execute('movel',point, tool, desc)) if sync: self.wait_end_of_move() @@ -457,8 +458,8 @@ class RobotTCP(TcpDevice, Stoppable): if tool is None: tool = self.tool #TODO: in new robot movel and movej is freezing controller - #ret = self.eval_int("movec(" + point_interm + ", " + point_target + ", " + tool + ", " + desc +")") - ret = int(self.execute('movec', point_interm, point_target, tool, desc)) + ret = self.eval_int("movec(" + point_interm + ", " + point_target + ", " + tool + ", " + desc +")") + #ret = int(self.execute('movec', point_interm, point_target, tool, desc)) if sync: self.wait_end_of_move() @@ -490,17 +491,21 @@ class RobotTCP(TcpDevice, Stoppable): #Tool - Not synchronized calls: atention to open/close only when state is Ready def open_tool(self, tool=None): if tool is None: tool = self.tool - self.evaluate(tool + ".gripper=true") + level = (str(self.gripper_open_value)).lower() + self.evaluate(tool + ".gripper=" + level) self.tool_open = True def close_tool(self, tool=None): if tool is None: tool = self.tool - self.evaluate(tool + ".gripper=false") + level = (str(not self.gripper_open_value)).lower() + self.evaluate(tool + ".gripper=" + level) self.tool_open = False def is_tool_open(self, tool=None): if tool is None: tool = self.tool self.tool_open = robot.eval_bool(tool + ".gripper") + if not self.gripper_open_value: + self.tool_open = not self.tool_open return self.tool_open @@ -568,8 +573,8 @@ class RobotTCP(TcpDevice, Stoppable): #TODO: in new robot exec taskCreate is freezing controller #REMOVE if bug is fixed - self.execute('task_create',name, str(priority), program, *args) - #self.evaluate('taskCreate "' + name + '", ' + str(priority) + ', ' + cmd) + #self.execute('task_create',name, str(priority), program, *args) + self.evaluate('taskCreate "' + name + '", ' + str(priority) + ', ' + cmd) @@ -701,12 +706,13 @@ class RobotTCP(TcpDevice, Stoppable): if frame is None: frame = self.frame #Do not work - #self.evaluate("tcp_j=herej(); tcp_p=jointToPoint(" + tool + ", " + frame + ", tcp_j)") - #return self.get_pnt() - a = self.execute('get_pos', tool, frame) - ret = [] - for i in range(6): ret.append(float(a[i])) - return ret + self.evaluate("tcp_j=herej(); tcp_p=jointToPoint(" + tool + ", " + frame + ", tcp_j)") + return self.get_pnt() + + #a = self.execute('get_pos', tool, frame) + #ret = [] + #for i in range(6): ret.append(float(a[i])) + #return ret def get_flange_pos(self, frame=None): diff --git a/script/local.py b/script/local.py index a664ecd..3d8bc6a 100644 --- a/script/local.py +++ b/script/local.py @@ -166,6 +166,12 @@ if is_rt(): run("motion_rt/homing_hexiposi") run("motion_rt/robot_recover") run("motion_rt/recover") + run("motion_rt/move_aux") + run("motion_rt/get_aux") + run("motion_rt/put_aux") + run("motion_rt/move_gonio_wait") + run("motion_rt/open_lid") + run("motion_rt/close_lid") else: run("motion/tools") run("motion/mount") @@ -213,7 +219,7 @@ def system_check(robot_move=True): if auto: if not feedback_psys_safety.read(): raise Exception("Psys safety not released") - if not guiding_tool_park.read(): + if not is_rt() and not guiding_tool_park.read(): raise Exception("Guiding tool not parked") def system_check_msg(): diff --git a/script/motion_rt/close_lid.py b/script/motion_rt/close_lid.py new file mode 100644 index 0000000..5004f56 --- /dev/null +++ b/script/motion_rt/close_lid.py @@ -0,0 +1,19 @@ +def close_lid(): + """ + """ + print "close_lid" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + hexiposi.assert_homed() + pos = hexiposi.position + if pos == hexiposi.UNKNOWN_POSITION: + raise Exception("Undefined hexiposi position") + #Enabling + enable_motion() + + robot.close_lid(pos) \ No newline at end of file diff --git a/script/motion_rt/get_aux.py b/script/motion_rt/get_aux.py new file mode 100644 index 0000000..e816c4c --- /dev/null +++ b/script/motion_rt/get_aux.py @@ -0,0 +1,22 @@ +def get_aux(sample): + """ + """ + print "get_aux: ",sample + + sample = int(sample) #assert_valid_sample only acceps int as parameters + #Initial checks + assert_valid_sample(sample) + + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + hexiposi.assert_homed() + + #Enabling + enable_motion() + + if not robot.is_aux(): + robot.move_aux() + + robot.get_aux(sample) diff --git a/script/motion_rt/get_rt.py b/script/motion_rt/get_rt.py index 11b5ba0..0561a30 100644 --- a/script/motion_rt/get_rt.py +++ b/script/motion_rt/get_rt.py @@ -1,20 +1,29 @@ -def get_rt(puck, sample): + + +def get_rt(segment, puck, sample): """ """ - print "get_rt: ",puck, sample + print "get_rt: ", segment, puck, sample #Initial checks - assert_valid_address('R', puck, sample) + assert_valid_address(segment, puck, sample) + assert_puck_detected(segment, puck) robot.assert_no_task() robot.reset_motion() robot.wait_ready() robot.assert_cleared() + #robot.assert_in_known_point() + hexiposi.assert_homed() + #location = robot.get_current_point() + #Enabling enable_motion() + set_hexiposi(segment) + if not robot.is_rt(): robot.move_rt() - robot.get_rt(puck, sample) + robot.get_rt(segment, puck, sample) diff --git a/script/motion_rt/mount.py b/script/motion_rt/mount.py index 55d7581..b514053 100644 --- a/script/motion_rt/mount.py +++ b/script/motion_rt/mount.py @@ -5,17 +5,9 @@ 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 + print "mount: ", segment, puck, sample start = time.time() - - is_aux = (segment == AUX_SEGMENT) - is_rt = (segment == RT_SEGMENT) - - is_room_temp_sample = is_aux or is_rt - - needs_chilling = not is_aux and (not is_rt) and (not robot.is_cold()) - needs_drying = (is_aux or is_rt) and robot.is_cold() puck_address = get_puck_address(puck) if puck_address is None: @@ -48,9 +40,6 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) try: - if needs_chilling: - robot.move_cold() - time.sleep(30.0) if smart_magnet.get_supress() == True: smart_magnet.set_supress(False) @@ -71,35 +60,18 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) #Enabling enable_motion() - if needs_drying: - dry(wait_cold=-1) - if is_aux: - if not robot.is_aux(): - robot.move_aux() - - robot.get_aux(sample) - elif is_rt: - if not robot.is_rt(): - robot.move_rt() - - robot.get_rt(puck, sample) - else: - set_hexiposi(segment) - - if not force: - visual_check_hexiposi(segment) - - if not robot.is_dewar(): - robot.move_dewar() - - robot.get_dewar(segment, puck, sample) + set_hexiposi(segment) + + if not force: + visual_check_hexiposi(segment) - if read_dm: - barcode_reader.start_read(10.0) - robot.move_scanner() - #time.sleep(1.0) + if not robot.is_rt(): + robot.move_rt() + robot.get_rt(segment, puck, sample) + + robot.move_gonio() if read_dm: @@ -110,31 +82,15 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) robot.put_gonio() + + robot.move_home() - - try: - dry_mount_count = int(get_setting("dry_mount_counter")) - except: - dry_mount_count = 0 - - if not is_room_temp_sample: - set_setting("dry_mount_counter", dry_mount_count+1) - - if is_aux or is_rt: - robot.move_home() - else: - robot.move_cold() 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 not is_room_temp_sample and is_force_dry(): - print "Auto dry" - log("Starting auto dry", False) - set_exec_pars(then = "dry()") - set_setting("mounted_sample_position", get_sample_name(segment, puck, sample)) return [mount_sample_detected, mount_sample_id] finally: diff --git a/script/motion_rt/move_aux.py b/script/motion_rt/move_aux.py new file mode 100644 index 0000000..94d6468 --- /dev/null +++ b/script/motion_rt/move_aux.py @@ -0,0 +1,18 @@ +def move_aux(): + """ + """ + print "move_aux" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + + if not robot.is_aux(): + robot.move_aux() \ No newline at end of file diff --git a/script/motion_rt/move_gonio_wait.py b/script/motion_rt/move_gonio_wait.py new file mode 100644 index 0000000..bb4ac07 --- /dev/null +++ b/script/motion_rt/move_gonio_wait.py @@ -0,0 +1,18 @@ +def move_gonio_wait(): + """ + """ + print "move_gonio_wait" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + + #Enabling + enable_motion() + + + if not robot.is_gonio_wait(): + robot.move_gonio_wait() diff --git a/script/motion_rt/open_lid.py b/script/motion_rt/open_lid.py new file mode 100644 index 0000000..a5d1084 --- /dev/null +++ b/script/motion_rt/open_lid.py @@ -0,0 +1,19 @@ +def open_lid(): + """ + """ + print "open_lid" + + #Initial checks + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + hexiposi.assert_homed() + pos = hexiposi.position + if pos == hexiposi.UNKNOWN_POSITION: + raise Exception("Undefined hexiposi position") + #Enabling + enable_motion() + + robot.open_lid(pos) \ No newline at end of file diff --git a/script/motion_rt/put_aux.py b/script/motion_rt/put_aux.py new file mode 100644 index 0000000..5fb97b3 --- /dev/null +++ b/script/motion_rt/put_aux.py @@ -0,0 +1,22 @@ +def put_aux(sample): + """ + """ + print "put_aux: ",sample + + sample = int(sample) #assert_valid_sample only acceps int as parameters + #Initial checks + assert_valid_sample(sample) + + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + hexiposi.assert_homed() + + #Enabling + enable_motion() + + if not robot.is_aux(): + robot.move_aux() + + robot.put_aux(sample) diff --git a/script/motion_rt/put_rt.py b/script/motion_rt/put_rt.py index ed84f4f..a753718 100644 --- a/script/motion_rt/put_rt.py +++ b/script/motion_rt/put_rt.py @@ -1,20 +1,25 @@ -def put_rt(puck, sample): +def put_rt(segment, puck, sample): """ """ - print "put_rt: ",puck, sample + print "put_rt: ", segment, puck, sample #Initial checks - assert_valid_address('R', puck, sample) + assert_valid_address(segment, puck, sample) + assert_puck_detected(segment, puck) robot.assert_no_task() robot.reset_motion() robot.wait_ready() robot.assert_cleared() + #robot.assert_in_known_point() + hexiposi.assert_homed() #Enabling enable_motion() + set_hexiposi(segment) + if not robot.is_rt(): robot.move_rt() - robot.put_rt(puck, sample) + robot.put_rt(segment, puck, sample) diff --git a/script/motion_rt/recover.py b/script/motion_rt/recover.py index 27b2bfd..4bd517a 100644 --- a/script/motion_rt/recover.py +++ b/script/motion_rt/recover.py @@ -7,15 +7,11 @@ RECOVER_DESC = "mRecovery" known_segments = [ ("pPark", "pHome", 50), \ ("pGonio", "pGonioG", 10), \ - ("pHome", "pHe", 230), \ + ("pHome", "pGonioWait", 230), \ ("pHome", "pGonio", 30), \ ("pHome", "pScan", 25), \ - ("pHome", "pHeater", 75), \ - ("pHome", "pDewar", 10), \ - ("pPark", "pHeat", 40), \ - ("pHeater", "pHeatB", 10), \ + ("pHome", "pRTHome", 10), \ ("pPark", "pAux", 50), \ - ("pPark", "pRT", 100), \ ] diff --git a/script/motion_rt/unmount.py b/script/motion_rt/unmount.py index a08fa6b..a5922b6 100644 --- a/script/motion_rt/unmount.py +++ b/script/motion_rt/unmount.py @@ -10,12 +10,7 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun 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 - - is_aux = (segment == AUX_SEGMENT) - is_rt = (segment ==RT_SEGMENT) - - needs_chilling = not is_aux and (not is_rt) and (not robot.is_cold()) - needs_drying = (is_aux or is_rt) and robot.is_cold() + #Initial checks assert_valid_address(segment, puck, sample) @@ -52,41 +47,22 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun #Enabling enable_motion() - if is_aux or is_rt: - if needs_drying: - dry(wait_cold=-1) - else: - set_hexiposi(segment) - - if not force: - visual_check_hexiposi(segment) - if needs_chilling: - robot.move_cold() - time.sleep(30.) + set_hexiposi(segment) - #location = robot.get_current_point() + if not force: + visual_check_hexiposi(segment) + if not robot.is_gonio(): robot.move_gonio() - #smart_magnet.set_unmount_current() - + robot.get_gonio() - #smart_magnet.apply_reverse() - #smart_magnet.apply_resting() - - if is_aux: - robot.move_aux() - robot.put_aux( sample) - elif is_rt: - robot.move_rt() - robot.put_rt( puck, 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() - robot.put_dewar(segment, puck, sample) + #TODO: Shuld check if smart magnet detection is off? + update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) + robot.move_rt() + robot.put_rt(segment, puck, sample) set_setting("mounted_sample_position", None) finally: if not auto_unmount: