Skip to content

Commit 6d01de1

Browse files
authored
feat(step-generation): touch_tip python command generation and add speed to commands (#17795)
closes AUTH-1580
1 parent 10e8a5e commit 6d01de1

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

step-generation/src/__tests__/touchTip.test.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ describe('touchTip', () => {
2828
robotStateWithTip = getRobotStateWithTipStandard(invariantContext)
2929
})
3030

31-
it('touchTip with tip, specifying offsetFromBottomMm', () => {
31+
it('touchTip with tip, specifying offsetFromBottomMm and speed', () => {
3232
const result = touchTip(
3333
{
3434
pipetteId: DEFAULT_PIPETTE,
3535
labwareId: SOURCE_LABWARE,
3636
wellName: 'A1',
3737
wellLocation,
38+
speed: 10,
3839
},
3940
invariantContext,
4041
robotStateWithTip
@@ -55,9 +56,38 @@ describe('touchTip', () => {
5556
z: 10,
5657
},
5758
},
59+
speed: 10,
5860
},
5961
},
6062
])
63+
expect(res.python).toBe(
64+
`
65+
mockPythonName.touch_tip(
66+
mockPythonName["A1"],
67+
v_offset=10,
68+
speed=10,
69+
)`.trimStart()
70+
)
71+
})
72+
73+
it('touchTip for python with tip, with no offset or speed set', () => {
74+
const result = touchTip(
75+
{
76+
pipetteId: DEFAULT_PIPETTE,
77+
labwareId: SOURCE_LABWARE,
78+
wellName: 'A1',
79+
},
80+
invariantContext,
81+
robotStateWithTip
82+
)
83+
const res = getSuccessResult(result)
84+
85+
expect(res.python).toBe(
86+
`
87+
mockPythonName.touch_tip(
88+
mockPythonName["A1"],
89+
)`.trimStart()
90+
)
6191
})
6292

6393
it('touchTip with invalid pipette ID should throw error', () => {

step-generation/src/commandCreators/atomic/touchTip.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { uuid } from '../../utils'
1+
import { formatPyStr, indentPyLines, uuid } from '../../utils'
22
import { noTipOnPipette, pipetteDoesNotExist } from '../../errorCreators'
33
import type { CreateCommand, TouchTipParams } from '@opentrons/shared-data'
44
import type { CommandCreator, CommandCreatorError } from '../../types'
@@ -10,7 +10,7 @@ export const touchTip: CommandCreator<TouchTipParams> = (
1010
) => {
1111
/** touchTip with given args. Requires tip. */
1212
const actionName = 'touchTip'
13-
const { pipetteId, labwareId, wellName, wellLocation } = args
13+
const { pipetteId, labwareId, wellName, wellLocation, speed } = args
1414
const pipetteData = prevRobotState.pipettes[pipetteId]
1515
const errors: CommandCreatorError[] = []
1616

@@ -39,6 +39,24 @@ export const touchTip: CommandCreator<TouchTipParams> = (
3939
}
4040
}
4141

42+
const pipettePythonName =
43+
invariantContext.pipetteEntities[pipetteId].pythonName
44+
const labwarePythonName =
45+
invariantContext.labwareEntities[labwareId].pythonName
46+
47+
const pythonArgs = [
48+
`${labwarePythonName}[${formatPyStr(wellName)}],`,
49+
...(wellLocation?.offset?.z != null
50+
? [`v_offset=${wellLocation?.offset?.z},`]
51+
: []),
52+
...(speed != null ? [`speed=${speed},`] : []),
53+
]
54+
55+
// TODO: add mmFromEdge to python and commandCreator
56+
const python = `${pipettePythonName}.touch_tip(\n${indentPyLines(
57+
pythonArgs.join('\n')
58+
)}\n)`
59+
4260
const commands: CreateCommand[] = [
4361
{
4462
commandType: 'touchTip',
@@ -48,10 +66,12 @@ export const touchTip: CommandCreator<TouchTipParams> = (
4866
labwareId,
4967
wellName,
5068
wellLocation,
69+
speed,
5170
},
5271
},
5372
]
5473
return {
5574
commands,
75+
python,
5676
}
5777
}

0 commit comments

Comments
 (0)