wrapyfi

Robotics MOM and RPC middleware wrapper with deep-learning framework integration

https://github.com/modular-ml/wrapyfi

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, researchgate.net
  • Committers with academic emails
    2 of 4 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.6%) to scientific vocabulary

Keywords

0mq distributed-computing flask-socketio middleware mqtt p2p parallel-computing python robotics ros ros-galactic ros-humble ros-noetic ros2 socketio websocket wrapper yarp zenoh zeromq
Last synced: 4 months ago · JSON representation ·

Repository

Robotics MOM and RPC middleware wrapper with deep-learning framework integration

Basic Info
Statistics
  • Stars: 77
  • Watchers: 5
  • Forks: 5
  • Open Issues: 5
  • Releases: 15
Topics
0mq distributed-computing flask-socketio middleware mqtt p2p parallel-computing python robotics ros ros-galactic ros-humble ros-noetic ros2 socketio websocket wrapper yarp zenoh zeromq
Created about 5 years ago · Last pushed 10 months ago
Metadata Files
Readme License Code of conduct Citation

README.md

[![webpage](https://custom-icon-badges.demolab.com/badge/Page-blue.svg?logo=globe&logoColor=white)](https://www.inf.uni-hamburg.de/en/inst/ab/wtm/research/software.html#wrapyfi "webpage link") [![paper](https://custom-icon-badges.demolab.com/badge/Paper-blue.svg?logo=paper_sheet&logoColor=white)](https://www2.informatik.uni-hamburg.de/wtm/publications/2024/AAFW24/Abawi_HRI24.pdf "paper link") [![researchgate](https://custom-icon-badges.demolab.com/badge/ResearchGate-white.svg?logo=researchgate)](https://www.researchgate.net/publication/376582189_Wrapyfi_A_Python_Wrapper_for_Integrating_Robots_Sensors_and_Applications_across_Multiple_Middleware "researchgate link") [![paperswithcode](https://custom-icon-badges.demolab.com/badge/Papers%20With%20Code-white.svg?logo=paperwithcode)](https://cs.paperswithcode.com/paper/wrapyfi-a-wrapper-for-message-oriented-and "paperswithcode link") [![modularml](https://custom-icon-badges.demolab.com/badge/Modular%20ML-white.svg?logo=modularml)](https://modular.ml/#wrap "modularml link") [![arXiv](https://custom-icon-badges.demolab.com/badge/arXiv:2302.09648-lightyellow.svg?logo=arxiv-logomark-small)](https://arxiv.org/abs/2302.09648 "arXiv link") [![doi](https://custom-icon-badges.demolab.com/badge/10.1145/3610977.3637471-lightyellow.svg?logo=doi_logo)](https://doi.org/10.1145/3610977.3637471 "doi link") [![codecov](https://codecov.io/github/modular-ml/wrapyfi/graph/badge.svg?token=5SD1A6ENKE)](https://codecov.io/github/modular-ml/wrapyfi) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://black.readthedocs.io/ "code style link") [![PyPI - Implementation](https://img.shields.io/pypi/implementation/wrapyfi)](https://pypi.org/project/wrapyfi/ "implementation") [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/wrapyfi)](https://pypi.org/project/wrapyfi/ "python version") [![PyPI version](https://badge.fury.io/py/wrapyfi.svg)](https://badge.fury.io/py/wrapyfi) [![PyPI total downloads](https://img.shields.io/pepy/dt/wrapyfi)](https://www.pepy.tech/projects/wrapyfi) [![Docker Hub Pulls](https://img.shields.io/docker/pulls/modularml/wrapyfi.svg)](https://hub.docker.com/repository/docker/modularml/wrapyfi) [![License](https://custom-icon-badges.demolab.com/github/license/denvercoder1/custom-icon-badges?logo=law&logoColor=white)](https://github.com/fabawi/wrapyfi/blob/main/LICENSE "license MIT") [![FOSSA status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmodular-ml%2Fwrapyfi.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmodular-ml%2Fwrapyfi?ref=badge_shield&issueType=license) [![Documentation status](https://readthedocs.org/projects/wrapyfi/badge/?version=latest)](https://wrapyfi.readthedocs.io/en/latest/?badge=latest)

Wrapyfi is a middleware communication wrapper for transmitting data across nodes, without altering the operation pipeline of your Python scripts. Wrapyfi introduces a number of helper functions to make middleware integration possible without the need to learn an entire framework, just to parallelize your processes on multiple machines. Wrapyfi supports YARP, ROS, ROS 2, ZeroMQ, Websocket, Zenoh and MQTT.

Attribution

Please refer to the following paper when citing Wrapyfi in academic work:

@inproceedings{abawi2024wrapyfi, title = {Wrapyfi: A Python Wrapper for Integrating Robots, Sensors, and Applications across Multiple Middleware}, author = {Abawi, Fares and Allgeuer, Philipp and Fu, Di and Wermter, Stefan}, booktitle = {Proceedings of the ACM/IEEE International Conference on Human-Robot Interaction (HRI '24)}, year = {2024}, organization = {ACM}, isbn = {79-8-4007-0322-5}, doi = {10.1145/3610977.3637471}, url = {https://github.com/fabawi/wrapyfi} }

Getting Started

Before using Wrapyfi, YARP, ROS, ZeroMQ, Websocket, Zenoh, or MQTT must be installed.

  • YARP: Follow the YARP installation guide.<!-- YARP installation guide. --> The yarpserver server must be running before running any YARP-based scripts. Note that the iCub package is not needed for Wrapyfi to work and does not have to be installed if you do not intend to use the iCub robot.

  • ROS: For installing ROS, follow the ROS installation guide [Ubuntu][Windows]. We recommend installing ROS on Conda using the RoboStack environment. The roscore server must be running before running any ROS-based scripts. Additionally, the Wrapyfi ROS interfaces must be built to support messages needed for audio transmission ROS Package Index

  • ROS 2: For installing ROS 2, follow the ROS 2 installation guide [Ubuntu][Windows]. We recommend installing ROS 2 on Conda using the RoboStack environment. Additionally, the Wrapyfi ROS 2 interfaces must be built to support messages and services needed for audio transmission and the REQ/REP pattern ROS Package Index

  • ZeroMQ: ZeroMQ can be installed using pip: pip install pyzmq. The XPUB/XSUB and XREQ/XREP patterns followed in our ZeroMQ implementation requires a proxy broker. A broker is spawned by default as a daemon process. To avoid automatic spawning, pass the argument start_proxy_broker=False to the method register decorator. A standalone broker can be found here

  • Websocket: Websocket can be installed using pip: pip install python-socketio. The PUB/SUB pattern followed in our Websocket implementation requires a socket server. We recommend setting the server to run using Flask-SocketIO which can be installed with pip install flask-socketio. Note that the server must be running and also scripted to forward messages to the listening from the publishing client as demonstrated in the example found here

  • Zenoh: Zenoh can be installed using pip: pip install eclipse-zenoh. It is recommended to use the WRAPYFI_ZENOH_MODE environment variable to set the mode to peer (default) for running in peer-to-peer mode. The PUB/SUB pattern followed in our Zenoh implementation requires a router. To install the Zenoh router, follow the instructions found here. The zenohd router must be running before executing any Zenoh-based Wrapyfi scripts with the environment variable WRAPYFI_ZENOH_MODE=client. NOTE: The zenohd --rest-http-port 8082 command must be executed with an arbitrary (non-conflicting) port to avoid collision with other services occupying the default port (8000).

  • MQTT: MQTT can be installed using pip: pip install paho-mqtt. The PUB/SUB pattern followed in our MQTT implementation requires a broker. The default broker used by Wrapyfi broker.emqx.io. However, this broker is not recommended for production use or for transmitting video/audio as it is a public online broker and requires an internet connection (not secure and suffers high latency). We recommend setting up a local broker using Mosquitto. A Dockerized version can be found here. The broker must be running, and the WRAPYFI_MQTT_BROKER_ADDRESS as well as WRAPYFI_MQTT_BROKER_PORT environment variables must be set to the broker's address and port, respectively. When setting up a local broker with a username and password, they can be passed through the Wrapyfi method decorator as follows:

python @MiddlewareCommunicator.register("NativeObject", "mqtt", "HelloWorld", "/hello/my_message", carrier="", should_wait=True, mqtt_kwargs=dict(username="username", password="password")) def send_message(self): ...

Compatibility

  • Operating System
    • [x] Ubuntu >= 18.04 (Not tested with earlier versions of Ubuntu or other Linux distributions)
    • [x] Windows >= 10 [beta support]:
    • Multiprocessing is disabled. ZeroMQ brokers spawn as threads only
    • Not tested with YARP and ROS 2
    • ROS only tested within mamba/micromamba environment installed using RoboStack
    • ROS and ROS 2 interfaces not tested
    • Installation instructions across Wrapyfi guides and tutorials are not guaranteed to be compatible with Windows 11
    • [ ] MacOS 10.14 Mojave planned
  • Python >= 3.6
  • OpenCV >= 4.2
  • NumPy >= 1.19

  • YARP >= v3.3.2

  • ROS Noetic Ninjemys

  • ROS 2 Humble Hawksbill | Galactic Geochelone | Foxy Fitzroy

  • PyZMQ 16.0, 17.1 and 19.0

  • Python-SocketIO >= 5.0.4

  • Eclipse-Zenoh >= 1.0.0

  • Paho-MQTT >= 2.0 (Hard-coded to v2 in Wrapyfi and not compatible with v1)

Installation

You can install Wrapyfi with pip or from source.

Pip

To install all the necessary components for the majority of common uses of Wrapyfi (e.g., NativeObject, Image, Audio, etc.) using pip, this process installs both Wrapyfi and its dependencies, like NumPy and OpenCV (opencv-contrib-python, opencv-headless, and opencv-python are supported), that are essential for various workloads, along with ZeroMQ being the default middleware. This option is the best for users running Wrapyfi out of the box in a newly created environment (without any middleware installed beforehand), installing numpy, opencv-contrib-python, and pyzmq:

pip install wrapyfi[all]

Note that most plugins require additional dependencies and should be installed separately.

or when installing Wrapyfi on a server (headless) including numpy, opencv-python-headless, and pyzmq:

pip install wrapyfi[headless]

Other middleware such as ROS are environment-specific and require dependencies that cannot be installed using pip. Wrapyfi could and should be used within such environments with minimal requirements to avoid conflicts with existing NumPy and OpenCV packages:

pip install wrapyfi

Source (Pip)

Clone this repository:

git clone --recursive https://github.com/fabawi/wrapyfi.git cd wrapyfi

You can choose to install minimal dependencies including numpy, opencv-contrib-python, and pyzmq, for running a basic Wrapyfi script:

pip install .[all]

or when installing Wrapyfi on a server (headless) including numpy, opencv-python-headless, and pyzmq:

pip install .[headless]

or when installing Wrapyfi to work with websockets (headless) including numpy, opencv-python-headless, and python-socketio:

pip install .[headless_websockets]

or when installing Wrapyfi to work with Zenoh (headless) including numpy, opencv-python-headless, and eclipse-zenoh:

pip install .[headless_zenoh]

or when installing Wrapyfi to work with MQTT (headless) including numpy, opencv-python-headless, and paho-mqtt:

pip install .[headless_mqtt]

or install Wrapyfi without NumPy, OpenCV, ZeroMQ, Websocket, Zenoh, and MQTT:

pip install .

Docker

Wrapyfi Docker images can be pulled/installed directly from the modularml/wrapyfi repository on the Docker Hub. Dockerfiles for all supported environments can be built as well by following the Wrapyfi Docker instructions.

Usage

Wrapyfi supports two patterns of communication: * Publisher-Subscriber (PUB/SUB): A publisher sends data to a subscriber accepting arguments and executing methods on the publisher's end. e.g., with YARP

Without Wrapyfi With Wrapyfi
```python # Just your usual Python class class HelloWorld(object): def send_message(self): msg = input("Type your message: ") obj = {"message": msg} return obj, hello_world = HelloWorld() while True: my_message, = hello_world.send_message() print(my_message) ``` ```python from wrapyfi.connect.wrapper import MiddlewareCommunicator class HelloWorld(MiddlewareCommunicator): @MiddlewareCommunicator.register("NativeObject", "yarp", "HelloWorld", "/hello/my_message", carrier="", should_wait=True) def send_message(self): msg = input("Type your message: ") obj = {"message": msg} return obj, hello_world = HelloWorld() LISTEN = True mode = "listen" if LISTEN else "publish" hello_world.activate_communication(hello_world.send_message, mode=mode) while True: my_message, = hello_world.send_message() print(my_message) ```

Run yarpserver from the command line. Now execute the Python script above (with Wrapyfi) twice, setting one instance to LISTEN = False and another to LISTEN = True. You can now type and return a message on the publisher's terminal and preview it within the listener's

  • Request-Reply (REQ/REP): A requester sends a request to a responder, which responds to the request in a synchronous manner. e.g., with ROS
Without Wrapyfi With Wrapyfi
```python # Just your usual Python class class HelloWorld(object): def send_message(self, a, b): msg = input("Type your message: ") obj = {"message": msg, "a": a, "b": b, "sum": a + b} return obj, hello_world = HelloWorld() while True: my_message, = hello_world.send_message(a=1, b=2) print(my_message) ``` ```python from wrapyfi.connect.wrapper import MiddlewareCommunicator class HelloWorld(MiddlewareCommunicator): @MiddlewareCommunicator.register("NativeObject", "ros", "HelloWorld", "/hello/my_message", carrier="", should_wait=True) def send_message(self, a, b): msg = input("Type your message: ") obj = {"message": msg, "a": a, "b": b, "sum": a + b} return obj, hello_world = HelloWorld() LISTEN = True mode = "request" if LISTEN else "reply" hello_world.activate_communication(hello_world.send_message, mode=mode) while True: my_message, = hello_world.send_message(a=1 if LISTEN else None, b=2 if LISTEN else None) print(my_message) ```

Run roscore from the command line. Now execute the Python script above (with Wrapyfi) twice, setting one instance to LISTEN = False and another to LISTEN = True. You can now type and return a message on server's terminal and preview it within the client's. Note that the server's command line will not show the message until the client's command line has been used to send a request. The arguments are passed from the client to the server and the server's response is passed back to the client.

For more examples of usage, refer to the user guide. Run scripts in the examples directory for trying out Wrapyfi.

Supported Formats

Serializers

  • [x] JSON
  • [ ] msgpack
  • [ ] protobuf

Data Structures

Supported Objects by the NativeObject type include:

Image

Supported Objects by the Image type include:

Sound

Supported Objects by the AudioChunk type include:

  • [x] Tuple(NumPy Array, int) [supports the sounddevice format]

Owner

  • Name: modular-ml
  • Login: modular-ml
  • Kind: organization

Distribute models across multiple machines and platforms

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
preferred-citation:
  type: article
  authors:
  - family-names: "Abawi"
    given-names: "Fares"
    orcid: "https://orcid.org/0000-0002-4240-5351"
  - family-names: "Allgeuer"
    given-names: "Philipp"
  - family-names: "Fu"
    given-names: "Di"
  - family-names: "Wermter"
    given-names: "Stefan"
  title: "Wrapyfi: A Python Wrapper for Integrating Robots, Sensors, and Applications across Multiple Middleware"
  journal: "Proceedings of the 2024 ACM/IEEE International Conference on Human-Robot Interaction (HRI '24)"
  publisher: 
    name: "Association for Computing Machinery"
  doi: 10.1145/3610977.3637471
  year: 2024
  date-released: 2023-12-12
  url: "https://github.com/fabawi/wrapyfi"

GitHub Events

Total
  • Create event: 12
  • Release event: 3
  • Issues event: 2
  • Watch event: 3
  • Delete event: 9
  • Issue comment event: 1
  • Push event: 36
  • Pull request event: 19
Last Year
  • Create event: 12
  • Release event: 3
  • Issues event: 2
  • Watch event: 3
  • Delete event: 9
  • Issue comment event: 1
  • Push event: 36
  • Pull request event: 19

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 693
  • Total Committers: 4
  • Avg Commits per committer: 173.25
  • Development Distribution Score (DDS): 0.101
Past Year
  • Commits: 75
  • Committers: 2
  • Avg Commits per committer: 37.5
  • Development Distribution Score (DDS): 0.093
Top Committers
Name Email Commits
Fares Abawi f****i@o****m 623
Philipp Allgeuer p****r@u****e 40
GitHub Actions Bot a****s@g****m 28
icub i****b@i****e 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 3
  • Total pull requests: 40
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 1 hour
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 1.67
  • Average comments per pull request: 0.03
  • Merged pull requests: 39
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 14
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • fabawi (4)
  • zhaokefei (1)
Pull Request Authors
  • fabawi (69)
  • fossabot (2)
Top Labels
Issue Labels
help wanted (2) bug (1) planned (1) enhancement (1)
Pull Request Labels

Dependencies

.github/workflows/manual_update_version.yml actions
  • actions/checkout v2 composite
docs/requirements.txt pypi
  • mdsplit *
  • myst_parser *
  • pyyaml >=5.1.1
  • sphinx *
  • sphinx_rtd_theme *
examples/requirements.txt pypi
  • Pillow *
  • dask *
  • mxnet-cu112 *
  • pandas <2.0.0
  • pint *
  • pyarrow *
  • sounddevice *
  • tensorflow >=2.9.1
  • torch >=1.12.1
  • torchaudio >=0.12.1
  • torchvision >=0.13.1
  • xarray *
  • zarr *
pyproject.toml pypi
  • pyyaml >=5.1.1
  • setuptools >=59.6.0
requirements.txt pypi
setup.py pypi
  • pyyaml >=5.1.1