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, ControllerData, RobotData

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

        # Send pressure data to remote clients
        communicator.robot_data = RobotData(True, 0.4)

        # 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, ControllerData, RobotData

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

def run_loop(communicator):
    while(True):
        # Send controller data to clients
        x = y = z = rx = ry = rz = rw = 0
        communicator.controller_data = ControllerData(x, y, z, rx, ry, rz, rw)

        # Apply pressure data to controller
        pressure = communicator.robot_data.pressure
        # controller.apply_force(pressure)

        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.9.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

doplcommunicator-1.0.9-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doplcommunicator-1.0.9.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for doplcommunicator-1.0.9.tar.gz
Algorithm Hash digest
SHA256 e8ba54303932ef4c9079326d34e2b5647c6832ad6ca7fe96332d435e3d275fa7
MD5 2f78e0dda6235accc88df9effbe7e9ce
BLAKE2b-256 bd9006937114d81c5cf7b4ee3da575f087457a33a512a4e1b29a4c5fe94d6115

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for doplcommunicator-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8d26f6b686a23c224796a60e812d014a5b61568113276c819707cf11d0eec8a7
MD5 ebbdb3ef2d29e6c126b216fddbcbba94
BLAKE2b-256 27f93eabc4fb3c3d195dc516a0e74a8e2a84a8332846057a2bbf90e876dcd0c3

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