Skip to content

Commit

Permalink
refactor(api): redefine well geometry structure (#16392)
Browse files Browse the repository at this point in the history
## Overview
After discovering some new shapes and generally interacting with the new
well geometry data structures, I think it would be better to reshape the
geometry data a little bit. Rather than having each section of a well be
represented by its top cross-section and top height, let's just
represent a section in its entirety, with bottom and top cross-sections
and bottom and top heights being present in every shape that is not a
`SphericalSegment`.

## Changelog

- add `RoundedRectangle` class
- add `TruncatedCircle` class
- add `CircularFrustum` and `RectangularFrustum` classes
- adjust `frustum_helpers` and tests to use the new data structure

## TODO
- We should [write some more
tests](https://opentrons.atlassian.net/browse/EXEC-743?atlOrigin=eyJpIjoiYzg5OThhMjQ2NTViNDRmNGI2OTkwMWEwYTExMmFjNjIiLCJwIjoiaiJ9)
to make sure invalid wells don't get passed in without an error being
raised.
- Implement the math for [truncated
circle](https://opentrons.atlassian.net/browse/EXEC-712) calculations
- Implement the math for [rounded
rectangle](https://opentrons.atlassian.net/browse/EXEC-744) calculations

---------

Co-authored-by: Ryan howard <[email protected]>
  • Loading branch information
caila-marashaj and ryanthecoder authored Oct 9, 2024
1 parent 50d3208 commit 7f6506f
Show file tree
Hide file tree
Showing 12 changed files with 790 additions and 463 deletions.
376 changes: 159 additions & 217 deletions api/src/opentrons/protocol_engine/state/frustum_helpers.py

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions api/tests/opentrons/protocol_engine/state/test_geometry_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
)
from opentrons.protocol_engine.state.geometry import GeometryView, _GripperMoveType
from opentrons.protocol_engine.state.frustum_helpers import (
height_from_volume_circular,
height_from_volume_rectangular,
volume_from_height_circular,
volume_from_height_rectangular,
_height_from_volume_circular,
_height_from_volume_rectangular,
_volume_from_height_circular,
_volume_from_height_rectangular,
)
from ..pipette_fixtures import get_default_nozzle_map
from ..mock_circular_frusta import TEST_EXAMPLES as CIRCULAR_TEST_EXAMPLES
Expand Down Expand Up @@ -2776,7 +2776,7 @@ def _find_volume_from_height_(index: int) -> None:
top_width = frustum["width"][index]
target_height = frustum["height"][index]

found_volume = volume_from_height_rectangular(
found_volume = _volume_from_height_rectangular(
target_height=target_height,
total_frustum_height=total_frustum_height,
top_length=top_length,
Expand All @@ -2785,7 +2785,7 @@ def _find_volume_from_height_(index: int) -> None:
bottom_width=bottom_width,
)

found_height = height_from_volume_rectangular(
found_height = _height_from_volume_rectangular(
volume=found_volume,
total_frustum_height=total_frustum_height,
top_length=top_length,
Expand Down Expand Up @@ -2815,14 +2815,14 @@ def _find_volume_from_height_(index: int) -> None:
top_radius = frustum["radius"][index]
target_height = frustum["height"][index]

found_volume = volume_from_height_circular(
found_volume = _volume_from_height_circular(
target_height=target_height,
total_frustum_height=total_frustum_height,
top_radius=top_radius,
bottom_radius=bottom_radius,
)

found_height = height_from_volume_circular(
found_height = _height_from_volume_circular(
volume=found_volume,
total_frustum_height=total_frustum_height,
top_radius=top_radius,
Expand Down
39 changes: 23 additions & 16 deletions api/tests/opentrons/protocol_runner/test_json_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Group,
Metadata1,
WellDefinition,
RectangularBoundedSection,
CuboidalFrustum,
InnerWellGeometry,
SphericalSegment,
)
Expand Down Expand Up @@ -685,32 +685,39 @@ def _load_labware_definition_data() -> LabwareDefinition:
y=75.43,
z=75,
totalLiquidVolume=1100000,
shape="rectangular",
shape="circular",
)
},
dimensions=Dimensions(yDimension=85.5, zDimension=100, xDimension=127.75),
cornerOffsetFromSlot=CornerOffsetFromSlot(x=0, y=0, z=0),
innerLabwareGeometry={
"welldefinition1111": InnerWellGeometry(
frusta=[
RectangularBoundedSection(
shape="rectangular",
xDimension=7.6,
yDimension=8.5,
sections=[
CuboidalFrustum(
shape="cuboidal",
topXDimension=7.6,
topYDimension=8.5,
bottomXDimension=5.6,
bottomYDimension=6.5,
topHeight=45,
bottomHeight=20,
),
RectangularBoundedSection(
shape="rectangular",
xDimension=5.6,
yDimension=6.5,
CuboidalFrustum(
shape="cuboidal",
topXDimension=5.6,
topYDimension=6.5,
bottomXDimension=4.5,
bottomYDimension=4.0,
topHeight=20,
bottomHeight=10,
),
SphericalSegment(
shape="spherical",
radiusOfCurvature=6,
topHeight=10,
bottomHeight=0.0,
),
],
bottomShape=SphericalSegment(
shape="spherical",
radiusOfCurvature=6,
depth=10,
),
)
},
brand=BrandData(brand="foo"),
Expand Down
Loading

0 comments on commit 7f6506f

Please sign in to comment.