A minimalist Python wrapper for OpenHaptics
Project description
pyOpenHaptics
Python wrapper for the OpenHaptics HD library to use the haptic device directly from Python. Used to control the 3dSystems devices (Touch/Touch X) directly from Python.
Prerequisites
This library requires from the pre-installation of the OpenHaptics libraries and Touch X drivers. For this please follow their official installation tutorial for Linux or Windows.
OpenHaptics in Linux requires from additional libraries. You can use the following command to install them.
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install libncurses5-dev freeglut3 build-essential
Installation
Use the latest version from the PyPi project.
python3 -m pip install pyOpenHaptics
How to use it
The library contains multiple functionalities to get and set different variables. Most of the functionalities are gathered into 3 different files hd.py, hd_callback.py and hd_device.py. The first file contains a Python mimic of most of the OpenHaptics HD library main functions. The second file contains the schedulers and a python wrapper to wrap your python callback function into a C callback function to interact with the already compiled shared library. Lastly, this defines the Python class to initialize your Haptic hardware and interface.
Haptic device template
Here is a small template on how to setup your callback loop and your haptic device to gather the desired information from the device.
import pyOpenHaptics.hd as hd
from pyOpenHaptics.hd_callback import hd_callback
from pyOpenHaptics.hd_device import HapticDevice
from dataclasses import dataclass
# Data class to keep track of the device state and use it in other parts of the code
@dataclass
class DeviceState:
# Define the variables you want to safe here
# Callback to gather the device state
@hd_callback
def device_callback():
# Make the device_state global to be accesed in other parts of the code
global device_state
# your callback function, gather the different variables on the device
# YOUR CODE HERE
if __name__ == "__main__":
# Initialize the data class
device_state = DeviceState()
# Initialize the haptic device and the callback loop
device = HapticDevice(callback = device_callback, scheduler_type="async")
# YOUR CODE HERE
# Close the device to avoid segmentation faults
device.close()
You can find more complex examples here
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyopenhaptics-1.0.1.tar.gz.
File metadata
- Download URL: pyopenhaptics-1.0.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18e310dc94dfb561ba2dc32e77102776d250b7521cb12784fa8445a968c79f41
|
|
| MD5 |
a7f96cdae3dc60bcfd8288f35db363dc
|
|
| BLAKE2b-256 |
9ff64ca6cf37a55abd0b09c6d8a15fa3b60810ea8f5f6d25fe0ac7d8438f062b
|
File details
Details for the file pyopenhaptics-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pyopenhaptics-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13975e926723dd54b5def5038e29f0b23ca9b4b6d5f7b22962d70c55178c14ef
|
|
| MD5 |
853a9256981c918e2d76c0989efbe646
|
|
| BLAKE2b-256 |
7484d8f74684e83ca4f7c375b9b6a1464ea8d2b7439a63e91b023f627695d68a
|