Update scan planners so secondary locations are imaged first and don't affect later planning

This commit is contained in:
Julian Stirling 2025-11-28 09:53:24 +00:00
parent cd53024c4f
commit 90be139575

View file

@ -409,7 +409,9 @@ class SmartSpiral(ScanPlanner):
self._add_surrounding_positions(xy_pos)
else:
self._add_intermediate_positions(xy_pos)
self._re_sort_remaining_locations(xy_pos)
# Don't re-sort after imaging a secondary location or it can cause scan
# direction to reverse, breaking the spiral.
self._re_sort_remaining_locations(xy_pos)
def _add_surrounding_positions(self, xy_pos: XYPos) -> None:
"""Add the 4 surrounding positions to the list of remaining locations to visit.
@ -504,6 +506,7 @@ class SmartSpiral(ScanPlanner):
# Defined rather than use a lambda for readability
def sort_key(pos: FutureScanLocation) -> tuple[float, float, float]:
return (
self._is_primary_location(pos), # False sorts low
self.moves_between(current_pos, pos),
self.moves_between(self._initial_position, pos),
distance_between(current_pos, pos),