Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a minimalist dummy for simulating communication #8

Merged
merged 35 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9215d9a
Add boilerplate code for a web server
stefanscherzinger Jul 9, 2024
95d8ab2
Add a launch parameter for the driver's TCP/IP port
stefanscherzinger Jul 9, 2024
07b69ab
Add boilerplate code for GET requests
stefanscherzinger Jul 9, 2024
b53a09f
Rename the dummy sub package
stefanscherzinger Jul 9, 2024
70409aa
Handle all get requests via a single API call
stefanscherzinger Jul 10, 2024
9116e12
Add the TCP/IP port in the `curl` calls
stefanscherzinger Jul 10, 2024
405641d
Make the dummy available for gripper tests
stefanscherzinger Jul 12, 2024
ece1266
Make the gripper dummy a ROS2 package
stefanscherzinger Jul 13, 2024
98bf9ca
Provide system parameters in a config folder
stefanscherzinger Jul 17, 2024
99751f7
Use metadata to process `data.json` requests
stefanscherzinger Jul 17, 2024
7d6f2d9
Implement instance-based `data.jon` get requests
stefanscherzinger Jul 18, 2024
91aa53d
Add additional tests for the webserver's startup
stefanscherzinger Jul 19, 2024
35984a6
Update system parameters
stefanscherzinger Jul 19, 2024
1e7db9f
Implement the skeleton for the post request
stefanscherzinger Jul 19, 2024
d6fd46a
Update joint states topic in connection test
stefanscherzinger Jul 22, 2024
83adb99
Add the dummy's dependencies to CI
stefanscherzinger Jul 22, 2024
43af5b5
Test whether the driver advertises all ROS2 interfaces
stefanscherzinger Jul 22, 2024
d6657cf
Fix the installation of dependencies in the CI
stefanscherzinger Jul 24, 2024
ffbdebf
Rename the acknowledge service's result variable
stefanscherzinger Jul 25, 2024
1643d00
Move test helpers into a separate module
stefanscherzinger Jul 26, 2024
3e05f2c
Add a test for the driver's start state
stefanscherzinger Jul 26, 2024
e77ce6d
Keep all of the dummy's request-related tests in a separate file
stefanscherzinger Jul 26, 2024
e79f736
Keep plc data buffers separate
stefanscherzinger Jul 30, 2024
d2bb958
Implement reading and writing bits in the plc status dword
stefanscherzinger Jul 30, 2024
6f9f89f
Add methods to read and write errors and diagnostics
stefanscherzinger Jul 31, 2024
f531ef4
Store post requests' data for further processing.
stefanscherzinger Jul 31, 2024
80192ba
Add function to read bits from plc control double word
stefanscherzinger Aug 1, 2024
05817c3
Implement the acknowledge mechanism in the dummy
stefanscherzinger Aug 1, 2024
2d50eda
Add functions to read target setpoints
stefanscherzinger Aug 2, 2024
b8f34e8
Add function for toggling status bits
stefanscherzinger Aug 2, 2024
c06385b
Use fastapi's background task mechanism for gripper motion
stefanscherzinger Aug 2, 2024
b22fa1d
Implement driving to absolute positions
stefanscherzinger Aug 5, 2024
90dce50
Add missing CI dependency
stefanscherzinger Aug 5, 2024
8640deb
Activate the absolute position test in the driver
stefanscherzinger Aug 5, 2024
4b8313b
Drop the _testing_ branch for `Rolling` in the CI
stefanscherzinger Aug 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading