Skip to content

Commit 5f383ef

Browse files
authored
feat(step-generation): py command for dropping tip in waste chute (#17831)
1 parent 7e44ff5 commit 5f383ef

File tree

8 files changed

+36
-38
lines changed

8 files changed

+36
-38
lines changed

protocol-designer/src/timelineMiddleware/generateRobotStateTimeline.ts

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import {
2-
dropTipInPlace,
3-
moveToAddressableArea,
4-
getWasteChuteAddressableAreaNamePip,
52
dropTipInTrash,
3+
dropTipInWasteChute,
64
curryCommandCreator,
75
dropTip,
86
reduceCommandCreators,
97
commandCreatorsTimeline,
108
getPipetteIdFromCCArgs,
11-
ZERO_OFFSET,
129
} from '@opentrons/step-generation'
1310
import { commandCreatorFromStepArgs } from '../file-data/helpers'
1411
import type { StepArgsAndErrorsById } from '../steplist/types'
@@ -75,11 +72,6 @@ export const generateRobotStateTimeline = (
7572
const isWasteChute = dropTipEntity?.name === 'wasteChute'
7673
const isTrashBin = dropTipEntity?.name === 'trashBin'
7774

78-
const pipetteSpec = invariantContext.pipetteEntities[pipetteId]?.spec
79-
const addressableAreaNameWasteChute = getWasteChuteAddressableAreaNamePip(
80-
pipetteSpec.channels
81-
)
82-
8375
let dropTipCommands = [
8476
curryCommandCreator(dropTip, {
8577
pipette: pipetteId,
@@ -88,13 +80,9 @@ export const generateRobotStateTimeline = (
8880
]
8981
if (isWasteChute) {
9082
dropTipCommands = [
91-
curryCommandCreator(moveToAddressableArea, {
92-
pipetteId,
93-
addressableAreaName: addressableAreaNameWasteChute,
94-
offset: ZERO_OFFSET,
95-
}),
96-
curryCommandCreator(dropTipInPlace, {
83+
curryCommandCreator(dropTipInWasteChute, {
9784
pipetteId,
85+
wasteChuteId: dropTipEntity.id,
9886
}),
9987
]
10088
}
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
11
import { describe, it, expect, vi } from 'vitest'
22
import { WASTE_CHUTE_CUTOUT } from '@opentrons/shared-data'
3-
import { getSuccessResult, makeContext } from '../fixtures'
3+
import { DEFAULT_PIPETTE, getSuccessResult, makeContext } from '../fixtures'
44
import { dropTipInWasteChute } from '../commandCreators'
55

6-
import type { InvariantContext, PipetteEntities, RobotState } from '../types'
6+
import type { InvariantContext, RobotState } from '../types'
77

88
vi.mock('../getNextRobotStateAndWarnings/dispenseUpdateLiquidState')
99

1010
const mockWasteChuteId = 'mockWasteChuteId'
11-
const mockId = 'mockId'
12-
13-
const mockPipEntities: PipetteEntities = {
14-
[mockId]: {
15-
name: 'p50_single_flex',
16-
id: mockId,
17-
spec: { channels: 1 },
18-
},
19-
} as any
2011

2112
const invariantContext: InvariantContext = {
2213
...makeContext(),
23-
pipetteEntities: mockPipEntities,
2414
additionalEquipmentEntities: {
2515
[mockWasteChuteId]: {
2616
name: 'wasteChute' as const,
2717
location: WASTE_CHUTE_CUTOUT,
2818
id: mockWasteChuteId,
19+
pythonName: 'mock_waste_chute_1',
2920
},
3021
},
3122
}
3223
const prevRobotState: RobotState = {
33-
tipState: { pipettes: { [mockId]: true } } as any,
24+
tipState: { pipettes: { [DEFAULT_PIPETTE]: true } } as any,
3425
} as any
3526

3627
describe('dropTipInWasteChute', () => {
37-
it('returns correct commands for drop tip', () => {
28+
it('returns correct commands for drop tip in waste chute', () => {
3829
const args = {
39-
pipetteId: mockId,
30+
pipetteId: DEFAULT_PIPETTE,
31+
wasteChuteId: mockWasteChuteId,
4032
}
4133
const result = dropTipInWasteChute(args, invariantContext, prevRobotState)
4234
expect(getSuccessResult(result).commands).toEqual([
4335
{
4436
commandType: 'moveToAddressableArea',
4537
key: expect.any(String),
4638
params: {
47-
pipetteId: mockId,
39+
pipetteId: DEFAULT_PIPETTE,
4840
addressableAreaName: '1ChannelWasteChute',
4941
offset: { x: 0, y: 0, z: 0 },
5042
},
@@ -53,9 +45,12 @@ describe('dropTipInWasteChute', () => {
5345
commandType: 'dropTipInPlace',
5446
key: expect.any(String),
5547
params: {
56-
pipetteId: mockId,
48+
pipetteId: DEFAULT_PIPETTE,
5749
},
5850
},
5951
])
52+
expect(getSuccessResult(result).python).toBe(
53+
'mockPythonName.drop_tip(mock_waste_chute_1)'
54+
)
6055
})
6156
})

step-generation/src/commandCreators/compound/consolidate.ts

+1
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ export const consolidate: CommandCreator<ConsolidateArgs> = (
460460
dropTipCommand = [
461461
curryCommandCreator(dropTipInWasteChute, {
462462
pipetteId: args.pipette,
463+
wasteChuteId: dropTipEntity.id,
463464
}),
464465
]
465466
}

step-generation/src/commandCreators/compound/distribute.ts

+1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ export const distribute: CommandCreator<DistributeArgs> = (
386386
dropTipCommand = [
387387
curryCommandCreator(dropTipInWasteChute, {
388388
pipetteId: args.pipette,
389+
wasteChuteId: dropTipEntity.id,
389390
}),
390391
]
391392
}

step-generation/src/commandCreators/compound/dropTipInWasteChute.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
curryCommandCreator,
2+
curryWithoutPython,
33
getWasteChuteAddressableAreaNamePip,
44
reduceCommandCreators,
55
} from '../../utils'
@@ -9,6 +9,7 @@ import type { CommandCreator, CurriedCommandCreator } from '../../types'
99

1010
interface DropTipInWasteChuteArgs {
1111
pipetteId: string
12+
wasteChuteId: string
1213
}
1314

1415
export const dropTipInWasteChute: CommandCreator<DropTipInWasteChuteArgs> = (
@@ -17,9 +18,9 @@ export const dropTipInWasteChute: CommandCreator<DropTipInWasteChuteArgs> = (
1718
prevRobotState
1819
) => {
1920
const offset = ZERO_OFFSET
20-
const { pipetteId } = args
21-
const pipetteChannels =
22-
invariantContext.pipetteEntities[pipetteId].spec.channels
21+
const { pipetteId, wasteChuteId } = args
22+
const { pipetteEntities, additionalEquipmentEntities } = invariantContext
23+
const pipetteChannels = pipetteEntities[pipetteId].spec.channels
2324
const addressableAreaName = getWasteChuteAddressableAreaNamePip(
2425
pipetteChannels
2526
)
@@ -30,15 +31,24 @@ export const dropTipInWasteChute: CommandCreator<DropTipInWasteChuteArgs> = (
3031
if (!prevRobotState.tipState.pipettes[pipetteId]) {
3132
commandCreators = []
3233
} else {
34+
const pipettePythonName = pipetteEntities[pipetteId].pythonName
35+
const wasteChutePythonName =
36+
additionalEquipmentEntities[wasteChuteId].pythonName
37+
const pythonCommandCreator: CurriedCommandCreator = () => ({
38+
commands: [],
39+
python: `${pipettePythonName}.drop_tip(${wasteChutePythonName})`,
40+
})
41+
3342
commandCreators = [
34-
curryCommandCreator(moveToAddressableArea, {
43+
curryWithoutPython(moveToAddressableArea, {
3544
pipetteId,
3645
addressableAreaName,
3746
offset,
3847
}),
39-
curryCommandCreator(dropTipInPlace, {
48+
curryWithoutPython(dropTipInPlace, {
4049
pipetteId,
4150
}),
51+
pythonCommandCreator,
4252
]
4353
}
4454
return reduceCommandCreators(

step-generation/src/commandCreators/compound/replaceTip.ts

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export const replaceTip: CommandCreator<ReplaceTipArgs> = (
211211
commandCreators = [
212212
curryCommandCreator(dropTipInWasteChute, {
213213
pipetteId: args.pipette,
214+
wasteChuteId: dropTipEntity.id,
214215
}),
215216
...configureNozzleLayoutCommand,
216217
curryCommandCreator(pickUpTip, {

step-generation/src/commandCreators/compound/transfer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ export const transfer: CommandCreator<TransferArgs> = (
545545
dropTipCommand = [
546546
curryCommandCreator(dropTipInWasteChute, {
547547
pipetteId: args.pipette,
548+
wasteChuteId: dropTipEntity.id,
548549
}),
549550
]
550551
}

step-generation/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
dropTip,
1818
dropTipInPlace,
1919
dropTipInTrash,
20+
dropTipInWasteChute,
2021
engageMagnet,
2122
heaterShaker,
2223
mix,

0 commit comments

Comments
 (0)