Skip to content

Commit ea09265

Browse files
authored
docs(api): how to use LPC enhancements and offsets in Jupyter (#11063)
1 parent bec8e23 commit ea09265

File tree

1 file changed

+67
-11
lines changed

1 file changed

+67
-11
lines changed

api/docs/v2/robot_position.rst

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ Most of the time when executing a protocol, the Python Protocol API's methods ta
1313
Position Relative to Labware
1414
****************************
1515

16-
Every well on every piece of labware you load has three addressable positions — top, bottom, and center — that are determined by the labware definition. You can use these positions as-is or calculate other positions relative to them.
16+
When you instruct the robot to move to a position on a piece of labware, the exact point in space it moves to is calculated based on the labware definition, the type of action the robot will perform there, and labware offsets for the specific deck slot on your robot. This section describes how each of these components of a position are calculated and methods for modifying them.
1717

18-
Top
19-
===
18+
Top, Bottom, and Center
19+
=======================
2020

21-
The :py:meth:`.Well.top` method returns a position level with the top of the well, centered in both horizontal directions.
21+
Every well on every piece of labware you load has three addressable positions — top, bottom, and center — that are determined by the labware definition and whether the labware is on a module or directly on the deck. You can use these positions as-is or calculate other positions relative to them.
22+
23+
:py:meth:`.Well.top` returns a position level with the top of the well, centered in both horizontal directions.
2224

2325
.. code-block:: python
2426
@@ -33,10 +35,7 @@ This is a good position to use for :ref:`new-blow-out` or any other operation wh
3335
3436
.. versionadded:: 2.0
3537

36-
Bottom
37-
======
38-
39-
The :py:meth:`.Well.bottom` method returns a position level with the bottom of the well, centered in both horizontal directions.
38+
:py:meth:`.Well.bottom` returns a position level with the bottom of the well, centered in both horizontal directions.
4039

4140
.. code-block:: python
4241
@@ -57,10 +56,8 @@ This is a good position to start for aspiration or any other operation where you
5756

5857
.. versionadded:: 2.0
5958

60-
Center
61-
======
6259

63-
The :py:meth:`.Well.center` method returns a position centered in the well both vertically and horizontally. This can be a good place to start for precise control of positions within the well for unusual or custom labware.
60+
:py:meth:`.Well.center` returns a position centered in the well both vertically and horizontally. This can be a good place to start for precise control of positions within the well for unusual or custom labware.
6461

6562
.. code-block:: python
6663
@@ -113,6 +110,65 @@ Changing these attributes will affect all subsequent aspirate and dispense actio
113110
.. versionadded:: 2.0
114111

115112

113+
.. _using_lpc:
114+
115+
Using Labware Position Check
116+
============================
117+
118+
All positions relative to labware are automatically adjusted based on the labware's offset, an x, y, z vector. The best way to calculate and apply these offsets is by using Labware Position Check when you run your protocol in the Opentrons App. As of version 6.0 of the app, you can apply previously calculated offsets — even across different protocols — as long as they are for the same type of labware in the same deck slot on the same robot.
119+
120+
You shouldn't adjust labware offsets in your Python code if you plan to run your protocol in the app. However, if you are running your protocol in Jupyter notebook or with ``opentrons_execute``, Labware Position Check is not directly available. For these applications, you can calculate and apply labware offsets by:
121+
122+
1. Creating a "dummy" protocol that loads your labware and has each used pipette pick up a tip from a tip rack
123+
2. Importing the dummy protocol to the Opentrons App
124+
3. Running Labware Position Check
125+
4. Adding the offsets to your protocol
126+
127+
To prepare code written for Jupyter notebook so it can be run in the app, you need to include a metadata block and a ``run()`` function. And to enable Labware Position Check, you need to add a :py:meth:`.pick_up_tip` action for each pipette the protocol uses. For example, a dummy protocol using a P300 Single-Channel pipette, a reservoir, and a well plate would look like this:
128+
129+
.. code-block:: python
130+
131+
metadata = {'apiLevel': '2.12'}
132+
133+
def run(protocol):
134+
tiprack = protocol.load_labware('opentrons_96_tiprack_300ul', 1)
135+
reservoir = protocol.load_labware('nest_12_reservoir_15ml', 2)
136+
plate = protocol.load_labware('nest_96_wellplate_200ul_flat', 3)
137+
p300 = protocol.load_instrument('p300_single_gen2', 'left', tip_racks=[tiprack])
138+
p300.pick_up_tip()
139+
p300.return_tip()
140+
141+
After importing this protocol to the Opentrons App, run Labware Position Check to get the x, y, and z offsets for the tip rack and labware. When complete, you can click **Get Labware Offset Data** to view automatically generated code that uses :py:meth:`.set_offset` to apply the offsets to each piece of labware:
142+
143+
.. code-block:: python
144+
145+
labware_1 = protocol.load_labware("opentrons_96_tiprack_300ul", location="1")
146+
labware_1.set_offset(x=0.00, y=0.00, z=0.00)
147+
148+
labware_2 = protocol.load_labware("nest_12_reservoir_15ml", location="2")
149+
labware_2.set_offset(x=0.10, y=0.20, z=0.30)
150+
151+
labware_3 = protocol.load_labware("nest_96_wellplate_200ul_flat", location="3")
152+
labware_3.set_offset(x=0.10, y=0.20, z=0.30)
153+
154+
You'll notice that this code uses generic names for the loaded labware. If you want to match the labware names already in your protocol, add your own ``.set_offset()`` calls using the arguments provided by Labware Position Check:
155+
156+
.. code-block:: python
157+
158+
reservoir = protocol.load_labware('nest_12_reservoir_15ml', 2)
159+
reservoir.set_offset(x=0.10, y=0.20, z=0.30)
160+
161+
.. versionadded:: 2.12
162+
163+
Once you've executed this code in Jupyter notebook, all subsequent positional calculations for this reservoir in slot 2 will be adjusted 0.1 mm to the right, 0.2 mm to the back, and 0.3 mm up.
164+
165+
Remember, you should only add ``.set_offset()`` commands to protocols run outside of the Opentrons App. And you should follow the behavior of Labware Position Check: do not reuse offset measurements unless they apply to the *same labware* in the *same deck slot* on the *same robot*.
166+
167+
.. warning::
168+
169+
Improperly reusing offset data may cause your robot to move to unforeseen positions, including crashing on labware, which can lead to incorrect protocol execution or damage to your equipment. The same is true of running protocols with ``.set_offset()`` commands in the Opentrons App. When in doubt: run Labware Position Check again and update your code!
170+
171+
116172
.. _protocol-api-deck-coords:
117173

118174
*****************************

0 commit comments

Comments
 (0)