Merge branch 'csm-return-to-start' into 'v3'

CSM always returns to start on error

See merge request openflexure/openflexure-microscope-server!227
This commit is contained in:
Joe Knapper 2025-04-08 12:49:38 +00:00
commit d4247235e3
2 changed files with 7 additions and 1 deletions

View file

@ -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",

View file

@ -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