ContactGlove Python SDK V2
contactglovesdk is the ContactGlove Python SDK V2 library. It receives glove
data from DivingStation over OSC and provides polling methods and callbacks.
Distribution contents
The downloadable distribution contains:
README.md (Japanese installation guide)
README_EN.md (English installation guide)
contactglovesdk-X.Y.Z-py3-none-any.whl
examples/
basic_usage.py
simple_receive.py
viewer/
doc/
LICENSE.md
NOTICE.md
THIRD_PARTY_NOTICES.mdSee the API reference for data types, methods, and callbacks.
Requirements
- ContactGlove3 Pro (with ContactGlove3, no data reaches the SDK)
- Python 3.10 or later
- DivingStation v2 or later installed and able to start
The SDK itself is pure Python and does not require an OS-specific build. Operation has been confirmed on Windows 11, macOS, and Ubuntu. Check the viewer setup and DivingStation availability separately.
The SDK communicates with DivingStation over OSC. By default, the receive port
on the DivingStation side is 25791, and the receive port on the SDK side is
assigned automatically by the OS.
The default source port is also send_port=0 (assigned by the OS).
By default, DivingStation listens on this computer only, so another PC cannot connect. If you expose it on a trusted LAN, the default connection policy requires approval for another PC; connections from the same PC are allowed automatically.
Connect from another PC
- Use a trusted LAN.
- In DivingStation's
SDK / Protocol, setListening scopetoExpose on LAN. If you change the listening scope, restart DivingStation. - Set the SDK's destination to the numeric IP address of the DivingStation PC and its listening port (default
25791). In Python, use a setting such asHost("DivingStation", "192.168.1.100", 25791). - If the connection policy requires approval, allow the connection request shown in DivingStation.
- Allow the required UDP traffic on the actual receive ports of both PCs. Set the SDK receive port with
ContactGloveClient(local_port=...); for automatic allocation, checkclient.local_portafter connecting for the actual value.
To retry
while waiting for LAN approval or recovering from missing data, call
connect_to_host(host) again on the same client without calling disconnect
or close. This resends only Connect using the same send socket, source port,
and receive port. The SDK also keeps resending Connect every 30 seconds.
A successful call does not confirm LAN approval. Retries can restore the
connection after DivingStation restarts; approve it again if required.
Explicit disconnect ends the session and can revoke pending or granted approval.
Installation
Download and extract the SDK distribution, then install its wheel file from the extracted folder.
Replace X.Y.Z with the version in the downloaded filename.
python -m pip install ./contactglovesdk-X.Y.Z-py3-none-any.whlpip automatically installs the dependencies python-osc>=1.7.5 and matplotlib>=3.7.5.
matplotlib is used only by examples/viewer.
Checking the connection first
- Start DivingStation.
- Connect ContactGlove3 Pro in DivingStation and make sure it is enabled.
- Run the following from the extracted SDK distribution folder.
python ./examples/basic_usage.pyOutput like the following means the SDK is receiving data from DivingStation.
Listening on local port ... …
Polling target: auto
[device] id=...
[select] ...
[poll] id=...If [device] shows an ID but [poll] stays at no data yet, specify the ID or
name of the target glove with the --glove option. Replace YOUR_GLOVE_ID below with the actual ID shown in [device].
python ./examples/basic_usage.py --glove YOUR_GLOVE_IDUsing the SDK in your own project
Once installed, you can import and use it as an ordinary Python package.
import time
from contactglovesdk import ContactGloveClient, Host
host = Host("localhost", "127.0.0.1", 25791)
with ContactGloveClient() as client:
client.register_callback_for_glove_data_stream(lambda g: print(g.id))
client.connect_to_host(host)
time.sleep(5)
client.disconnect(host)For data access and callbacks, see the API reference.
The distribution also includes examples/simple_receive.py and examples/basic_usage.py.
Troubleshooting
basic_usage.py only prints no data yet:
- Check that DivingStation is running.
- Check that the glove is connected in DivingStation.
- Check that the ID or name passed to the
--gloveoption matches the actual glove shown in[device].
ModuleNotFoundError: No module named 'contactglovesdk':
- Check that the Python environment where you ran
python -m pip install ./contactglovesdk-X.Y.Z-py3-none-any.whlis the same one you use to run the samples (if you use a virtual environment, remember to activate it).
A port-in-use error appears when running a sample:
- Check that no other application is using the receive port on the SDK side.
- Specify a different port number explicitly with
ContactGloveClient(local_port=...). - To specify the source port, use
ContactGloveClient(send_port=...)or the--send-portoption ofsimple_receive.py.
License
The Melt Interface Technologies portions of this SDK are licensed under the Apache License, Version 2.0. The full text and copyright notice are included in the distribution:
doc/LICENSE.md
doc/NOTICE.mdThird-party dependencies retain their own license terms and are not relicensed under Apache-2.0. The python-osc notice and full license are included in the distribution:
doc/THIRD_PARTY_NOTICES.mdContact
For questions or bug reports about this SDK, use the contact form.