Skip to content

Commit

Permalink
Merge pull request #8 from SCHUNK-SE-Co-KG/add-test-dummy
Browse files Browse the repository at this point in the history
Add a minimalist dummy for simulating communication
  • Loading branch information
stefanscherzinger authored Aug 5, 2024
2 parents 1297d61 + 4b8313b commit ed4d9ac
Show file tree
Hide file tree
Showing 45 changed files with 5,162 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
[flake8]
# Use black's line length (default 88) instead of the flake8 default of 79:
max-line-length = 88

per-file-ignores =
schunk_egu_egk_gripper_dummy/*.py:E203
18 changes: 17 additions & 1 deletion .github/script/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#/usr/bin/bash
cd $HOME
apt-get install curl libcurl4-openssl-dev
apt-get install -y curl libcurl4-openssl-dev

# Python dependencies
python_deps="fastapi uvicorn httpx requests coverage python-multipart"
os_name=$(lsb_release -cs)

case $os_name in
jammy) # Ubuntu 22.04
pip install --user $python_deps
;;
kinetic) # Ubuntu 24.04
pip install --break-system-packages $python_deps
;;
*) # Newer
pip install --break-system-packages $python_deps
;;
esac
2 changes: 1 addition & 1 deletion .github/workflows/industrial_ci_rolling_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
env:
- {ROS_DISTRO: rolling, ROS_REPO: testing}
#- {ROS_DISTRO: rolling, ROS_REPO: testing}
- {ROS_DISTRO: rolling, ROS_REPO: main}
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/install/
/log/
/.vscode

# Ignore test coverage artifacts
*.coverage
10 changes: 8 additions & 2 deletions schunk_egu_egk_gripper_driver/launch/schunk.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def generate_launch_description():
default_value="10.49.60.86",
description="IP address of the gripper on your network",
)
args = [ip]
port = DeclareLaunchArgument(
"port",
default_value="80",
description="TCP/IP port of the gripper",
)
args = [ip, port]

container = Node(
name="gripper_container",
Expand All @@ -44,9 +49,10 @@ def generate_launch_description():
package="schunk_egu_egk_gripper_driver",
plugin="SchunkGripperNode",
name="schunk_gripper_driver",
namespace="EGK_50_M_B",
namespace="",
parameters=[
{"IP": LaunchConfiguration("IP")},
{"port": LaunchConfiguration("port")},
{"state_frq": 60.0},
{"rate": 10.0},
{"use_brk": False},
Expand Down
11 changes: 7 additions & 4 deletions schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ std::map<std::string, std::string> inst_param =
//Initialize the ROS Driver
SchunkGripperNode::SchunkGripperNode(const rclcpp::NodeOptions &options) :
rclcpp::Node("schunk_gripper_driver", options),
Gripper(this->declare_parameter("IP", "0.0.0.0", parameter_descriptor("IP-Address of the gripper"))),
Gripper(
this->declare_parameter("IP", "0.0.0.0", parameter_descriptor("IP-Address of the gripper")),
this->declare_parameter("port", 80, parameter_descriptor("TCP/IP port of the gripper"))
),
limiting_rate(1000) //limiting_rate for loops
{
//Callback groups
Expand Down Expand Up @@ -1150,20 +1153,20 @@ void SchunkGripperNode::acknowledge_srv(const std::shared_ptr<Acknowledge::Reque

if(check()) //TODO handshake
{
res->acknowledged = true;
res->success = true;
RCLCPP_WARN(this->get_logger(),"Acknowledged");
}
else
{
res->acknowledged = false;
res->success = false;
RCLCPP_WARN(this->get_logger(),"Acknowledge failed!");
}
}
catch(const char* server_err)
{
connection_error = server_err ;
RCLCPP_ERROR(this->get_logger(), "Failed Connection! %s", connection_error.c_str());
res->acknowledged = false;
res->success = false;
RCLCPP_WARN(this->get_logger(), "Acknowledge failed!");
}
last_command = 0;
Expand Down
25 changes: 25 additions & 0 deletions schunk_egu_egk_gripper_dummy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Schunk EGU/EGK Dummy
A minimalist protocol simulator for system tests.

## Dependencies

```bash
pip install --user fastapi uvicorn
```

## Getting started
1. Start the dummy standalone with
```bash
uvicorn schunk_egu_egk_gripper_dummy.main:server --port 8000 --reload
```

## Run tests locally

```bash
pip install --user pytest httpx coverage
```

```bash
coverage run -m pytest tests/
coverage report
```
22 changes: 22 additions & 0 deletions schunk_egu_egk_gripper_dummy/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Reading system parameters from a gripper
The system parameters are mentioned in the gripper's datasheet [Commissioning Instructions, Firmware 5.2 EGU with EtherNet/IP interface](https://stb.cloud.schunk.com/media/IM0046706.PDF).

## Enums
The easiest approach is reading enums from a web browser.
Enums need to be accessed via the _DEC_ identifier.
For instance, reading available error codes for the enum `HEX=0x0118` (`DEC=280`) would be
```browser
http://<gripper-ip>/adi/enum.json?inst=280
```

## Metadata

```bash
http://<gripper-ip>/adi/metadata.json?offset=0&count=300
```

## Data
Use this script that reads the data directly from the gripper:
```bash
./read_system_parameters.py <gripper-ip>
```
170 changes: 170 additions & 0 deletions schunk_egu_egk_gripper_dummy/config/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"0x0040": [
"800000800000A25800000000D90000EF"
],
"0x0048": [
"05000000000000000000000000000000"
],
"0x0100": [
"0000"
],
"0x0118": [
"EF"
],
"0x0120": [
"00"
],
"0x0128": [
"001F"
],
"0x0130": [
"3238343A32363A3532203C307846343E206D6F766520626C6F636B6564206F6363757272656420696E2063757272656E74207374617465203420286170706C69636174696F6E5F73746174655F6D616368696E652E683A3A313334392900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
],
"0x0210": [
"00000000"
],
"0x0230": [
"42263D87"
],
"0x0238": [
"00000000"
],
"0x0380": [
"0000"
],
"0x03A8": [
"3F828F5C"
],
"0x03B0": [
"000000000000000042A70000000000000000000000000000"
],
"0x03B8": [
"BF251EB8BEAD844D423A7AE1448EC57E44E16CEE45066271"
],
"0x0500": [
"12"
],
"0x0528": [
"3F800000"
],
"0x0540": [
"40A00000"
],
"0x0580": [
"40000000"
],
"0x0588": [
"42A60000"
],
"0x05A8": [
"40A00000"
],
"0x0600": [
"00000000"
],
"0x0608": [
"42A60000"
],
"0x0610": [
"00000000"
],
"0x0628": [
"40B00000"
],
"0x0630": [
"42E60000"
],
"0x0650": [
"41B00000"
],
"0x0658": [
"42960000"
],
"0x0660": [
"43160000"
],
"0x06A8": [
"00000000"
],
"0x0800": [
"4199999A"
],
"0x0808": [
"41F00000"
],
"0x0810": [
"4199999A"
],
"0x0818": [
"41E66666"
],
"0x0820": [
"C0A00000"
],
"0x0828": [
"42AA0000"
],
"0x0840": [
"421EAE6D"
],
"0x0870": [
"41BA5871"
],
"0x0878": [
"41C04897"
],
"0x0880": [
"41ACCCCD"
],
"0x0888": [
"41D33333"
],
"0x0890": [
"41ACCCCD"
],
"0x0898": [
"41D33333"
],
"0x08A0": [
"40A00000"
],
"0x08A8": [
"42960000"
],
"0x1000": [
"4E534E53303731390000000000000000"
],
"0x1008": [
"31323334350000000000000000000000"
],
"0x1020": [
"3B036ECF"
],
"0x1100": [
"536570202034203230323300"
],
"0x1108": [
"31383A30343A313400"
],
"0x1110": [
"01F6"
],
"0x1118": [
"352E322E302E38313839360000000000000000000000"
],
"0x1120": [
"322E312E3100000000000000"
],
"0x1130": [
"01"
],
"0x1138": [
"0030114844C7"
],
"0x1330": [
"01"
],
"0x1400": [
"00000A69"
]
}
Loading

0 comments on commit ed4d9ac

Please sign in to comment.