diff --git a/software/control/core/core.py b/software/control/core/core.py index e7d8bb6e..5994a08f 100644 --- a/software/control/core/core.py +++ b/software/control/core/core.py @@ -4607,8 +4607,8 @@ def initialize_auto(self) -> bool: # Move to first position and measure if self.piezo is not None: - self._move_z(-self.PIXEL_TO_UM_CALIBRATION_DISTANCE/2) - time.sleep(MULTIPOINT_PIEZO_DELAY_MS/1000) + self._move_z(-self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 2) + time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000) else: # TODO: change to _move_z after backlash correction is absorbed into firmware self.stage.move_z(-1.5 * self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 1000) @@ -4623,8 +4623,8 @@ def initialize_auto(self) -> bool: x0, y0 = result # Move to second position and measure - self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE/2) - time.sleep(MULTIPOINT_PIEZO_DELAY_MS/1000) + self._move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE) + time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000) result = self._get_laser_spot_centroid() if result is None: @@ -4637,6 +4637,15 @@ def initialize_auto(self) -> bool: self.microcontroller.turn_off_AF_laser() self.microcontroller.wait_till_operation_is_completed() + # move back to initial position + if self.piezo is not None: + self._move_z(-self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 2) + time.sleep(MULTIPOINT_PIEZO_DELAY_MS / 1000) + else: + # TODO: change to _move_z after backlash correction is absorbed into firmware + self.stage.move_z(-1.5 * self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 1000) + self.stage.move_z(self.PIXEL_TO_UM_CALIBRATION_DISTANCE / 1000) + # Calculate conversion factor if x1 - x0 == 0: self.pixel_to_um = 0.4 # Simulation value @@ -4794,10 +4803,10 @@ def _verify_spot_alignment(self) -> bool: self.microcontroller.wait_till_operation_is_completed() # TODO: create a function to get the current image (taking care of trigger mode checking and laser on/off switching) - ''' + """ self.camera.send_trigger() current_image = self.camera.read_frame() - ''' + """ self._get_laser_spot_centroid() current_image = self.image