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

feat(api): Add RobotContext movement commands #16403

Merged
merged 46 commits into from
Nov 8, 2024

Conversation

Laura-Danielle
Copy link
Contributor

@Laura-Danielle Laura-Danielle commented Oct 2, 2024

Overview

In this PR, you'll find a couple of major changes including hooking up the RobotContext with the protocol engine, adding the three movement commands (PLAT-351, PLAT-352, PLAT-449, PLAT-452, PLAT-455) in the context as well as http commands.

Remaining work

  • Gate behind 2.21
  • Disable for OT-2
  • Add tests for: robot_core, movement, gantry_mover, motion_utils functions and protocol engine commands
  • Update absolute motion_utils function to properly handle critical point

Test Plan and Hands on Testing

Robot has been tested with pipette mounts and will need to be tested with the gripper mount.

Changelog

  • Add robot_context movement commands
  • Add robot/moveTo, robot/moveAxesRelative and robot/moveAxesTo protocol engine commands
  • Add a robot core to share between the robot context and moveTo command
  • Update the ot3controller to handle sending moves to the Q motor if it is requested
  • Bump the command schema
  • Add relevant tests

Note

The axis_coordinates_for function can only properly handle Location types at this moment. There will be a follow-up PR to address modules and slots.

Review requests

Double check that routing makes sense and that I'm not missing any movement conversions before passing off to the hardware controller.

Risk assessment

Low. This is a use at your own risk API.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline comments. also i think something got lost in moveAxes vs moveAxesRelative, it seems like the gantry_mover function is missing an argument or a separate implementation for relative moves


Args:
axis_map: The mapping of axes to command.
relative_move: Specifying whether a relative move needs to be handled or not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the description, let me know if it makes more sense now.

api/src/opentrons/protocol_engine/types.py Outdated Show resolved Hide resolved
api/src/opentrons/types.py Outdated Show resolved Hide resolved
from opentrons.protocol_api.core.robot import AbstractRobot

_AXIS_TYPE_TO_MOTOR_AXIS = {
AxisType.X: MotorAxis.X,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kind of seems like it should be in the engine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in the engine, or did you mean a specific file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the engine - this is the protocol api engine bindings. My point is really that in my opinion, we shouldn't need to move AxisType to opentrons.types; instead, we should push MotorAxis upwards. Types that are used for the hardware controller shouldn't be part of user API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I guess that makes sense as well. I'll make the change, but as a PR based off this one since there is already a lot going on and there will be a decent amount of import changes.

abs_axis_map: Dict[hw_types.Axis, hw_types.AxisMapValue],
velocity: float,
critical_point: Optional[hw_types.CriticalPoint],
axis_map: Union[AxisMapType, StringAxisMap],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be hardware axes or engine axes? I think we should probably use engine axes, since this goes to the engine and that's what it uses, and also that will keep it the same as json protos

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment from here

@Laura-Danielle Laura-Danielle force-pushed the PLAT-351-move-axes-to-position branch from 52bd17b to b91630b Compare November 1, 2024 14:23
@Laura-Danielle Laura-Danielle marked this pull request as ready for review November 1, 2024 15:38
@Laura-Danielle Laura-Danielle requested review from a team as code owners November 1, 2024 15:38
@@ -69,9 +150,54 @@ def open_gripper_jaw(self) -> None:
raise NotImplementedError()

def axis_coordinates_for(
Copy link
Contributor

@TamarZanzouri TamarZanzouri Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random question, is this intended to be called from a protocol before using move_axes_relative or move_axes_to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move_axes_relative can be called directly with a user dict, but axis_coordinates_for is intended to help users build a proper absolute position axis map from location. In a follow-up PR I will also build out the slot and module locations but I felt like there was already a lot here and decided not to address it as we only need "location" at the moment for the evo protocol.

Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few nips but overall looks super intuitive and makes total sense. I just want to make sure we dont need to update the state right? (sorry I was not part of the convo's of this feature)

@Laura-Danielle Laura-Danielle force-pushed the PLAT-351-move-axes-to-position branch from 632b75e to 5fa07d7 Compare November 3, 2024 17:58
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a couple last little things we need to do. Some of them can be todos, but we definitely should update the command schema since it'll be quick.

I'm also a little concerned about the big changes to ot3controller. That's all to allow users to specify gear motor motions from the robot context, right? could we split that part out of this pr?

api/src/opentrons/hardware_control/ot3api.py Outdated Show resolved Hide resolved
@@ -1228,7 +1230,9 @@ async def move_axes( # noqa: C901
message=f"{axis} is not present", detail={"axis": str(axis)}
)

self._log.info(f"Attempting to move {position} with speed {speed}.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note which coordinates this is in in the log please

# TODO (lc 08-16-2024) implement `move_axes` for OT 2 hardware controller
# and then we can remove this validation.
ensure_ot3_hardware(self._hardware_api)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another thing we need to add here, and in the other commands, is that we changed the way the engine keeps track of positions to be based on StateUpdate objects that command implementations return. specifically, these will need to return state_updates with set_pipette_location() as aspirate now does for protocol engine commands after this one to properly know where the pipette currently is. we can have a todo for this, but it will be outright broken until then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean it would still execute the movements no? We have tickets for updating state for the robot context and I'd rather not add more to the PR than necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they will. It'll just move weird after.

shared-data/command/schemas/11.json Show resolved Hide resolved
@Laura-Danielle Laura-Danielle force-pushed the PLAT-351-move-axes-to-position branch 2 times, most recently from 5d0e3c8 to 02b8dde Compare November 7, 2024 22:01
@Laura-Danielle Laura-Danielle changed the base branch from edge to PLAT-351-allow-Q-motor-moves November 7, 2024 22:03
@Laura-Danielle Laura-Danielle force-pushed the PLAT-351-move-axes-to-position branch from 02b8dde to 8a6873d Compare November 7, 2024 22:07
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I feel great about this now. Thanks for bearing with me, and thanks for splitting that stuff out. Great work!

# TODO (lc 08-16-2024) implement `move_axes` for OT 2 hardware controller
# and then we can remove this validation.
ensure_ot3_hardware(self._hardware_api)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they will. It'll just move weird after.

Base automatically changed from PLAT-351-allow-Q-motor-moves to edge November 8, 2024 20:58
@Laura-Danielle Laura-Danielle force-pushed the PLAT-351-move-axes-to-position branch from 8a6873d to 0297272 Compare November 8, 2024 21:10
@Laura-Danielle Laura-Danielle force-pushed the PLAT-351-move-axes-to-position branch from 5271362 to 1fb5978 Compare November 8, 2024 22:00
@Laura-Danielle Laura-Danielle merged commit 0efe0af into edge Nov 8, 2024
61 of 63 checks passed
@Laura-Danielle Laura-Danielle deleted the PLAT-351-move-axes-to-position branch November 8, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants