Wrapify is a middleware communication wrapper for effortlessly transmitting data across nodes, without the need to alter the operation pipeline of your python scripts

fabawi fabawi Last update: Sep 23, 2022

Wrapify

Wrapify is a middleware communication wrapper for transmitting data across nodes, without the need toalter the operation pipeline of your python scripts. Wrapify introducesa number of helper functions to make middleware integration possible without the need to learn an entire framework, just to parallelize your processes onmultiple machines.Wrapify supports Yarp, ROS, and ZeroMQ.

To Wrapify a class, simply add the decorators describing the publisher and listener parameters. Wrapify imposes an object-orientedrequirement on your coding style: All wrapify compatible functions need to be defined within a class.

Installation

Before using Wrapify, Yarp, ROS, or ZeroMQ must be installed.

Follow the Yarp installation guide.Note that the iCub package is not needed for Wrapify to work and does not have to be installed if you do not intend on using the iCub robot.

For the installation of ROS, follow the ROS installation guide.We recommend installing ROS on conda using the RoboStack environment.

ZeroMQ can be installed using pip. ImageZMQ is required by Wrapify when using ZeroMQ as the middleware: pip install imagezmq.The xpub-xsub pattern 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

compatibility

  • Python >= 3.6
  • OpenCV >= 4.2
  • Yarp >= v3.3.2
  • ROS Noetic Ninjemys
  • PyZMQ 16.0, 17.1 and 19.0
  • imageZMQ 1.1.1

To install Warpify:

python3 setup.py install

Usage

Without Wrapify With Wrapify
# Just your usual python classclass 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["message"])
from wrapify.connect.wrapper import MiddlewareCommunicatorclass 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 = Truemode = "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["message"])

Run yarpserver from the command line. Now execute the python script above (with wrapify) twice setting LISTEN = False and LISTEN = True. You can now type with the publisher's command line and preview the message within the listiner's

For more examples on usage, refer to the usage documentation. Run scripts in the examples directory for seeing Wrapify in action.

TODO

Visit the issues section for more details

  • Support ROS
  • Support ROS 2
  • Support ZeroMQ (TODO: image and audio chunk support; proper should_wait trigger instead of dummy)
  • Support Pytorch
  • Support Tensorflow 2
  • Support MXNet
  • Support Keras (TF 2)
  • Support Pandas dataframes
  • Support Image formats: tensorflow, Pytorch, Scikit Image, ImageIO and Pillow
  • Support msgpack as a serialization format
  • Support encapsulating wrapped calls to publishers and listeners
  • Support wrapping for module functions
  • Support multiple class instances for functions set to publish

Subscribe to our newsletter