From 3473e13648093cce8625390c780d674e2cb3f11e Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Wed, 23 Oct 2024 14:41:06 -0400 Subject: [PATCH 01/10] home gripper axis if stall detected --- .../RunHeaderContent/ActionButton/index.tsx | 23 +++++++++------- .../__tests__/useHomeGripperZAxis.test.ts | 26 +++++++++---------- .../__tests__/useRecoveryCommands.test.ts | 4 +-- .../ErrorRecoveryFlows/hooks/index.ts | 2 +- .../hooks/useHomeGripperZAxis.ts | 6 ++--- .../hooks/useRecoveryCommands.ts | 18 ++++++++++--- 6 files changed, 46 insertions(+), 33 deletions(-) diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx index 4b8c0f68076..babdea8d8a9 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx @@ -75,16 +75,19 @@ export function ActionButton(props: ActionButtonProps): JSX.Element { const isValidRunAgain = isRunAgainStatus(runStatus) const { isClosingCurrentRun } = useCloseCurrentRun() - const { isDisabled, disabledReason } = useActionBtnDisabledUtils({ - isCurrentRun, - isSetupComplete, - isOtherRunCurrent, - isProtocolNotReady, - isRobotOnWrongVersionOfSoftware, - isValidRunAgain, - isClosingCurrentRun, - ...props, - }) + // const { isDisabled, disabledReason } = useActionBtnDisabledUtils({ + // isCurrentRun, + // isSetupComplete, + // isOtherRunCurrent, + // isProtocolNotReady, + // isRobotOnWrongVersionOfSoftware, + // isValidRunAgain, + // isClosingCurrentRun, + // ...props, + // }) + + const isDisabled = false + const disabledReason = '' const robot = useRobot(robotName) const robotSerialNumber = getFallbackRobotSerialNumber(robot) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts index 197dfbfd3e7..953e3d612d0 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts @@ -1,12 +1,12 @@ import { renderHook, act } from '@testing-library/react' import { describe, it, expect, vi, beforeEach } from 'vitest' -import { useHomeGripperZAxis } from '../useHomeGripperZAxis' +import { useHomeGripper } from '../useHomeGripperZAxis' import { RECOVERY_MAP } from '/app/organisms/ErrorRecoveryFlows/constants' -describe('useHomeGripperZAxis', () => { +describe('useHomeGripper', () => { const mockRecoveryCommands = { - homeGripperZAxis: vi.fn().mockResolvedValue(undefined), + homeGripper: vi.fn().mockResolvedValue(undefined), } const mockRouteUpdateActions = { @@ -28,7 +28,7 @@ describe('useHomeGripperZAxis', () => { it('should home gripper Z axis when in manual gripper step and door is closed', async () => { renderHook(() => { - useHomeGripperZAxis({ + useHomeGripper({ recoveryCommands: mockRecoveryCommands, routeUpdateActions: mockRouteUpdateActions, recoveryMap: mockRecoveryMap, @@ -43,7 +43,7 @@ describe('useHomeGripperZAxis', () => { expect(mockRouteUpdateActions.handleMotionRouting).toHaveBeenCalledWith( true ) - expect(mockRecoveryCommands.homeGripperZAxis).toHaveBeenCalled() + expect(mockRecoveryCommands.homeGripper).toHaveBeenCalled() expect(mockRouteUpdateActions.handleMotionRouting).toHaveBeenCalledWith( false ) @@ -51,7 +51,7 @@ describe('useHomeGripperZAxis', () => { it('should go back to previous step when door is open', () => { renderHook(() => { - useHomeGripperZAxis({ + useHomeGripper({ recoveryCommands: mockRecoveryCommands, routeUpdateActions: mockRouteUpdateActions, recoveryMap: mockRecoveryMap, @@ -60,12 +60,12 @@ describe('useHomeGripperZAxis', () => { }) expect(mockRouteUpdateActions.goBackPrevStep).toHaveBeenCalled() - expect(mockRecoveryCommands.homeGripperZAxis).not.toHaveBeenCalled() + expect(mockRecoveryCommands.homeGripper).not.toHaveBeenCalled() }) it('should not home again if already homed once', async () => { const { rerender } = renderHook(() => { - useHomeGripperZAxis({ + useHomeGripper({ recoveryCommands: mockRecoveryCommands, routeUpdateActions: mockRouteUpdateActions, recoveryMap: mockRecoveryMap, @@ -77,17 +77,17 @@ describe('useHomeGripperZAxis', () => { await new Promise(resolve => setTimeout(resolve, 0)) }) - expect(mockRecoveryCommands.homeGripperZAxis).toHaveBeenCalledTimes(1) + expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1) rerender() - expect(mockRecoveryCommands.homeGripperZAxis).toHaveBeenCalledTimes(1) + expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1) }) it('should reset hasHomedOnce when step changes to non-manual gripper step and back', async () => { const { rerender } = renderHook( ({ recoveryMap }) => { - useHomeGripperZAxis({ + useHomeGripper({ recoveryCommands: mockRecoveryCommands, routeUpdateActions: mockRouteUpdateActions, recoveryMap, @@ -103,7 +103,7 @@ describe('useHomeGripperZAxis', () => { await new Promise(resolve => setTimeout(resolve, 0)) }) - expect(mockRecoveryCommands.homeGripperZAxis).toHaveBeenCalledTimes(1) + expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1) rerender({ recoveryMap: { step: 'SOME_OTHER_STEP' } as any }) @@ -117,6 +117,6 @@ describe('useHomeGripperZAxis', () => { await new Promise(resolve => setTimeout(resolve, 0)) }) - expect(mockRecoveryCommands.homeGripperZAxis).toHaveBeenCalledTimes(2) + expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(2) }) }) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts index 11a15edfbfd..c0e052565a5 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts @@ -264,11 +264,11 @@ describe('useRecoveryCommands', () => { ) }) - it('should call homeGripperZAxis and resolve the promise', async () => { + it('should call useHomeGripper and resolve the promise', async () => { const { result } = renderHook(() => useRecoveryCommands(props)) await act(async () => { - await result.current.homeGripperZAxis() + await result.current.homeGripper() }) expect(mockChainRunCommands).toHaveBeenCalledWith( diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts index baa685c0dcc..b63f02d9a17 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts @@ -5,7 +5,7 @@ export { useRouteUpdateActions } from './useRouteUpdateActions' export { useERUtils } from './useERUtils' export { useRecoveryTakeover } from './useRecoveryTakeover' export { useRetainedFailedCommandBySource } from './useRetainedFailedCommandBySource' -export { useHomeGripperZAxis } from './useHomeGripperZAxis' +export { useHomeGripper } from './useHomeGripperZAxis' export type { ERUtilsProps } from './useERUtils' export type { UseRouteUpdateActionsResult } from './useRouteUpdateActions' diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripperZAxis.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripperZAxis.ts index 649fb801d44..36ce031a7fd 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripperZAxis.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripperZAxis.ts @@ -4,7 +4,7 @@ import { RECOVERY_MAP } from '/app/organisms/ErrorRecoveryFlows/constants' import type { ErrorRecoveryWizardProps } from '/app/organisms/ErrorRecoveryFlows/ErrorRecoveryWizard' // Home the gripper z-axis implicitly. Because the z-home is not tied to a CTA, it must be handled here. -export function useHomeGripperZAxis({ +export function useHomeGripper({ recoveryCommands, routeUpdateActions, recoveryMap, @@ -20,7 +20,7 @@ export function useHomeGripperZAxis({ useLayoutEffect(() => { const { handleMotionRouting, goBackPrevStep } = routeUpdateActions - const { homeGripperZAxis } = recoveryCommands + const { homeGripper } = recoveryCommands if (!hasHomedOnce) { if (isManualGripperStep) { @@ -28,7 +28,7 @@ export function useHomeGripperZAxis({ void goBackPrevStep() } else { void handleMotionRouting(true) - .then(() => homeGripperZAxis()) + .then(() => homeGripper()) .then(() => { setHasHomedOnce(true) }) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts index f0962b07693..a274249cac1 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts @@ -63,7 +63,7 @@ export interface UseRecoveryCommandsResult { /* A non-terminal recovery command */ releaseGripperJaws: () => Promise /* A non-terminal recovery command */ - homeGripperZAxis: () => Promise + homeGripper: () => Promise /* A non-terminal recovery command */ moveLabwareWithoutPause: () => Promise } @@ -269,8 +269,12 @@ export function useRecoveryCommands({ return chainRunRecoveryCommands([RELEASE_GRIPPER_JAW]) }, [chainRunRecoveryCommands]) - const homeGripperZAxis = useCallback((): Promise => { - return chainRunRecoveryCommands([HOME_GRIPPER_Z_AXIS]) + const homeGripper = useCallback((): Promise => { + const gripperAxis = + failedCommandByRunRecord?.error?.errorCode === '2003' + ? HOME_GRIPPER + : HOME_GRIPPER_Z_AXIS + return chainRunRecoveryCommands([gripperAxis]) }, [chainRunRecoveryCommands]) const moveLabwareWithoutPause = useCallback((): Promise => { @@ -291,7 +295,7 @@ export function useRecoveryCommands({ homePipetteZAxes, pickUpTips, releaseGripperJaws, - homeGripperZAxis, + homeGripper, moveLabwareWithoutPause, skipFailedCommand, ignoreErrorKindThisRun, @@ -316,6 +320,12 @@ export const HOME_GRIPPER_Z_AXIS: CreateCommand = { intent: 'fixit', } +export const HOME_GRIPPER: CreateCommand = { + commandType: 'home', + params: { axes: ['extensionZ', 'extensionJaw'] }, + intent: 'fixit', +} + const buildMoveLabwareWithoutPause = ( failedCommand: FailedCommand | null ): CreateCommand | null => { From 7825a61bea716191cdae0a16d9051791c890734c Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Wed, 23 Oct 2024 14:50:12 -0400 Subject: [PATCH 02/10] renaming useHomeGripperZAxis --- .../hooks/__tests__/useHomeGripperZAxis.test.ts | 2 +- app/src/organisms/ErrorRecoveryFlows/hooks/index.ts | 2 +- .../hooks/{useHomeGripperZAxis.ts => useHomeGripper.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename app/src/organisms/ErrorRecoveryFlows/hooks/{useHomeGripperZAxis.ts => useHomeGripper.ts} (100%) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts index 953e3d612d0..c640f448d6c 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts @@ -1,7 +1,7 @@ import { renderHook, act } from '@testing-library/react' import { describe, it, expect, vi, beforeEach } from 'vitest' -import { useHomeGripper } from '../useHomeGripperZAxis' +import { useHomeGripper } from '../useHomeGripper' import { RECOVERY_MAP } from '/app/organisms/ErrorRecoveryFlows/constants' describe('useHomeGripper', () => { diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts index b63f02d9a17..75904a24966 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/index.ts @@ -5,7 +5,7 @@ export { useRouteUpdateActions } from './useRouteUpdateActions' export { useERUtils } from './useERUtils' export { useRecoveryTakeover } from './useRecoveryTakeover' export { useRetainedFailedCommandBySource } from './useRetainedFailedCommandBySource' -export { useHomeGripper } from './useHomeGripperZAxis' +export { useHomeGripper } from './useHomeGripper' export type { ERUtilsProps } from './useERUtils' export type { UseRouteUpdateActionsResult } from './useRouteUpdateActions' diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripperZAxis.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts similarity index 100% rename from app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripperZAxis.ts rename to app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts From c9a57ad5dc1e294489868a17819d137062350bb9 Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Wed, 23 Oct 2024 15:04:00 -0400 Subject: [PATCH 03/10] revert debugging changes --- .../RunHeaderContent/ActionButton/index.tsx | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx index babdea8d8a9..4b8c0f68076 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/index.tsx @@ -75,19 +75,16 @@ export function ActionButton(props: ActionButtonProps): JSX.Element { const isValidRunAgain = isRunAgainStatus(runStatus) const { isClosingCurrentRun } = useCloseCurrentRun() - // const { isDisabled, disabledReason } = useActionBtnDisabledUtils({ - // isCurrentRun, - // isSetupComplete, - // isOtherRunCurrent, - // isProtocolNotReady, - // isRobotOnWrongVersionOfSoftware, - // isValidRunAgain, - // isClosingCurrentRun, - // ...props, - // }) - - const isDisabled = false - const disabledReason = '' + const { isDisabled, disabledReason } = useActionBtnDisabledUtils({ + isCurrentRun, + isSetupComplete, + isOtherRunCurrent, + isProtocolNotReady, + isRobotOnWrongVersionOfSoftware, + isValidRunAgain, + isClosingCurrentRun, + ...props, + }) const robot = useRobot(robotName) const robotSerialNumber = getFallbackRobotSerialNumber(robot) From fb6e5b1a282bf97af598a0953fa10560a749624a Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Wed, 23 Oct 2024 16:24:57 -0400 Subject: [PATCH 04/10] always home both axis --- .../ErrorRecoveryFlows/ErrorRecoveryWizard.tsx | 4 ++-- .../hooks/__tests__/useRecoveryCommands.test.ts | 7 ++----- .../ErrorRecoveryFlows/hooks/useRecoveryCommands.ts | 12 +----------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/app/src/organisms/ErrorRecoveryFlows/ErrorRecoveryWizard.tsx b/app/src/organisms/ErrorRecoveryFlows/ErrorRecoveryWizard.tsx index 5f38dfabf48..e1dd7c5add2 100644 --- a/app/src/organisms/ErrorRecoveryFlows/ErrorRecoveryWizard.tsx +++ b/app/src/organisms/ErrorRecoveryFlows/ErrorRecoveryWizard.tsx @@ -29,7 +29,7 @@ import { import { RecoveryInProgress } from './RecoveryInProgress' import { getErrorKind } from './utils' import { RECOVERY_MAP } from './constants' -import { useHomeGripperZAxis } from './hooks' +import { useHomeGripper } from './hooks' import type { LabwareDefinition2, RobotType } from '@opentrons/shared-data' import type { RecoveryRoute, RouteStep, RecoveryContentProps } from './types' @@ -90,7 +90,7 @@ export function ErrorRecoveryWizard( routeUpdateActions, }) - useHomeGripperZAxis(props) + useHomeGripper(props) return } diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts index c0e052565a5..5fe18a914bd 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts @@ -14,7 +14,7 @@ import { RELEASE_GRIPPER_JAW, buildPickUpTips, buildIgnorePolicyRules, - HOME_GRIPPER_Z_AXIS, + HOME_GRIPPER, } from '../useRecoveryCommands' import { RECOVERY_MAP } from '../../constants' @@ -271,10 +271,7 @@ describe('useRecoveryCommands', () => { await result.current.homeGripper() }) - expect(mockChainRunCommands).toHaveBeenCalledWith( - [HOME_GRIPPER_Z_AXIS], - false - ) + expect(mockChainRunCommands).toHaveBeenCalledWith([HOME_GRIPPER], false) }) it('should call skipFailedCommand and show success toast on success', async () => { diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts index a274249cac1..53da7ca2f74 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts @@ -270,11 +270,7 @@ export function useRecoveryCommands({ }, [chainRunRecoveryCommands]) const homeGripper = useCallback((): Promise => { - const gripperAxis = - failedCommandByRunRecord?.error?.errorCode === '2003' - ? HOME_GRIPPER - : HOME_GRIPPER_Z_AXIS - return chainRunRecoveryCommands([gripperAxis]) + return chainRunRecoveryCommands([HOME_GRIPPER]) }, [chainRunRecoveryCommands]) const moveLabwareWithoutPause = useCallback((): Promise => { @@ -314,12 +310,6 @@ export const RELEASE_GRIPPER_JAW: CreateCommand = { intent: 'fixit', } -export const HOME_GRIPPER_Z_AXIS: CreateCommand = { - commandType: 'home', - params: { axes: ['extensionZ'] }, - intent: 'fixit', -} - export const HOME_GRIPPER: CreateCommand = { commandType: 'home', params: { axes: ['extensionZ', 'extensionJaw'] }, From 47a2c9d8cdbf45f32a01e0057eef48d34ea6c55d Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Thu, 24 Oct 2024 13:23:28 -0400 Subject: [PATCH 05/10] home extension z and update positions --- .../__tests__/useRecoveryCommands.test.ts | 11 +++++---- .../hooks/useHomeGripper.ts | 4 ++-- .../hooks/useRecoveryCommands.ts | 23 +++++++++++++------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts index 5fe18a914bd..76066a9b501 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts @@ -14,7 +14,7 @@ import { RELEASE_GRIPPER_JAW, buildPickUpTips, buildIgnorePolicyRules, - HOME_GRIPPER, + UPDATE_ESTIMATORS_EXCEPT_PLUNGERS, } from '../useRecoveryCommands' import { RECOVERY_MAP } from '../../constants' @@ -264,14 +264,17 @@ describe('useRecoveryCommands', () => { ) }) - it('should call useHomeGripper and resolve the promise', async () => { + it('should call useUpdatePositionEstimators and resolve the promise', async () => { const { result } = renderHook(() => useRecoveryCommands(props)) await act(async () => { - await result.current.homeGripper() + await result.current.updatePositionEstimatorsAndHomeGripper() }) - expect(mockChainRunCommands).toHaveBeenCalledWith([HOME_GRIPPER], false) + expect(mockChainRunCommands).toHaveBeenCalledWith( + [UPDATE_ESTIMATORS_EXCEPT_PLUNGERS], + false + ) }) it('should call skipFailedCommand and show success toast on success', async () => { diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts index 36ce031a7fd..1859e98ea85 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts @@ -20,7 +20,7 @@ export function useHomeGripper({ useLayoutEffect(() => { const { handleMotionRouting, goBackPrevStep } = routeUpdateActions - const { homeGripper } = recoveryCommands + const { updatePositionEstimatorsAndHomeGripper } = recoveryCommands if (!hasHomedOnce) { if (isManualGripperStep) { @@ -28,7 +28,7 @@ export function useHomeGripper({ void goBackPrevStep() } else { void handleMotionRouting(true) - .then(() => homeGripper()) + .then(() => updatePositionEstimatorsAndHomeGripper()) .then(() => { setHasHomedOnce(true) }) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts index 53da7ca2f74..e39593fa17e 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts @@ -63,7 +63,7 @@ export interface UseRecoveryCommandsResult { /* A non-terminal recovery command */ releaseGripperJaws: () => Promise /* A non-terminal recovery command */ - homeGripper: () => Promise + updatePositionEstimatorsAndHomeGripper: () => Promise /* A non-terminal recovery command */ moveLabwareWithoutPause: () => Promise } @@ -269,8 +269,13 @@ export function useRecoveryCommands({ return chainRunRecoveryCommands([RELEASE_GRIPPER_JAW]) }, [chainRunRecoveryCommands]) - const homeGripper = useCallback((): Promise => { - return chainRunRecoveryCommands([HOME_GRIPPER]) + const updatePositionEstimatorsAndHomeGripper = useCallback((): Promise< + CommandData[] + > => { + return chainRunRecoveryCommands([ + UPDATE_ESTIMATORS_EXCEPT_PLUNGERS, + HOME_GRIPPER_Z, + ]) }, [chainRunRecoveryCommands]) const moveLabwareWithoutPause = useCallback((): Promise => { @@ -291,7 +296,7 @@ export function useRecoveryCommands({ homePipetteZAxes, pickUpTips, releaseGripperJaws, - homeGripper, + updatePositionEstimatorsAndHomeGripper, moveLabwareWithoutPause, skipFailedCommand, ignoreErrorKindThisRun, @@ -310,10 +315,14 @@ export const RELEASE_GRIPPER_JAW: CreateCommand = { intent: 'fixit', } -export const HOME_GRIPPER: CreateCommand = { +export const UPDATE_ESTIMATORS_EXCEPT_PLUNGERS: CreateCommand = { + commandType: 'unsafe/updatePositionEstimators', + params: { axes: ['x', 'y', 'extensionZ'] }, +} + +export const HOME_GRIPPER_Z: CreateCommand = { commandType: 'home', - params: { axes: ['extensionZ', 'extensionJaw'] }, - intent: 'fixit', + params: { axes: ['extensionZ'] }, } const buildMoveLabwareWithoutPause = ( From efc401fbc32f912f4ae9cf8080ebbf0e3aa20156 Mon Sep 17 00:00:00 2001 From: TamarZanzouri Date: Thu, 24 Oct 2024 13:25:19 -0400 Subject: [PATCH 06/10] Update app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts Co-authored-by: Jamey Huffnagle --- app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts index 1859e98ea85..b165e59ebd4 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useHomeGripper.ts @@ -3,7 +3,7 @@ import { RECOVERY_MAP } from '/app/organisms/ErrorRecoveryFlows/constants' import type { ErrorRecoveryWizardProps } from '/app/organisms/ErrorRecoveryFlows/ErrorRecoveryWizard' -// Home the gripper z-axis implicitly. Because the z-home is not tied to a CTA, it must be handled here. +// Home the gripper implicitly. Because the home is not tied to a CTA, it must be handled here. export function useHomeGripper({ recoveryCommands, routeUpdateActions, From 76f3692398023385bb56146b885f1a1377fb0422 Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Thu, 24 Oct 2024 13:32:15 -0400 Subject: [PATCH 07/10] fixed failing test --- .../hooks/__tests__/useRecoveryCommands.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts index 76066a9b501..a553bdcb4ee 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryCommands.test.ts @@ -15,6 +15,7 @@ import { buildPickUpTips, buildIgnorePolicyRules, UPDATE_ESTIMATORS_EXCEPT_PLUNGERS, + HOME_GRIPPER_Z, } from '../useRecoveryCommands' import { RECOVERY_MAP } from '../../constants' @@ -272,7 +273,7 @@ describe('useRecoveryCommands', () => { }) expect(mockChainRunCommands).toHaveBeenCalledWith( - [UPDATE_ESTIMATORS_EXCEPT_PLUNGERS], + [UPDATE_ESTIMATORS_EXCEPT_PLUNGERS, HOME_GRIPPER_Z], false ) }) From 466d2c84736fb1be5bb7d98c6346c915cffde36d Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Thu, 24 Oct 2024 13:37:35 -0400 Subject: [PATCH 08/10] changed mock name --- .../__tests__/useHomeGripperZAxis.test.ts | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts index c640f448d6c..32f5d939eb8 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useHomeGripperZAxis.test.ts @@ -6,7 +6,9 @@ import { RECOVERY_MAP } from '/app/organisms/ErrorRecoveryFlows/constants' describe('useHomeGripper', () => { const mockRecoveryCommands = { - homeGripper: vi.fn().mockResolvedValue(undefined), + updatePositionEstimatorsAndHomeGripper: vi + .fn() + .mockResolvedValue(undefined), } const mockRouteUpdateActions = { @@ -43,7 +45,9 @@ describe('useHomeGripper', () => { expect(mockRouteUpdateActions.handleMotionRouting).toHaveBeenCalledWith( true ) - expect(mockRecoveryCommands.homeGripper).toHaveBeenCalled() + expect( + mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper + ).toHaveBeenCalled() expect(mockRouteUpdateActions.handleMotionRouting).toHaveBeenCalledWith( false ) @@ -60,7 +64,9 @@ describe('useHomeGripper', () => { }) expect(mockRouteUpdateActions.goBackPrevStep).toHaveBeenCalled() - expect(mockRecoveryCommands.homeGripper).not.toHaveBeenCalled() + expect( + mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper + ).not.toHaveBeenCalled() }) it('should not home again if already homed once', async () => { @@ -77,11 +83,15 @@ describe('useHomeGripper', () => { await new Promise(resolve => setTimeout(resolve, 0)) }) - expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1) + expect( + mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper + ).toHaveBeenCalledTimes(1) rerender() - expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1) + expect( + mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper + ).toHaveBeenCalledTimes(1) }) it('should reset hasHomedOnce when step changes to non-manual gripper step and back', async () => { @@ -103,7 +113,9 @@ describe('useHomeGripper', () => { await new Promise(resolve => setTimeout(resolve, 0)) }) - expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1) + expect( + mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper + ).toHaveBeenCalledTimes(1) rerender({ recoveryMap: { step: 'SOME_OTHER_STEP' } as any }) @@ -117,6 +129,8 @@ describe('useHomeGripper', () => { await new Promise(resolve => setTimeout(resolve, 0)) }) - expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(2) + expect( + mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper + ).toHaveBeenCalledTimes(2) }) }) From cbb20c97c241c42d1eaed2a4f50a95ae6c713584 Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Thu, 24 Oct 2024 13:39:15 -0400 Subject: [PATCH 09/10] added a comment --- app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts b/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts index 63d3f264ae1..cd761dc22b4 100644 --- a/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts +++ b/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts @@ -313,6 +313,7 @@ const HOME_EXCEPT_PLUNGERS: CreateCommand = { params: { axes: ['leftZ', 'rightZ', 'x', 'y'] }, } +// in case the gripper does not know the position after a stall/collision we must update the position. const UPDATE_ESTIMATORS_EXCEPT_PLUNGERS: CreateCommand = { commandType: 'unsafe/updatePositionEstimators' as const, params: { axes: ['leftZ', 'rightZ', 'x', 'y'] }, From 3e76aa11eadf1a5f5bcb08c6beaf4131e61bfc65 Mon Sep 17 00:00:00 2001 From: tamarzanzouri Date: Thu, 24 Oct 2024 13:39:53 -0400 Subject: [PATCH 10/10] updated comment --- app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts | 1 - .../organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts b/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts index cd761dc22b4..63d3f264ae1 100644 --- a/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts +++ b/app/src/organisms/DropTipWizardFlows/hooks/useDropTipCommands.ts @@ -313,7 +313,6 @@ const HOME_EXCEPT_PLUNGERS: CreateCommand = { params: { axes: ['leftZ', 'rightZ', 'x', 'y'] }, } -// in case the gripper does not know the position after a stall/collision we must update the position. const UPDATE_ESTIMATORS_EXCEPT_PLUNGERS: CreateCommand = { commandType: 'unsafe/updatePositionEstimators' as const, params: { axes: ['leftZ', 'rightZ', 'x', 'y'] }, diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts index e39593fa17e..69101d92fe9 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryCommands.ts @@ -315,6 +315,7 @@ export const RELEASE_GRIPPER_JAW: CreateCommand = { intent: 'fixit', } +// in case the gripper does not know the position after a stall/collision we must update the position. export const UPDATE_ESTIMATORS_EXCEPT_PLUNGERS: CreateCommand = { commandType: 'unsafe/updatePositionEstimators', params: { axes: ['x', 'y', 'extensionZ'] },