Skip to content

Commit

Permalink
fix(api): smoothie-driver backlash compensation allows all axes to mo…
Browse files Browse the repository at this point in the history
…ve simultaneously (#10923)

* apply backlash correction only after all axes have arrived at target position

* remove overcomplicated plunger-split change

* update plunger test

* lint
  • Loading branch information
andySigler authored Jun 28, 2022
1 parent 21cf672 commit d65147e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions api/src/opentrons/drivers/smoothie_drivers/driver_3_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,21 @@ def create_coords_list(coords_dict: Dict[str, float]) -> CommandBuilder:
log.info(f"No axes move in {target} from position {self.position}")
return

backlash_target = {
axis: value + PLUNGER_BACKLASH_MM
# Multi-axis movements should include the added backlash.
# After all axes arrive at target, finally then apply
# a backlash correction to just the plunger axes
plunger_backlash_axes = [
axis
for axis, value in target.items()
if axis in "BC" and self.position[axis] < value
}
]
backlash_target = {ax: moving_target[ax] for ax in plunger_backlash_axes}
moving_target.update(
{
ax: moving_target[ax] + PLUNGER_BACKLASH_MM
for ax in plunger_backlash_axes
}
)

# whatever else we do to our motion target, if nothing moves in the
# input we will not command it to move
Expand All @@ -1295,7 +1305,7 @@ def build_split(here: float, dest: float, split_distance: float) -> float:
split_target = {
ax: build_split(
self.position[ax],
backlash_target.get(ax, moving_target[ax]),
moving_target[ax],
split.split_distance,
)
for ax, split in self._move_split_config.items()
Expand Down Expand Up @@ -1365,12 +1375,14 @@ def build_split(here: float, dest: float, split_distance: float) -> float:
# introduce the standard currents
command.add_builder(builder=self._generate_current_command())

# move to target position, including any added backlash to B/C axes
command.add_gcode(GCODE.MOVE).add_builder(builder=primary_command_string)
if backlash_command_string:
# correct the B/C positions
command.add_gcode(gcode=GCODE.MOVE).add_builder(
builder=backlash_command_string
)

command.add_gcode(GCODE.MOVE).add_builder(builder=primary_command_string)
if checked_speed != self._combined_speed:
command.add_builder(builder=self._build_speed_command(self._combined_speed))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ async def test_plunger_commands(subject: SmoothieDriver, spy: MagicMock):
)
expected = [
# Set active axes high
"M907 A0.8 B0.05 C0.05 X1.25 Y1.25 Z0.8 G4 P0.005 G0 B4.55 G0 A3.5"
" B4.25 C5.55 X10.988 Y2.123 Z2.5",
"M907 A0.8 B0.05 C0.05 X1.25 Y1.25 Z0.8 G4 P0.005"
" G0 A3.5 B4.55 C5.55 X10.988 Y2.123 Z2.5 G0 B4.25",
"M400",
# Set plunger current low
"M907 A0.8 B0.05 C0.05 X1.25 Y1.25 Z0.8 G4 P0.005",
Expand Down

0 comments on commit d65147e

Please sign in to comment.