From 56158856e697cdd51ec36cc40d8687c7a2ceff91 Mon Sep 17 00:00:00 2001 From: rproesma Date: Thu, 21 Nov 2024 12:12:43 +0100 Subject: [PATCH] turned schunk move_done_condition into member method --- .../grippers/hardware/schunk_egk40_usb.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/airo-robots/airo_robots/grippers/hardware/schunk_egk40_usb.py b/airo-robots/airo_robots/grippers/hardware/schunk_egk40_usb.py index 4506233..6bbc408 100644 --- a/airo-robots/airo_robots/grippers/hardware/schunk_egk40_usb.py +++ b/airo-robots/airo_robots/grippers/hardware/schunk_egk40_usb.py @@ -39,9 +39,10 @@ def __init__(self, usb_interface="/dev/ttyUSB0", self.calibrate_width() self.width_loss_due_to_fingers = self.SCHUNK_DEFAULT_SPECS.max_width - self.gripper_specs.max_width - # The BKSBase object supports communication with the Schunk EGK40 + # The BKSBase object supports communication with Schunk grippers self.bksb = BKSBase(usb_interface) # , debug=args.debug, repeater_timeout=args.repeat_timeout, # repeater_nb_tries=args.repeat_nb_tries) + # Prepare gripper: Acknowledge any pending error: self.bksb.command_code = eCmdCode.CMD_ACK time.sleep(0.1) @@ -107,9 +108,7 @@ def move(self, width: float, speed: Optional[float] = SCHUNK_DEFAULT_SPECS.min_s self.bksb.set_pos = (self.gripper_specs.max_width - _width) * 1000 self.bksb.command_code = eCmdCode.MOVE_POS - def move_done_condition() -> bool: - return self.current_speed == 0 - return AwaitableAction(move_done_condition) + return AwaitableAction(self._move_done_condition) def move_relative(self, width_difference: float, speed: Optional[float] = SCHUNK_DEFAULT_SPECS.min_speed, force: Optional[float] = SCHUNK_DEFAULT_SPECS.min_force) -> AwaitableAction: @@ -124,9 +123,7 @@ def move_relative(self, width_difference: float, speed: Optional[float] = SCHUNK self.bksb.set_pos = -width_difference*1000 self.bksb.command_code = eCmdCode.MOVE_POS_REL - def move_done_condition() -> bool: - return self.current_speed == 0 - return AwaitableAction(move_done_condition) + return AwaitableAction(self._move_done_condition) def grip(self) -> AwaitableAction: """ @@ -141,9 +138,7 @@ def grip(self) -> AwaitableAction: self.bksb.command_code = eCmdCode.MOVE_FORCE # (for historic reasons the actual grip command for simple gripping is called MOVE_FORCE...) WaitGrippedOrError(self.bksb) - def move_done_condition() -> bool: - return self.current_speed == 0 - return AwaitableAction(move_done_condition) + return AwaitableAction(self._move_done_condition) def stop(self) -> None: """ @@ -174,3 +169,6 @@ def input(self, prompt) -> None: def sleep(self, duration) -> None: return keep_communication_alive_sleep(self.bksb, duration) + + def _move_done_condition(self) -> bool: + return self.current_speed == 0