From c11050d11f1b90c39d9f402c0acf806e2917ec9d Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Thu, 13 Jul 2023 15:15:57 +0100 Subject: [PATCH] (#798) Add more debugging around finding the pin tip --- src/artemis/device_setup_plans/setup_oav.py | 4 +++- .../experiment_plans/oav_grid_detection_plan.py | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/artemis/device_setup_plans/setup_oav.py b/src/artemis/device_setup_plans/setup_oav.py index e0ace9640..fc25aa085 100644 --- a/src/artemis/device_setup_plans/setup_oav.py +++ b/src/artemis/device_setup_plans/setup_oav.py @@ -76,13 +76,15 @@ def pre_centring_setup_oav(oav: OAV, parameters: OAVParameters): parameters.minimum_height, ) - # Connect MXSC output to MJPG input yield from start_mxsc( oav, parameters.min_callback_time, parameters.detection_script_filename, ) + # Connect MXSC output to MJPG input for debugging + yield from bps.abs_set(oav.snapshot.input_plugin, "OAV.MXSC") + zoom_level_str = f"{float(parameters.zoom)}x" if zoom_level_str not in oav.zoom_controller.allowed_zoom_levels: raise OAVError_ZoomLevelNotFound( diff --git a/src/artemis/experiment_plans/oav_grid_detection_plan.py b/src/artemis/experiment_plans/oav_grid_detection_plan.py index 9ecb131e3..4843cb9a5 100644 --- a/src/artemis/experiment_plans/oav_grid_detection_plan.py +++ b/src/artemis/experiment_plans/oav_grid_detection_plan.py @@ -8,10 +8,9 @@ import numpy as np from bluesky.preprocessors import finalize_wrapper from dodal.beamlines import i03 -from dodal.devices.areadetector.plugins.MXSC import PinTipDetect from dodal.devices.fast_grid_scan import GridScanParams from dodal.devices.oav.oav_calculations import camera_coordinates_to_xyz -from dodal.devices.oav.oav_detector import OAV +from dodal.devices.oav.oav_detector import MXSC, OAV from dodal.devices.smargon import Smargon from artemis.device_setup_plans.setup_oav import pre_centring_setup_oav @@ -49,10 +48,16 @@ def grid_detection_plan( ) -def wait_for_tip_to_be_found(pin_tip: PinTipDetect): +def wait_for_tip_to_be_found(mxsc: MXSC): + pin_tip = mxsc.pin_tip yield from bps.trigger(pin_tip, wait=True) found_tip = yield from bps.rd(pin_tip) if found_tip == pin_tip.INVALID_POSITION: + top_edge = yield from bps.rd(mxsc.top) + bottom_edge = yield from bps.rd(mxsc.bottom) + LOGGER.info( + f"No tip found with top/bottom of {list(top_edge), list(bottom_edge)}" + ) raise WarningException( f"No pin found after {pin_tip.validity_timeout.get()} seconds" ) @@ -104,7 +109,7 @@ def grid_detection_main_plan( # See #673 for improvements yield from bps.sleep(0.3) - tip_x_px, tip_y_px = yield from wait_for_tip_to_be_found(oav.mxsc.pin_tip) + tip_x_px, tip_y_px = yield from wait_for_tip_to_be_found(oav.mxsc) LOGGER.info(f"Tip is at x,y: {tip_x_px},{tip_y_px}") @@ -208,5 +213,7 @@ def grid_detection_main_plan( def reset_oav(): + """Changes the MJPG stream to look at the camera without the edge detection and turns off the edge detcetion plugin.""" oav = i03.oav() + yield from bps.abs_set(oav.snapshot.input_plugin, "OAV.CAM") yield from bps.abs_set(oav.mxsc.enable_callbacks, 0)