Skip to main content

Communicates data between dopl and devices

Project description

Data Communicator Client

Sends and receives data between clients connected to Dopl

Usage

# Robot
import threading
import time

from doplcommunicator import DoplCommunicator
from doplcommunicator.controllerdata import ControllerData

def on_joined_session(session_id: int):
    print('Joined session id', session_id)

def on_controller_data(controller_data: ControllerData):
    print('Controller data received', controller_data.toDict())

def run_loop(communicator):
    while(True):
        # Use sparingly as this causes a read lock
        controller_data = communicator.controller_data

        # Apply controller data to robot

        time.sleep(0.01)

communicator = DoplCommunicator("http://localhost:3000")
communicator.on_joined_session(on_joined_session)
communicator.on_controller_data(on_controller_data)
communicator.connect()

threading.Thread(target=run_loop, args=(communicator))
# Robot Controller
import time
from doplcommunicator import DoplCommunicator
from doplcommunicator.controllerdata import ControllerData

def on_joined_session(session_id: int):
    print('Joined session id', session_id)

def run_loop(communicator):
    while(True):
        x = y = z = rx = ry = rz = rw = 0
        communicator.controller_data = ControllerData(x, y, z, rx, ry, rz, rw)

        time.sleep(0.01)

communicator = DoplCommunicator("http://localhost:3000")
communicator.on_joined_session(on_joined_session)
communicator.connect()

threading.Thread(target=run_loop, args=(communicator))

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

doplcommunicator-1.0.7.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

doplcommunicator-1.0.7-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file doplcommunicator-1.0.7.tar.gz.

File metadata

  • Download URL: doplcommunicator-1.0.7.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for doplcommunicator-1.0.7.tar.gz
Algorithm Hash digest
SHA256 5f7f111a1120254a8ae0f93129ac1c6f7dc7bb0e192226d580a9d4dd965fbd4e
MD5 01b8220910a7b8ea622e907466888f8d
BLAKE2b-256 130006d4fe83ad48aff7381d36bb3f04cc1cc11669738c8fe26c2f7575f153f2

See more details on using hashes here.

File details

Details for the file doplcommunicator-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for doplcommunicator-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 49096346f50fca9cd3dc232aafb9b174d72a73755137cc9321fa45cb7519f6df
MD5 ffde510765889937d9d6556225437020
BLAKE2b-256 c4e757c2213f403dd29555d2f9c9a1039cc9226d24f148e284f11108d6808817

See more details on using hashes here.

Supported by

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