forcedimension-core


Nameforcedimension-core JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/EmDash00/forcedimension_core-python
SummaryUnofficial Python Bindings for the Force Dimension SDK
upload_time2023-11-07 00:43:24
maintainer
docs_urlNone
authorEmber Chow
requires_python>=3.8,<3.13
licenseLGPL-3.0
keywords forcedimension haptics bindings
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # forcedimension_core-python

![PyPI - Version](https://img.shields.io/pypi/v/forcedimension_core?logo=pypi)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/forcedimension_core?logo=python)  
[![tests](https://github.com/EmDash00/forcedimension_core-python/actions/workflows/tests.yml/badge.svg)](https://github.com/EmDash00/forcedimension_core-python/actions/workflows/tests.yml)
[![Coveralls branch](https://img.shields.io/coverallsCoverage/github/EmDash00/forcedimension_core-python?branch=main&logo=coveralls)](https://coveralls.io/github/EmDash00/forcedimension_core-python)
[![Read the Docs](https://img.shields.io/readthedocs/forcedimension-core-python-docs?logo=Read%20the%20Docs)](https://forcedimension-core-python-docs.readthedocs.io/en/v1.0.0/)  
[![PyPI - License](https://img.shields.io/pypi/l/forcedimension_core)](LICENSE)
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)

Want to do more with the Force Dimension SDK with less code? Also check out
the [experimental high level wrappers](https://github.com/EmDash00/forcedimension-python).

## Installation

v1.0.0 of the bindings bind Force Dimension SDK v3.16.0+. They are available through a PyPI package for Python 3.8+.

```
python3 -m pip install forcedimension-core
```

NumPy is an optional dependency which allows the usage of special NumPy style
[containers](https://forcedimension-core-python-docs.readthedocs.io/en/v1.0.0-dev/direct_copy_optimization.html).

```
python3 -m pip install "forcedimension-core[numpy]"
```


You will also need to install the Force Dimension SDK and setup any drivers
or udev rules. If you are unfamiliar with how to do this please refer to the
[detailed installation instructions](https://forcedimension-core-python-docs.readthedocs.io/en/latest/installation.html).

## About

This project aims to create unofficial Python bindings for the Force Dimension SDK's C/C++ API.

```py
import sys
from forcedimension_core import dhd
from forcedimension_core.dhd.os_independent import kbHit, kbGet

b = 5  # damping coefficient in [N][s]/[m]
k = 150  # spring constant in [N]/[m]

# Storage buffers
pos = [0.0, 0.0, 0.0]
v = [0.0, 0.0, 0.0]
f = [0.0, 0.0, 0.0]

# Try to open the first available device
if (ID := dhd.open()) == -1:
  print(f"Error: {dhd.errorGetLastStr()}")
  sys.exit(1)

if (name := dhd.getSystemName()) is not None:
  print(isinstance(name, str))  # prints "True"
  print(name)

# Run until button 0 is pressed (typically the center or only button)
# or q is pressed on the keyboard
try:
  while not (dhd.getButton(index=0) or (kbHit() and kbGet() == 'q')):
    # Try to get the position
    if (dhd.getPosition(out=pos) == -1):
      raise dhd.errno_to_exception(dhd.errorGetLast())(
        op=dhd.getPosition, ID=ID
      )

    # Try to get the velocity
    if (dhd.getLinearVelocity(out=v) == -1):
      raise dhd.errno_to_exception(dhd.errorGetLast())(
        op=dhd.getLinearVelocity, ID=ID
      )

    # Set the dynamics to be a spring-mass damper
    f[0] = -k * pos[0] - b * v[0]
    f[1] = -k * pos[1] - b * v[1]
    f[2] = -k * pos[2] - b * v[2]

    # Try to set the force
    if (dhd.setForce(f) == -1):
      raise dhd.errno_to_exception(dhd.errorGetLast())(
        op=dhd.setForce, ID=ID
      )
except Exception as ex:
    print(str(ex))
finally:
  # On error, close the device and gracefully exit
  dhd.close(ID)
  sys.exit(1)
```

## Licensing and Rights

This project is NOT directly associated with Force Dimension. It does NOT involve reverse-engineering or distribution
of proprietary code. Docstrings are lifted from the Force Dimension SDK documentation and revised to fit the Python bindings
with the express permission of Force Dimension.

The Python code itself is licensed under LGPLv3 for the benefit of public
research.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/EmDash00/forcedimension_core-python",
    "name": "forcedimension-core",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<3.13",
    "maintainer_email": "",
    "keywords": "forcedimension,haptics,bindings",
    "author": "Ember Chow",
    "author_email": "emberchow.business@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/97/0a/0acb0260cf6c2407db6b3f02a5441de559dde43ca3a9cf12a7b8b9a3fdca/forcedimension_core-1.0.0.tar.gz",
    "platform": null,
    "description": "# forcedimension_core-python\n\n![PyPI - Version](https://img.shields.io/pypi/v/forcedimension_core?logo=pypi)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/forcedimension_core?logo=python)  \n[![tests](https://github.com/EmDash00/forcedimension_core-python/actions/workflows/tests.yml/badge.svg)](https://github.com/EmDash00/forcedimension_core-python/actions/workflows/tests.yml)\n[![Coveralls branch](https://img.shields.io/coverallsCoverage/github/EmDash00/forcedimension_core-python?branch=main&logo=coveralls)](https://coveralls.io/github/EmDash00/forcedimension_core-python)\n[![Read the Docs](https://img.shields.io/readthedocs/forcedimension-core-python-docs?logo=Read%20the%20Docs)](https://forcedimension-core-python-docs.readthedocs.io/en/v1.0.0/)  \n[![PyPI - License](https://img.shields.io/pypi/l/forcedimension_core)](LICENSE)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)\n\nWant to do more with the Force Dimension SDK with less code? Also check out\nthe [experimental high level wrappers](https://github.com/EmDash00/forcedimension-python).\n\n## Installation\n\nv1.0.0 of the bindings bind Force Dimension SDK v3.16.0+. They are available through a PyPI package for Python 3.8+.\n\n```\npython3 -m pip install forcedimension-core\n```\n\nNumPy is an optional dependency which allows the usage of special NumPy style\n[containers](https://forcedimension-core-python-docs.readthedocs.io/en/v1.0.0-dev/direct_copy_optimization.html).\n\n```\npython3 -m pip install \"forcedimension-core[numpy]\"\n```\n\n\nYou will also need to install the Force Dimension SDK and setup any drivers\nor udev rules. If you are unfamiliar with how to do this please refer to the\n[detailed installation instructions](https://forcedimension-core-python-docs.readthedocs.io/en/latest/installation.html).\n\n## About\n\nThis project aims to create unofficial Python bindings for the Force Dimension SDK's C/C++ API.\n\n```py\nimport sys\nfrom forcedimension_core import dhd\nfrom forcedimension_core.dhd.os_independent import kbHit, kbGet\n\nb = 5  # damping coefficient in [N][s]/[m]\nk = 150  # spring constant in [N]/[m]\n\n# Storage buffers\npos = [0.0, 0.0, 0.0]\nv = [0.0, 0.0, 0.0]\nf = [0.0, 0.0, 0.0]\n\n# Try to open the first available device\nif (ID := dhd.open()) == -1:\n  print(f\"Error: {dhd.errorGetLastStr()}\")\n  sys.exit(1)\n\nif (name := dhd.getSystemName()) is not None:\n  print(isinstance(name, str))  # prints \"True\"\n  print(name)\n\n# Run until button 0 is pressed (typically the center or only button)\n# or q is pressed on the keyboard\ntry:\n  while not (dhd.getButton(index=0) or (kbHit() and kbGet() == 'q')):\n    # Try to get the position\n    if (dhd.getPosition(out=pos) == -1):\n      raise dhd.errno_to_exception(dhd.errorGetLast())(\n        op=dhd.getPosition, ID=ID\n      )\n\n    # Try to get the velocity\n    if (dhd.getLinearVelocity(out=v) == -1):\n      raise dhd.errno_to_exception(dhd.errorGetLast())(\n        op=dhd.getLinearVelocity, ID=ID\n      )\n\n    # Set the dynamics to be a spring-mass damper\n    f[0] = -k * pos[0] - b * v[0]\n    f[1] = -k * pos[1] - b * v[1]\n    f[2] = -k * pos[2] - b * v[2]\n\n    # Try to set the force\n    if (dhd.setForce(f) == -1):\n      raise dhd.errno_to_exception(dhd.errorGetLast())(\n        op=dhd.setForce, ID=ID\n      )\nexcept Exception as ex:\n    print(str(ex))\nfinally:\n  # On error, close the device and gracefully exit\n  dhd.close(ID)\n  sys.exit(1)\n```\n\n## Licensing and Rights\n\nThis project is NOT directly associated with Force Dimension. It does NOT involve reverse-engineering or distribution\nof proprietary code. Docstrings are lifted from the Force Dimension SDK documentation and revised to fit the Python bindings\nwith the express permission of Force Dimension.\n\nThe Python code itself is licensed under LGPLv3 for the benefit of public\nresearch.\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0",
    "summary": "Unofficial Python Bindings for the Force Dimension SDK",
    "version": "1.0.0",
    "project_urls": {
        "Changelog": "https://github.com/EmDash00/forcedimension_core-python/blob/main/CHANGELOG.md",
        "Documentation": "https://forcedimension-core-python-docs.readthedocs.io/en/v1.0.0/",
        "Homepage": "https://github.com/EmDash00/forcedimension_core-python",
        "Repository": "https://github.com/EmDash00/forcedimension_core-python"
    },
    "split_keywords": [
        "forcedimension",
        "haptics",
        "bindings"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "875aa381b6416eb351a88a074d6b0b49de73fa2e6f0db650f53965e29d77f5f0",
                "md5": "206f5818dd1565dd8de29821fbee6173",
                "sha256": "1b6b8e271a24c03a0fbc70164119b1ddd7dd7d70e1870eaf3a77e3d99b2822c5"
            },
            "downloads": -1,
            "filename": "forcedimension_core-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "206f5818dd1565dd8de29821fbee6173",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<3.13",
            "size": 64096,
            "upload_time": "2023-11-07T00:43:22",
            "upload_time_iso_8601": "2023-11-07T00:43:22.757409Z",
            "url": "https://files.pythonhosted.org/packages/87/5a/a381b6416eb351a88a074d6b0b49de73fa2e6f0db650f53965e29d77f5f0/forcedimension_core-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "970a0acb0260cf6c2407db6b3f02a5441de559dde43ca3a9cf12a7b8b9a3fdca",
                "md5": "7d2707640fa8c3db9f940a269f7a9c60",
                "sha256": "f10b5c01ed1bd271a64635be71859e97572dfc2ce9d85a02b703e003e9323254"
            },
            "downloads": -1,
            "filename": "forcedimension_core-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7d2707640fa8c3db9f940a269f7a9c60",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<3.13",
            "size": 57857,
            "upload_time": "2023-11-07T00:43:24",
            "upload_time_iso_8601": "2023-11-07T00:43:24.675939Z",
            "url": "https://files.pythonhosted.org/packages/97/0a/0acb0260cf6c2407db6b3f02a5441de559dde43ca3a9cf12a7b8b9a3fdca/forcedimension_core-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-07 00:43:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EmDash00",
    "github_project": "forcedimension_core-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "forcedimension-core"
}
        
Elapsed time: 3.33210s