Skip to content

Commit

Permalink
fix(api): use consistent CriticalPoints when moving to maintenance po…
Browse files Browse the repository at this point in the history
…sition (#12878)

Use the MOUNT critical point for moving to X and Y position, but still calculate final Z position based on the tip of whatever's attached to the mount
  • Loading branch information
fsinapi authored Jun 9, 2023
1 parent f074b53 commit 9f28e7f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,23 @@ async def execute(
ot3_api = ensure_ot3_hardware(
self._hardware_api,
)
current_position = await ot3_api.gantry_position(Mount.LEFT)
max_height_z = ot3_api.get_instrument_max_height(Mount.LEFT)
current_position_mount = await ot3_api.gantry_position(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
max_height_z_mount = ot3_api.get_instrument_max_height(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
max_height_z_tip = ot3_api.get_instrument_max_height(Mount.LEFT)
# avoid using motion planning waypoints because we do not need to move the z at this moment
movement_points = [
# move the z to the highest position
Point(x=current_position.x, y=current_position.y, z=max_height_z),
Point(
x=current_position_mount.x,
y=current_position_mount.y,
z=max_height_z_mount,
),
# move in x,y without going down the z
Point(x=_ATTACH_POINT.x, y=_ATTACH_POINT.y, z=max_height_z),
Point(x=_ATTACH_POINT.x, y=_ATTACH_POINT.y, z=max_height_z_mount),
]

for movement in movement_points:
Expand All @@ -108,7 +117,7 @@ async def execute(
}
)
else:
max_motion_range = max_height_z - _MAX_Z_AXIS_MOTION_RANGE
max_motion_range = max_height_z_tip - _MAX_Z_AXIS_MOTION_RANGE
await ot3_api.move_axes(
{
OT3Axis.Z_L: max_motion_range + _LEFT_MOUNT_Z_MARGIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ async def test_calibration_move_to_location_implementation(
mount=MountType.LEFT, maintenancePosition=maintenance_position
)

decoy.when(await ot3_hardware_api.gantry_position(Mount.LEFT)).then_return(
Point(x=1, y=2, z=3)
)
decoy.when(
await ot3_hardware_api.gantry_position(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
).then_return(Point(x=1, y=2, z=3))

decoy.when(
ot3_hardware_api.get_instrument_max_height(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
).then_return(250)

decoy.when(ot3_hardware_api.get_instrument_max_height(Mount.LEFT)).then_return(300)

Expand All @@ -70,7 +78,7 @@ async def test_calibration_move_to_location_implementation(
decoy.verify(
await ot3_hardware_api.move_to(
mount=Mount.LEFT,
abs_position=Point(x=1, y=2, z=300),
abs_position=Point(x=1, y=2, z=250),
critical_point=CriticalPoint.MOUNT,
),
times=1,
Expand All @@ -79,7 +87,7 @@ async def test_calibration_move_to_location_implementation(
decoy.verify(
await ot3_hardware_api.move_to(
mount=Mount.LEFT,
abs_position=Point(x=0, y=110, z=300),
abs_position=Point(x=0, y=110, z=250),
critical_point=CriticalPoint.MOUNT,
),
times=1,
Expand Down

0 comments on commit 9f28e7f

Please sign in to comment.