diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a719caac..609b2596 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,7 +71,7 @@ jobs: # Python extensions - rcs_xarm7 - rcs_realsense - # - rcs_robotiq + - rcs_robotiq2f85 - rcs_tacto - rcs_usb_cam runs-on: ubuntu-latest diff --git a/docs/extensions/index.md b/docs/extensions/index.md index f72ce7e7..58c0391e 100644 --- a/docs/extensions/index.md +++ b/docs/extensions/index.md @@ -12,4 +12,5 @@ rcs_realsense rcs_usb_cam rcs_tacto rcs_robotics_library +rcs_robotiq2f85 ``` diff --git a/docs/extensions/overview.md b/docs/extensions/overview.md index efe3138f..84334d4e 100644 --- a/docs/extensions/overview.md +++ b/docs/extensions/overview.md @@ -30,6 +30,7 @@ RCS comes with several supported extensions: - **rcs_usb_cam**: Support for generic USB webcams. - **rcs_tacto**: Integration with the Tacto tactile sensor simulator. - **rcs_robotics_library**: Integration with the Robotics Library (RL). +- **rcs_robotiq2f85**: Integration with the Robotiq 2F-85 Gripper. ## Creating Extensions diff --git a/docs/extensions/rcs_robotiq2f85.md b/docs/extensions/rcs_robotiq2f85.md new file mode 100644 index 00000000..de0334e8 --- /dev/null +++ b/docs/extensions/rcs_robotiq2f85.md @@ -0,0 +1,29 @@ +# RCS Robotiq2F85 Extension + +This extension provides support for Robotiq 2F-85 Gripper in RCS. + +## Installation + +```shell +pip install -ve extensions/rcs_robotiq2f85 +``` + +Get the serial number of the gripper with this command: +```shell +udevadm info -a -n /dev/ttyUSB0 | grep serial +``` + +Provide the necessary permission: +```shell +chmod 777 /dev/ttyUSB0 +``` + +## Usage +```python +from rcs_robotiq2f85 import RobotiQGripper + +gripper = RobotiQGripper('') +gripper.reset() +gripper.shut() +print(gripper.get_normalized_width()) +``` diff --git a/extensions/rcs_robotiq2f85/README.md b/extensions/rcs_robotiq2f85/README.md new file mode 100644 index 00000000..baa44c9c --- /dev/null +++ b/extensions/rcs_robotiq2f85/README.md @@ -0,0 +1,28 @@ +# RCS Robotiq 2F-85 Gripper Hardware Extension +Extension to use the Robotiq 2F-85 Gripper with rcs. + +## Installation +```shell +pip install -ve . +``` + +Get the serial number of the gripper with this command: +```shell +udevadm info -a -n /dev/ttyUSB0 | grep serial +``` + +Provide the necessary permission: +```shell +chmod 777 /dev/ttyUSB0 +``` + +## Usage +```python +from rcs_robotiq2f85 import RobotiQGripper + +gripper = RobotiQGripper('') +gripper.reset() +gripper.shut() +print(gripper.get_normalized_width()) +``` + diff --git a/extensions/rcs_robotiq2f85/pyproject.toml b/extensions/rcs_robotiq2f85/pyproject.toml new file mode 100644 index 00000000..9d7b4958 --- /dev/null +++ b/extensions/rcs_robotiq2f85/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "rcs_robotiq2f85" +version = "0.6.2" +description="RCS RobotiQ module" +dependencies = [ + "rcs>=0.6.2", + "2f85-python-driver @ git+https://github.com/PhilNad/2f85-python-driver.git", +] +readme = "README.md" +maintainers = [ + { name = "Tobias Jülg", email = "tobias.juelg@utn.de" }, +] +authors = [ + { name = "Tobias Jülg", email = "tobias.juelg@utn.de" }, +] +requires-python = ">=3.10" +license = { text = "AGPL-3.0-or-later" } diff --git a/extensions/rcs_robotiq2f85/src/rcs_robotiq2f45/__init__.py b/extensions/rcs_robotiq2f85/src/rcs_robotiq2f45/__init__.py new file mode 100644 index 00000000..22049ab2 --- /dev/null +++ b/extensions/rcs_robotiq2f85/src/rcs_robotiq2f45/__init__.py @@ -0,0 +1 @@ +__version__ = "0.6.2" diff --git a/extensions/rcs_robotiq2f85/src/rcs_robotiq2f45/hw.py b/extensions/rcs_robotiq2f85/src/rcs_robotiq2f45/hw.py new file mode 100644 index 00000000..0e256899 --- /dev/null +++ b/extensions/rcs_robotiq2f85/src/rcs_robotiq2f45/hw.py @@ -0,0 +1,43 @@ +from rcs._core.common import Gripper +from Robotiq2F85Driver.Robotiq2F85Driver import Robotiq2F85Driver + + +class RobotiQGripper(Gripper): + def __init__(self, serial_number): + super().__init__() + self.gripper = Robotiq2F85Driver(serial_number=serial_number) + + def get_normalized_width(self) -> float: + # value between 0 and 1 (0 is closed) + return self.gripper.opening / 85 + + def grasp(self) -> None: + """ + Close the gripper to grasp an object. + """ + self.set_normalized_width(0.0) + + def open(self) -> None: + """ + Open the gripper to its maximum width. + """ + self.set_normalized_width(1.0) + + def reset(self) -> None: + self.gripper.reset() + + def set_normalized_width(self, width: float, _: float = 0) -> None: + """ + Set the gripper width to a normalized value between 0 and 1. + """ + if not (0 <= width <= 1): + msg = f"Width must be between 0 and 1, got {width}." + raise ValueError(msg) + abs_width = width * 85 + self.gripper.go_to(opening=float(abs_width), speed=150.0, force=30.0) + + def shut(self) -> None: + """ + Close the gripper. + """ + self.set_normalized_width(0.0) diff --git a/pyproject.toml b/pyproject.toml index 094f8195..97bab848 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -214,4 +214,8 @@ version_files = [ "extensions/rcs_tacto/pyproject.toml:version", "extensions/rcs_tacto/src/rcs_tacto/__init__.py:__version__", "extensions/rcs_tacto/pyproject.toml:\"rcs>=(.*)\"", + + "extensions/rcs_robotiq2f85/pyproject.toml:version", + "extensions/rcs_robotiq2f85/src/rcs_robotiq2f85/__init__.py:__version__", + "extensions/rcs_robotiq2f85/pyproject.toml:\"rcs>=(.*)\"", ]