From b8babf3d89950ca9d56bec9fab349978c93ee4ad Mon Sep 17 00:00:00 2001 From: Shekar V Date: Mon, 1 Jul 2024 12:22:41 -0400 Subject: [PATCH 1/3] Added tested code for robot recovery procedure --- daq_macros.py | 10 ++++++++++ embl_robot.py | 23 +++++++++++++++++++---- robot_lib.py | 3 +++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/daq_macros.py b/daq_macros.py index a83c7429..4e6da73a 100644 --- a/daq_macros.py +++ b/daq_macros.py @@ -19,6 +19,7 @@ import parseSheet import attenCalc import raddoseLib +import robot_lib from raddoseLib import * import logging logger = logging.getLogger(__name__) @@ -248,6 +249,15 @@ def changeImageCenterHighMag(x,y,czoom): "face_on_omega" : 0 } +def run_robot_recovery_procedure(): + """ Generic recovery procedure to be used during automated + collection""" + # Recover robot + robot_lib.recoverRobot() + # Dry Gripper + robot_lib.dryGripper() + # Park Gripper and cool gripper + robot_lib.cooldownGripper() def run_top_view_optimized(): RE(topview_optimized()) diff --git a/embl_robot.py b/embl_robot.py index 9d540a15..fadd7beb 100644 --- a/embl_robot.py +++ b/embl_robot.py @@ -442,6 +442,7 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): absPos = (PINS_PER_PUCK*(puckPos%3))+pinPos+1 if getBlConfig('robot_online'): try: + logger.info("Unmounting sample") RobotControlLib.unmount2(absPos) except Exception as e: e_s = str(e) @@ -450,10 +451,24 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): daq_macros.disableMount() daq_lib.gui_message(e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return UNMOUNT_FAILURE - message = "ROBOT unmount2 ERROR: " + e_s - daq_lib.gui_message(message) - logger.error(message) - return UNMOUNT_FAILURE + elif (e_s.find("SE") != -1): + # In case there is an SE Timeout error, run the recovery procedure + daq_macros.run_robot_recovery_procedure() + try: + # Try to unmount again + RobotControlLib.unmount2(absPos) + except Exception as e: + # If there is an exception again, return UNMOUNT_FAILURE + e_s = str(e) + message = "ROBOT unmount2 ERROR: " + e_s + daq_lib.gui_message(message) + logger.error(message) + return UNMOUNT_FAILURE + else: + message = "ROBOT unmount2 ERROR: " + e_s + daq_lib.gui_message(message) + logger.error(message) + return UNMOUNT_FAILURE gov_status = gov_lib.setGovRobot(gov_robot, 'SE') if not gov_status.success: daq_lib.clearMountedSample() diff --git a/robot_lib.py b/robot_lib.py index d9c4bff6..e553f9c2 100644 --- a/robot_lib.py +++ b/robot_lib.py @@ -133,3 +133,6 @@ def openGripper(): def closeGripper(): robot.closeGripper() + +def cooldownGripper(): + robot.cooldownGripper() \ No newline at end of file From 6ece1031913b2eeb0cbdd44b1f7b970e1b605560 Mon Sep 17 00:00:00 2001 From: Shekar V Date: Mon, 1 Jul 2024 12:33:39 -0400 Subject: [PATCH 2/3] Added recovery if unmount attempt 2 is unsuccessful --- embl_robot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/embl_robot.py b/embl_robot.py index fadd7beb..e411a5bd 100644 --- a/embl_robot.py +++ b/embl_robot.py @@ -459,6 +459,7 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): RobotControlLib.unmount2(absPos) except Exception as e: # If there is an exception again, return UNMOUNT_FAILURE + daq_macros.run_robot_recovery_procedure() e_s = str(e) message = "ROBOT unmount2 ERROR: " + e_s daq_lib.gui_message(message) From 7e132decaf84fbfb25e3e157e4df805f0112d1bb Mon Sep 17 00:00:00 2001 From: Shekar V Date: Fri, 5 Jul 2024 10:39:22 -0400 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Jun Aishima --- embl_robot.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/embl_robot.py b/embl_robot.py index e411a5bd..6b9b516f 100644 --- a/embl_robot.py +++ b/embl_robot.py @@ -451,7 +451,7 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): daq_macros.disableMount() daq_lib.gui_message(e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return UNMOUNT_FAILURE - elif (e_s.find("SE") != -1): + elif "SE" in e_s: # In case there is an SE Timeout error, run the recovery procedure daq_macros.run_robot_recovery_procedure() try: @@ -460,8 +460,7 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): except Exception as e: # If there is an exception again, return UNMOUNT_FAILURE daq_macros.run_robot_recovery_procedure() - e_s = str(e) - message = "ROBOT unmount2 ERROR: " + e_s + message = f"ROBOT unmount2 ERROR: {e}" daq_lib.gui_message(message) logger.error(message) return UNMOUNT_FAILURE