Skip to content

Commit

Permalink
Merge pull request #10 from SCHUNK-SE-Co-KG/update-dummy-dependencies
Browse files Browse the repository at this point in the history
Update dummy dependencies
  • Loading branch information
stefanscherzinger authored Sep 24, 2024
2 parents 3e5ed39 + eab0fd2 commit 6afd3d8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
28 changes: 23 additions & 5 deletions schunk_egu_egk_gripper_dummy/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
# Schunk EGU/EGK Dummy
A minimalist protocol simulator for system tests.

Use this SCHUNK gripper dummy whenever you don't have access to real hardware
and still want to test your application.

## Dependencies
We need additional Python dependencies.
Install them inside your favorite Python environment with

```bash
pip install --user fastapi uvicorn
pip install --user fastapi uvicorn requests python-multipart
```

## Getting started
1. Start the dummy standalone with
```bash
./start_dummy.sh
```
There's a convenience script `start_dummy` for starting the dummy simulator.
It will start on localhost with port `8000` by default but you can specify another port via the `port:=<port-id>` syntax.

### Plain python

Although shipped inside a ROS2 package, the dummy itself doesn't need ROS2.
You can simply navigate into the dummy's package and start it with
```bash
./start_dummy port:=8000
```

### ROS2
When working in a sourced ROS2 environment, you can start the dummy with
```bash
ros2 run schunk_egu_egk_gripper_dummy start_dummy --ros-args -p port:=8000
```

## Run tests locally
Inside the dummy's package

```bash
pip install --user pytest httpx coverage
Expand Down
2 changes: 2 additions & 0 deletions schunk_egu_egk_gripper_dummy/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file's existence lets setup.py install the config folder to site-packages.
# We need this when starting this dummy with ros2 run.
5 changes: 1 addition & 4 deletions schunk_egu_egk_gripper_dummy/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from setuptools import find_packages, setup
import os
from glob import glob

package_name = "schunk_egu_egk_gripper_dummy"

Expand All @@ -11,9 +10,7 @@
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")),
(os.path.join("share", package_name, "config"), glob("config/*.json")),
(os.path.join("lib", package_name), ["start_dummy"]),
],
install_requires=["setuptools"],
zip_safe=True,
Expand Down
25 changes: 25 additions & 0 deletions schunk_egu_egk_gripper_dummy/start_dummy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/sh

# Default port
port=8000

# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
--ros-args)
shift
;;
-p|--port)
shift
;;
port:*)
port="${1#*:=}"
shift
;;
*)
shift
;;
esac
done

uvicorn schunk_egu_egk_gripper_dummy.main:server --port $port --reload
1 change: 0 additions & 1 deletion schunk_egu_egk_gripper_dummy/start_dummy.sh

This file was deleted.

0 comments on commit 6afd3d8

Please sign in to comment.