|
192 | 192 | ),
|
193 | 193 | )
|
194 | 194 |
|
| 195 | +_MOCK_LABWARE_DEFINITION2 = LabwareDefinition2.model_construct( # type: ignore[call-arg] |
| 196 | + namespace="test", |
| 197 | + version=1, |
| 198 | + schemaVersion=2, |
| 199 | + dimensions=LabwareDimensions(xDimension=1000, yDimension=1200, zDimension=750), |
| 200 | + parameters=LabwareDefinition2Parameters.model_construct(loadName="labware-name"), # type: ignore[call-arg] |
| 201 | +) |
| 202 | + |
| 203 | + |
195 | 204 | MOCK_ADDRESSABLE_AREA = AddressableArea(
|
196 | 205 | area_name="1",
|
197 | 206 | area_type=AreaType.SLOT,
|
@@ -2735,31 +2744,76 @@ def test_ensure_location_not_occupied_raises(
|
2735 | 2744 | )
|
2736 | 2745 |
|
2737 | 2746 |
|
2738 |
| -def test_get_labware_grip_point( |
| 2747 | +def test_get_labware_grip_point_v2_definition( |
2739 | 2748 | decoy: Decoy,
|
2740 | 2749 | mock_labware_view: LabwareView,
|
2741 | 2750 | mock_addressable_area_view: AddressableAreaView,
|
2742 | 2751 | subject: GeometryView,
|
2743 | 2752 | ) -> None:
|
2744 |
| - """It should get the grip point of the labware at the specified location.""" |
| 2753 | + """It should get the grip point of a LabwareDefinition2 labware at the specified location.""" |
2745 | 2754 | decoy.when(
|
2746 |
| - mock_labware_view.get_grip_height_from_labware_bottom( |
2747 |
| - sentinel.labware_definition |
2748 |
| - ) |
| 2755 | + mock_labware_view.get_grip_height_from_labware_bottom(_MOCK_LABWARE_DEFINITION2) |
2749 | 2756 | ).then_return(100)
|
2750 | 2757 |
|
2751 | 2758 | decoy.when(
|
2752 | 2759 | mock_addressable_area_view.get_addressable_area_center(DeckSlotName.SLOT_1.id)
|
2753 | 2760 | ).then_return(Point(x=101, y=102, z=103))
|
| 2761 | + |
| 2762 | + decoy.when( |
| 2763 | + mock_addressable_area_view.get_addressable_area(DeckSlotName.SLOT_1.id) |
| 2764 | + ).then_return(MOCK_ADDRESSABLE_AREA) |
| 2765 | + |
| 2766 | + expected_lw_origin_to_parent = Point(0, 0, 0) |
| 2767 | + |
2754 | 2768 | labware_center = subject.get_labware_grip_point(
|
2755 |
| - labware_definition=sentinel.labware_definition, |
| 2769 | + labware_definition=_MOCK_LABWARE_DEFINITION2, |
2756 | 2770 | location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1),
|
2757 | 2771 | )
|
2758 | 2772 |
|
2759 | 2773 | assert labware_center == Point(
|
2760 |
| - 101.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x, |
2761 |
| - 102.0 + +_PARENT_ORIGIN_TO_LABWARE_ORIGIN.y, |
2762 |
| - 203 + +_PARENT_ORIGIN_TO_LABWARE_ORIGIN.z, |
| 2774 | + 101.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x + expected_lw_origin_to_parent.x, |
| 2775 | + 102.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y + expected_lw_origin_to_parent.y, |
| 2776 | + 203 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z + expected_lw_origin_to_parent.z, |
| 2777 | + ) |
| 2778 | + |
| 2779 | + |
| 2780 | +def test_get_labware_grip_point_v3_definition( |
| 2781 | + decoy: Decoy, |
| 2782 | + mock_labware_view: LabwareView, |
| 2783 | + mock_addressable_area_view: AddressableAreaView, |
| 2784 | + subject: GeometryView, |
| 2785 | +) -> None: |
| 2786 | + """It should get the grip point of a LabwareDefinition3 labware at the specified location.""" |
| 2787 | + decoy.when( |
| 2788 | + mock_labware_view.get_grip_height_from_labware_bottom(_MOCK_LABWARE_DEFINITION3) |
| 2789 | + ).then_return(100) |
| 2790 | + |
| 2791 | + decoy.when( |
| 2792 | + mock_addressable_area_view.get_addressable_area_center(DeckSlotName.SLOT_1.id) |
| 2793 | + ).then_return(Point(x=101, y=102, z=103)) |
| 2794 | + |
| 2795 | + decoy.when( |
| 2796 | + mock_addressable_area_view.get_addressable_area(DeckSlotName.SLOT_1.id) |
| 2797 | + ).then_return(MOCK_ADDRESSABLE_AREA) |
| 2798 | + |
| 2799 | + expected_lw_origin_to_parent = ( |
| 2800 | + Point( |
| 2801 | + 0, |
| 2802 | + MOCK_ADDRESSABLE_AREA.bounding_box.y, |
| 2803 | + MOCK_ADDRESSABLE_AREA.bounding_box.z, |
| 2804 | + ) |
| 2805 | + * -1 |
| 2806 | + ) |
| 2807 | + |
| 2808 | + labware_center = subject.get_labware_grip_point( |
| 2809 | + labware_definition=_MOCK_LABWARE_DEFINITION3, |
| 2810 | + location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1), |
| 2811 | + ) |
| 2812 | + |
| 2813 | + assert labware_center == Point( |
| 2814 | + 101.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x + expected_lw_origin_to_parent.x, |
| 2815 | + 102.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y + expected_lw_origin_to_parent.y, |
| 2816 | + 203 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z + expected_lw_origin_to_parent.z, |
2763 | 2817 | )
|
2764 | 2818 |
|
2765 | 2819 |
|
@@ -2790,15 +2844,31 @@ def test_get_labware_grip_point_on_labware(
|
2790 | 2844 | mock_addressable_area_view.get_addressable_area_center(DeckSlotName.SLOT_4.id)
|
2791 | 2845 | ).then_return(Point(x=5, y=9, z=10))
|
2792 | 2846 |
|
| 2847 | + decoy.when( |
| 2848 | + mock_addressable_area_view.get_addressable_area(DeckSlotName.SLOT_4.id) |
| 2849 | + ).then_return(MOCK_ADDRESSABLE_AREA) |
| 2850 | + |
| 2851 | + expected_lw_origin_to_parent = ( |
| 2852 | + Point( |
| 2853 | + 0, |
| 2854 | + MOCK_ADDRESSABLE_AREA.bounding_box.y, |
| 2855 | + MOCK_ADDRESSABLE_AREA.bounding_box.z, |
| 2856 | + ) |
| 2857 | + * -1 |
| 2858 | + ) |
| 2859 | + |
2793 | 2860 | grip_point = subject.get_labware_grip_point(
|
2794 | 2861 | labware_definition=sentinel.definition,
|
2795 | 2862 | location=OnLabwareLocation(labwareId="below-id"),
|
2796 | 2863 | )
|
2797 | 2864 |
|
2798 | 2865 | assert grip_point == Point(
|
2799 |
| - 5.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x * 2, # The labware and adapter |
2800 |
| - 9.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y * 2, |
2801 |
| - 110.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z * 2, |
| 2866 | + 5.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x * 2 + expected_lw_origin_to_parent.x, |
| 2867 | + 9.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y * 2 + expected_lw_origin_to_parent.y, |
| 2868 | + 10.0 |
| 2869 | + + 100 |
| 2870 | + + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z * 2 |
| 2871 | + + expected_lw_origin_to_parent.z, |
2802 | 2872 | )
|
2803 | 2873 |
|
2804 | 2874 |
|
@@ -2868,14 +2938,23 @@ def test_get_labware_grip_point_for_labware_on_module(
|
2868 | 2938 | )
|
2869 | 2939 | ).then_return(Point(x=0, y=0, z=0))
|
2870 | 2940 |
|
| 2941 | + expected_lw_origin_to_parent = ( |
| 2942 | + Point( |
| 2943 | + 0, |
| 2944 | + MOCK_ADDRESSABLE_AREA.bounding_box.y, |
| 2945 | + MOCK_ADDRESSABLE_AREA.bounding_box.z, |
| 2946 | + ) |
| 2947 | + * -1 |
| 2948 | + ) |
| 2949 | + |
2871 | 2950 | result_grip_point = subject.get_labware_grip_point(
|
2872 | 2951 | labware_definition=sentinel.labware_definition,
|
2873 | 2952 | location=ModuleLocation(moduleId="module-id"),
|
2874 | 2953 | )
|
2875 | 2954 | assert result_grip_point == Point(
|
2876 |
| - x=492 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x, |
2877 |
| - y=350 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y, |
2878 |
| - z=838 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z, |
| 2955 | + x=492 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x + expected_lw_origin_to_parent.x, |
| 2956 | + y=350 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y + expected_lw_origin_to_parent.y, |
| 2957 | + z=838 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z + expected_lw_origin_to_parent.z, |
2879 | 2958 | )
|
2880 | 2959 |
|
2881 | 2960 |
|
@@ -2953,16 +3032,30 @@ def test_get_labware_grip_point_for_labware_stack_on_module(
|
2953 | 3032 | "magneticBlockV1C3"
|
2954 | 3033 | )
|
2955 | 3034 |
|
| 3035 | + expected_lw_origin_to_parent = ( |
| 3036 | + Point( |
| 3037 | + 0, |
| 3038 | + MOCK_ADDRESSABLE_AREA.bounding_box.y, |
| 3039 | + MOCK_ADDRESSABLE_AREA.bounding_box.z, |
| 3040 | + ) |
| 3041 | + * -1 |
| 3042 | + ) |
| 3043 | + |
2956 | 3044 | result_grip_point = subject.get_labware_grip_point(
|
2957 | 3045 | labware_definition=sentinel.labware_definition,
|
2958 | 3046 | location=OnLabwareLocation(labwareId="below-id-9"),
|
2959 | 3047 | )
|
2960 | 3048 |
|
2961 | 3049 | assert result_grip_point == Point(
|
2962 | 3050 | x=492.0
|
2963 |
| - + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x * 2, # The labware and module beneath it. |
2964 |
| - y=350.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y * 2, |
2965 |
| - z=838.0 + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z * 2, |
| 3051 | + + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.x * 2 # The labware and module beneath it. |
| 3052 | + + expected_lw_origin_to_parent.x, |
| 3053 | + y=350.0 |
| 3054 | + + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.y * 2 |
| 3055 | + + expected_lw_origin_to_parent.y, |
| 3056 | + z=838.0 |
| 3057 | + + _PARENT_ORIGIN_TO_LABWARE_ORIGIN.z * 2 |
| 3058 | + + expected_lw_origin_to_parent.z, |
2966 | 3059 | )
|
2967 | 3060 |
|
2968 | 3061 |
|
|
0 commit comments