Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
(#798) Add more debugging around finding the pin tip
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Jul 13, 2023
1 parent f8cb2d0 commit c11050d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/artemis/device_setup_plans/setup_oav.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 11 additions & 4 deletions src/artemis/experiment_plans/oav_grid_detection_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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)

0 comments on commit c11050d

Please sign in to comment.