-
Notifications
You must be signed in to change notification settings - Fork 186
chore(step-generation): state update for FlexStacker in getNextRobotStateAndWarningsSingleCommand #20120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TamarZanzouri
wants to merge
40
commits into
edge
Choose a base branch
from
EXEC-2018-robot-state-and-timeline-for-stacker
base: edge
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
chore(step-generation): state update for FlexStacker in getNextRobotStateAndWarningsSingleCommand #20120
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
599842c
WIP skeleton
TamarZanzouri beeadfb
state update WIP
TamarZanzouri 024c8aa
renaming module state to match step gen
TamarZanzouri 244a3cc
added tests and started with open latch command
TamarZanzouri acda6cf
renaming methods and break for unsafe commands
TamarZanzouri 5b15343
test fixes
TamarZanzouri 7c77fc1
added tests for fill
TamarZanzouri 5c6829c
make sure the count is less than max number
TamarZanzouri 7d79fa5
check js
TamarZanzouri 8ed53be
getModuleMaxFillHeight
TamarZanzouri 4fdd56e
added tests and renaming
TamarZanzouri 0f59fbb
wire up max count for stack
TamarZanzouri cc0e526
getHeightOfLabwareStackFromDefinitions
TamarZanzouri d910e9a
logic for getHeightOfLabwareStackFromDefinitions
TamarZanzouri 90bbdec
tests for getHeightOfLabwareStackFromDefinitions
TamarZanzouri 372c4b9
linting
TamarZanzouri 1c35096
stack of stored labware defs
TamarZanzouri 887318d
WIP forFlexStackerRetrieve
TamarZanzouri 1e27974
retrieve WIP
TamarZanzouri 3127502
is slot taken
TamarZanzouri 2d17cfc
labware tests in slot
TamarZanzouri fe64f50
getIsSlotValid and WIP getIsSlotOccupied
TamarZanzouri 6bb1dbc
renaming and fixed logic for retrieve
TamarZanzouri a0d38bc
raise tests
TamarZanzouri 2bf5d31
logic test for retrieve
TamarZanzouri c30b7c0
fixed failing test
TamarZanzouri 97b9013
moved slot dec to symbolic helpers
TamarZanzouri 611e885
WIP getIsSlotOccupied use LabwareLocation
TamarZanzouri 2cb95d3
import fix and labwareLocation fix
TamarZanzouri 8c2c22d
labwareIdsInStacker
TamarZanzouri d64310f
renaming and orginizing
TamarZanzouri d5e204e
mocking fix
TamarZanzouri 96fc952
pythonFileUtils set_store_labware
TamarZanzouri 2bc04e6
WIP add flex stacker to tests
TamarZanzouri 1ed2298
added tests
TamarZanzouri 2262691
lint
TamarZanzouri 501e409
logic fix for set stored labware
TamarZanzouri 69daacc
cleanup
TamarZanzouri 63b456c
cleanup
TamarZanzouri e134190
lint fixes
TamarZanzouri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
api/src/opentrons/protocol_engine/commands/flex_stacker/fill.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
api/src/opentrons/protocol_engine/commands/flex_stacker/store.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import type { | |
| CutoutId, | ||
| FLEX_STACKER_MODULE_TYPE, | ||
| FlexModuleCutoutFixtureId, | ||
| FlexStackerSetStoredLabwareParams, | ||
| HEATERSHAKER_MODULE_TYPE, | ||
| MAGNETIC_BLOCK_TYPE, | ||
| MAGNETIC_MODULE_TYPE, | ||
|
|
@@ -71,7 +72,14 @@ export interface MagneticBlockState { | |
|
|
||
| export interface FlexStackerModuleState { | ||
| type: typeof FLEX_STACKER_MODULE_TYPE | ||
| // TODO: extend this state | ||
| latchOpen: boolean | null | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove? |
||
| maxPoolCount: number | ||
| storedLabwareDetails: FlexStackerSetStoredLabwareParams | null | ||
| shuttlePosition: 'home' | 'retrieved' | 'stored' | ||
| labwareInStacker: string[] | null | ||
| labwareInShuttle: number | null | ||
| labwareRetrieved: number | null | ||
| labwareStored: number | null | ||
| } | ||
| export type InitializationMode = 'single' | 'multi' | ||
| export interface Initialization { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
shared-data/js/helpers/__tests__/getFlexStackerHardwareProps.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import { | ||
| fixtureTiprack1000ul, | ||
| FLEX_STACKER_MODULE_V1, | ||
| getSchema2Dimensions, | ||
| MAGNETIC_MODULE_V1, | ||
| } from '../..' | ||
| import { | ||
| getHeightOfLabwareStackFromDefinitions, | ||
| getLabwareOverlapOffset, | ||
| getModuleMaxFillHeight, | ||
| getStackerMaxPoolCountByHeight, | ||
| } from '../getFlexStackerHardwareProps' | ||
|
|
||
| import type { LabwareDefinition2 } from '../..' | ||
|
|
||
| describe('getModuleMaxFillHeight()', () => { | ||
| it('should return the max fill height for a given module model', () => { | ||
| expect(getModuleMaxFillHeight(FLEX_STACKER_MODULE_V1)).toBe(612.75) | ||
| }) | ||
| }) | ||
|
|
||
| describe('getStackerMaxPoolCountByHeight()', () => { | ||
| it('should return the max pool count by height for a given module model', () => { | ||
| expect(getStackerMaxPoolCountByHeight(FLEX_STACKER_MODULE_V1, 100, 0)).toBe( | ||
| 6 | ||
| ) | ||
| }) | ||
|
|
||
| it('should throw an error if the module model is invalid', () => { | ||
| expect(() => | ||
| getStackerMaxPoolCountByHeight(MAGNETIC_MODULE_V1, 100, 0) | ||
| ).toThrow( | ||
| 'Invalid module model for max pool count by height: magneticModuleV1' | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('getLabwareOverlapOffset()', () => { | ||
| const mockLabwareDefinition = fixtureTiprack1000ul as LabwareDefinition2 | ||
|
|
||
| it('should return the labware overlap offset for a given module model', () => { | ||
| const result = getLabwareOverlapOffset( | ||
| FLEX_STACKER_MODULE_V1, | ||
| mockLabwareDefinition, | ||
| 'labware-name' | ||
| ) | ||
| expect(result).toStrictEqual({ x: 0, y: 0, z: 0 }) | ||
| }) | ||
|
|
||
| it('should throw an error if the module model is invalid', () => { | ||
| expect(() => | ||
| getLabwareOverlapOffset( | ||
| MAGNETIC_MODULE_V1, | ||
| mockLabwareDefinition, | ||
| 'labware-name' | ||
| ) | ||
| ).toThrow( | ||
| 'Invalid module model for labware overlap offset: magneticModuleV1' | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('getHeightOfLabwareStackFromDefinitions()', () => { | ||
| it('should return the height of a stack of labware from definitions', () => { | ||
| const mockLabwareDefinition = fixtureTiprack1000ul as LabwareDefinition2 | ||
| const result = getHeightOfLabwareStackFromDefinitions([ | ||
| mockLabwareDefinition, | ||
| ]) | ||
| expect(result).toBe(getSchema2Dimensions(mockLabwareDefinition).zDimension) | ||
| }) | ||
|
|
||
| it('should return 0 if the definitions are empty', () => { | ||
| const result = getHeightOfLabwareStackFromDefinitions([]) | ||
| expect(result).toBe(0) | ||
| }) | ||
|
|
||
| it('should return the height of a stack of labware from definitions', () => { | ||
| const mockLabwareDefinition = fixtureTiprack1000ul as LabwareDefinition2 | ||
| const result = getHeightOfLabwareStackFromDefinitions([ | ||
| mockLabwareDefinition, | ||
| mockLabwareDefinition, | ||
| ]) | ||
| expect(result).toBe( | ||
| getSchema2Dimensions(mockLabwareDefinition).zDimension * 2 | ||
| ) | ||
| }) | ||
| }) |
23 changes: 23 additions & 0 deletions
23
shared-data/js/helpers/__tests__/symbolicPositionHelpers.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { beforeEach, describe, expect, it } from 'vitest' | ||
|
|
||
| import { STANDARD_FLEX_SLOTS, STANDARD_OT2_SLOTS } from '../../fixtures' | ||
| import { getIsValidSlotName } from '../symbolicPositionHelpers' | ||
|
|
||
| describe('getIsSlotValid', () => { | ||
| beforeEach(() => {}) | ||
|
|
||
| it('returns true for a valid slot', () => { | ||
| STANDARD_FLEX_SLOTS.forEach(slot => { | ||
| expect(getIsValidSlotName(slot)).toBe(true) | ||
| }) | ||
| STANDARD_OT2_SLOTS.forEach(slot => { | ||
| expect(getIsValidSlotName(slot)).toBe(true) | ||
| }) | ||
| }) | ||
| it('returns false for an invalid slot', () => { | ||
| expect(getIsValidSlotName('13')).toBe(false) | ||
| }) | ||
| it('returns false for an invalid slot', () => { | ||
| expect(getIsValidSlotName('A5')).toBe(false) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { FLEX_STACKER_MODULE_V1 } from '../constants' | ||
| import { getModuleDef } from '../modules' | ||
| import { getSchema2Dimensions } from './positionMath' | ||
|
|
||
| import type { LabwareDefinition, ModuleModel, Vector3D } from '../types' | ||
|
|
||
| export const getModuleMaxFillHeight = (model: ModuleModel): number => { | ||
| if (model === FLEX_STACKER_MODULE_V1) { | ||
| return ( | ||
| getModuleDef(FLEX_STACKER_MODULE_V1).dimensions.maxStackerFillHeight ?? 0 | ||
| ) | ||
| } | ||
| throw new Error(`Invalid module model for max fill height: ${model}`) | ||
| } | ||
|
|
||
| export const getStackerMaxPoolCountByHeight = ( | ||
| model: ModuleModel, | ||
| poolHeight: number, | ||
| poolOverlap: number | ||
| ): number => { | ||
| if (model === FLEX_STACKER_MODULE_V1) { | ||
| const maxFillHeight = getModuleMaxFillHeight(model) | ||
| if (maxFillHeight <= 0) { | ||
| throw new Error( | ||
| `Invalid max fill height for ${model}: ${maxFillHeight} must be greater than 0` | ||
| ) | ||
| } | ||
| return Math.floor( | ||
| (maxFillHeight - poolOverlap) / (poolHeight - poolOverlap) | ||
| ) | ||
| } | ||
| throw new Error(`Invalid module model for max pool count by height: ${model}`) | ||
| } | ||
|
|
||
| export const getLabwareOverlapOffset = ( | ||
| model: ModuleModel, | ||
| definition: LabwareDefinition, | ||
| belowLabwareName: string | ||
| ): Vector3D => { | ||
| if (model !== FLEX_STACKER_MODULE_V1) { | ||
| throw new Error(`Invalid module model for labware overlap offset: ${model}`) | ||
| } | ||
| if ( | ||
| belowLabwareName in Object.keys(definition.stackingOffsetWithLabware ?? {}) | ||
| ) { | ||
| return ( | ||
| definition.stackingOffsetWithLabware?.[belowLabwareName] ?? { | ||
| x: 0, | ||
| y: 0, | ||
| z: 0, | ||
| } | ||
| ) | ||
| } | ||
| return definition.stackingOffsetWithLabware?.default ?? { x: 0, y: 0, z: 0 } | ||
| } | ||
|
|
||
| export const getHeightOfLabwareStackFromDefinitions = ( | ||
| definitions: LabwareDefinition[] | ||
| ): number => { | ||
| if (definitions.length === 0) { | ||
| return 0 | ||
| } | ||
| let total_height = 0.0 | ||
| let upper_def: LabwareDefinition = definitions[0] | ||
| for (const lower_def of definitions.slice(1)) { | ||
| const overlap = getLabwareOverlapOffset( | ||
| FLEX_STACKER_MODULE_V1, | ||
| upper_def, | ||
| lower_def.parameters.loadName | ||
| ).z | ||
| total_height += getSchema2Dimensions(upper_def).zDimension - overlap | ||
| upper_def = lower_def | ||
| } | ||
| return total_height + getSchema2Dimensions(upper_def).zDimension | ||
| } | ||
| // export const getModuleMaxRetrievableHeight = (model: ModuleModel): number => | ||
| // getModuleDef(model).dimensions.maxStackerRetrievableHeight ?? 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?