Skip to content

Commit

Permalink
Make the gripper dummy a ROS2 package
Browse files Browse the repository at this point in the history
That's easier for installation and usage in the driver's test
repository.
The idea is, still, to keep the dummy ROS2-free in case we want to
ship it separately.
  • Loading branch information
stefanscherzinger committed Jul 13, 2024
1 parent 405641d commit ece1266
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
11 changes: 4 additions & 7 deletions schunk_egu_egk_gripper_dummy/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# Schunk EGU/EGK Dummy
A minimalist protocol simulator for system tests.

## Install
Use a virtual environment and
## Dependencies

```bash
pip install fastapi uvicorn
```

## Getting started
1. In a new terminal, start the dummy
1. Start the dummy standalone with
```bash
uvicorn main:server --port 8000 --reload
uvicorn schunk_egu_egk_gripper_dummy.main:server --port 8000 --reload
```

## Run tests locally

Inside a virtual environment (.venv)

```bash
pip install pytest coverage
```

And then inside this repository
```bash
coverage run -m pytest tests/
coverage report
Expand Down
13 changes: 13 additions & 0 deletions schunk_egu_egk_gripper_dummy/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>schunk_egu_egk_gripper_dummy</name>
<version>0.0.0</version>
<description>A minimalist dummy for simulating the gripper's communication</description>
<maintainer email="[email protected]">Stefan Scherzinger</maintainer>
<license>GPL-3.0-or-later</license>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
Empty file.
File renamed without changes.
4 changes: 4 additions & 0 deletions schunk_egu_egk_gripper_dummy/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/schunk_egu_egk_gripper_dummy
[install]
install_scripts=$base/lib/schunk_egu_egk_gripper_dummy
27 changes: 27 additions & 0 deletions schunk_egu_egk_gripper_dummy/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from setuptools import find_packages, setup
import os
from glob import glob

package_name = "schunk_egu_egk_gripper_dummy"

setup(
name=package_name,
version="0.0.0",
packages=find_packages(exclude=["tests"]),
data_files=[
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
("share/" + package_name, ["package.xml"]),
(os.path.join("share", package_name), [package_name + "/main.py"]),
(os.path.join("share", package_name, "src"), glob("src/*.py")),
],
install_requires=["setuptools"],
zip_safe=True,
maintainer="Stefan Scherzinger",
maintainer_email="[email protected]",
description="A minimalist dummy for simulating the gripper's communication",
license="GPL-3.0-or-later",
tests_require=["pytest", "coverage"],
entry_points={
"console_scripts": [],
},
)
5 changes: 4 additions & 1 deletion schunk_egu_egk_gripper_tests/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from launch_ros.substitutions import FindPackageShare
import launch_pytest
import subprocess
from ament_index_python.packages import get_package_share_directory


# We avoid black's F811, F401 linting warnings
# by using pytest's special conftest.py file.
Expand All @@ -22,7 +24,8 @@ def isolated():

@pytest.fixture()
def gripper_dummy():
dummy_dir = "/home/stefan/src/ros2_workspaces/egu-egk/src/schunk_egu_egk_gripper/schunk_egu_egk_gripper_dummy" # noqa: E501
package_name = "schunk_egu_egk_gripper_dummy"
dummy_dir = get_package_share_directory(package_name)
start_cmd = " uvicorn main:server --port 8000"
p = subprocess.Popen(
"exec" + start_cmd, stdin=subprocess.PIPE, cwd=dummy_dir, shell=True
Expand Down

0 comments on commit ece1266

Please sign in to comment.