Skip to content

Commit

Permalink
turned schunk move_done_condition into member method
Browse files Browse the repository at this point in the history
  • Loading branch information
RemkoPr committed Nov 21, 2024
1 parent 31075bb commit 5615885
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions airo-robots/airo_robots/grippers/hardware/schunk_egk40_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
"""
Expand All @@ -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:
"""
Expand Down Expand Up @@ -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

0 comments on commit 5615885

Please sign in to comment.