diff --git a/pyproject.toml b/pyproject.toml index e3ddcd89..57e92338 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ dependencies = [ "labthings-fastapi[server] == 0.0.7", "labthings-sangaboard", - "camera-stage-mapping ~= 0.1.7", + "camera-stage-mapping ~= 0.1.8", "opencv-python ~= 4.7.0", "pillow ~= 10.4", "anyio ~= 4.0", diff --git a/src/openflexure_microscope_server/things/camera_stage_mapping.py b/src/openflexure_microscope_server/things/camera_stage_mapping.py index 5efdfb59..a860636f 100644 --- a/src/openflexure_microscope_server/things/camera_stage_mapping.py +++ b/src/openflexure_microscope_server/things/camera_stage_mapping.py @@ -32,6 +32,7 @@ from camera_stage_mapping.camera_stage_calibration_1d import ( calibrate_backlash_1d, image_to_stage_displacement_from_1d, ) +from camera_stage_mapping.exceptions import MappingError from labthings_fastapi.dependencies.invocation import ( InvocationCancelledError, InvocationLogger, @@ -207,9 +208,14 @@ class CameraStageMapper(Thing): tracker, move, direction_array, logger=logger ) except InvocationCancelledError as e: + logger.info("User cancelled the camera stage mapping calibration") logger.info("Returning to starting position") stage.move_absolute(**starting_position, block_cancellation=True) raise e + except MappingError as e: + logger.info("Returning to starting position due to failed calibration") + stage.move_absolute(**starting_position, block_cancellation=True) + raise e result["move_history"] = move.history result["image_resolution"] = hw.grab_image().shape[:2] return result