Skip to main content

A jpype based TRADE wrapper for using TRADE with Python

Project description

Disclaimer

This is a MAJOR work in progress, and everything is subject to change. Questions and bug reports are encouraged!

What is PyTRADE?

The purpose of this project is to enable developers to use TRADE in python. This is primarily to give developers access to integrate java components available in DIARC with python-specific libraries, such as simulation environments or reinforcement learning.

The process for using PyTRADE is simple: Install it with pip, initialize your TRADE wrapper, and you're good to go. You can also create python implementations of Java interfaces, allowing you to implement new TRADE services in python.

Installation

To install this package, make sure you have pip installed on your machine and then run:

pip install pytrade-wrapper

Setup

  1. Set up DIARC. See the DIARC readme for install instructions.
  2. In your DIARC directory, Run the command: ./gradlew publishToMavenLocal.
  3. From the DIARC readme, follow instructions for setting up Metric-FF. This will include creating/modifying gradle.properties.
  4. From the DIARC repo's trade.properties.default file, follow the instructions for making your own trade.properties file for java.
  5. In your personal trade.properties, change STARTDISCOVERY to true.

Using the Wrapper

Initializing

  1. If you just want to use TRADE, you can just import pyTRADE.core.wrapper. The JVM will automatically start.
  2. If you want to use the DIARC wrapper, instantiate the TRADEWrapper object.
  3. You can now use its various methods, most importantly call_trade(...).

Note: After importing trade_wrapper, you can also import anything from the DIARC and TRADE jars, following normal JPype standards. Import order matters here!

Implementing an Existing Java Interface

The primary reason you would want to implement an existing Java interface is to provide Python implementations for TRADE services. For example, if you wish to control a robotic arm through Python, and advertise that controller to TRADE, you can implement the ArmInterface from edu.tufts.hrilab.interfaces.ArmInterface.

It may be useful to read the JPype documentation on this process first.

  1. Create a new python class, such as PythonArmComponent
  2. Decorate it with @JImplements([YourInterface]), e.g. @JImplements(ArmInterface). Make sure you have [YourInterface] imported!
  3. For every method in the interface, implement it by decorating a standard python function definition with @JOverride
  4. Instantiate an instance of the class you just created, and register it with TRADE using: TRADE.registerAllServices([your_object], "")

Your methods from your new class should now be available via TRADE, assuming they implement a function annotated with @TRADEService in Java.

Please see the examples for additional guidance.

Making a new interface

If you need to advertise new TRADE services that aren't covered by any existing interfaces in DIARC, follow these steps.

  1. Create your new interface in the appropriate location in Java.
  2. Make sure you annotate the relevant methods with @TRADEService
  3. Run ./gradlew publishToMavenLocal

You can now follow the steps from the previous section to implement your new interface.

Todo:

  • Implement DIARC detectors
  • Let users add to the classpath

For questions, email (marlow.fawn@gmail.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrade_wrapper-1.0.0.tar.gz (768.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytrade_wrapper-1.0.0-py3-none-any.whl (769.5 kB view details)

Uploaded Python 3

File details

Details for the file pytrade_wrapper-1.0.0.tar.gz.

File metadata

  • Download URL: pytrade_wrapper-1.0.0.tar.gz
  • Upload date:
  • Size: 768.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pytrade_wrapper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0e19eaa8157f2a4f83914556308d7de28a2ab7b7ce6bda34ea18823580658230
MD5 c35b95df69005a9c0f9886f1c638793a
BLAKE2b-256 c33dba24df6567c58d12fe891bfdbfc1d91129adabe8b89255a13b7f2a666d4a

See more details on using hashes here.

File details

Details for the file pytrade_wrapper-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytrade_wrapper-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 769.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pytrade_wrapper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63099e44463f5b48faead0b82854f52eca050162a2dc1786d9fd21b3b11c37c3
MD5 060266949e3d364cb19401ffd151b1ff
BLAKE2b-256 cf1f98d489ae2753784a3cd266fd5ab3aead0102c28cdf47522ed2a04332bc0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page