Skip to content
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

fix(api): monitor the pressure sensor more #15246

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
motor_nodes,
LIMIT_SWITCH_OVERTRAVEL_DISTANCE,
map_pipette_type_to_sensor_id,
moving_axes_in_move_group,
moving_pipettes_in_move_group,
gripper_jaw_state_from_fw,
get_system_constraints,
get_system_constraints_for_calibration,
Expand Down Expand Up @@ -667,12 +667,9 @@ async def move(
else False,
)

mounts_moving = [
ryanthecoder marked this conversation as resolved.
Show resolved Hide resolved
k
for k in moving_axes_in_move_group(move_group)
if k in [NodeId.pipette_left, NodeId.pipette_right]
]
async with self._monitor_overpressure(mounts_moving):
pipettes_moving = moving_pipettes_in_move_group(move_group)

async with self._monitor_overpressure(pipettes_moving):
positions = await runner.run(can_messenger=self._messenger)
self._handle_motor_status_response(positions)

Expand Down
14 changes: 14 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,20 @@ def create_gripper_jaw_hold_group(encoder_position_um: int) -> MoveGroup:
return move_group


def moving_pipettes_in_move_group(group: MoveGroup) -> List[NodeId]:
"""Utility function to get which pipette nodes are moving either in z or their plunger."""
all_nodes = [node for step in group for node, _ in step.items()]
moving_nodes = moving_axes_in_move_group(group)
pipettes_moving: List[NodeId] = [
k for k in moving_nodes if k in [NodeId.pipette_left, NodeId.pipette_right]
]
if NodeId.head_l in moving_nodes and NodeId.pipette_left in all_nodes:
pipettes_moving.append(NodeId.pipette_left)
if NodeId.head_r in moving_nodes and NodeId.pipette_right in all_nodes:
pipettes_moving.append(NodeId.pipette_right)
return pipettes_moving


def moving_axes_in_move_group(group: MoveGroup) -> Set[NodeId]:
"""Utility function to get only the moving nodes in a move group."""
ret: Set[NodeId] = set()
Expand Down
47 changes: 47 additions & 0 deletions api/tests/opentrons/hardware_control/backends/test_ot3_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest
from typing import List
from opentrons_hardware.hardware_control.motion_planning import Move
from opentrons_hardware.hardware_control.motion import (
create_step,
Expand Down Expand Up @@ -119,3 +121,48 @@ def test_get_system_contraints_for_plunger() -> None:
)

assert updated_contraints[axis].max_acceleration == set_acceleration


@pytest.mark.parametrize(
["moving", "expected"],
[
[
[NodeId.gantry_x, NodeId.gantry_y, NodeId.gripper_g, NodeId.gripper_z],
[],
],
[
[NodeId.head_l],
[NodeId.pipette_left],
],
[
[NodeId.head_r],
[NodeId.pipette_right],
],
],
)
def test_moving_pipettes_in_move_group(
moving: List[NodeId], expected: List[NodeId]
) -> None:
"""Test that we can filter out the nonmoving nodes."""
present_nodes = [
NodeId.gantry_x,
NodeId.gantry_y,
NodeId.head_l,
NodeId.head_r,
NodeId.pipette_left,
NodeId.pipette_right,
NodeId.gripper_g,
NodeId.gripper_z,
]
move_group = [
create_step(
distance={node: f64(100) for node in moving},
velocity={node: f64(100) for node in moving},
acceleration={node: f64(0) for node in moving},
duration=f64(1),
present_nodes=present_nodes,
)
]

moving_pipettes = ot3utils.moving_pipettes_in_move_group(move_group)
assert set(moving_pipettes) == set(expected)
Loading