Skip to main content

Taika asynchronous client library for Python

Project description

aiotaika

Documentation Status Latest PyPI release Supported Python versions

Taika asynchronous client library for Python

This library provides a very intuitive API for developers to easily create Python applications for Taika Tech's Spatial User Interface (SUI). With SUI, you can program actions to your physical environment, which are triggered based on location, orientation, and/or gesture data coming from a Taika Ring or Taika Tag.

You can find aiotaika's documentation from Read the Docs.

Basic Examples

For more examples, see examples folder of the repository.

Callback Example

In this example, we subscribe to move events and gesture events of ring ID 3. In the callback function, we track the latest position and when a gesture event happens, we print out which gesture was made with the latest location data.

With callbacks one can register one or more callbacks to a single callback function. However, the Event type must be a parent class of all incoming event objects in that callback function. Here RingGestureEvent and RingMoveEvent inherit from RingEvent.

import asyncio

from aiotaika import TaikaClient
from aiotaika.events import EventType
from aiotaika.ring import RingGestureEvent, RingMoveEvent

Vector3 last_position

async def my_callback(event: RingEvent) -> None:
    if isinstance(event, RingMoveEvent):
        last_position = event.position
    elif isinstance(event, RingGestureEvent):
        print(f"{event.gesture} in position {last_position}")


async def main() -> None:
    async with TaikaClient(
        host="127.0.0.1", username="root", password=""
    ) as taika:
        rings = taika.rings
        for key, ring in rings.items():
            print("{}: {}".format(key, ring.metadata))
        await rings[3].register_event_cb(EventType.RING_MOVE_EVT, my_callback)
        await rings[3].register_event_cb(EventType.RING_GESTURE_EVT, my_callback)
        await asyncio.sleep(5)


try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass

Asynchronous Generator Example (no callbacks!)

This example shows simply how all the incoming events can be handled via the events AsyncGenerator of the TaikaClient class. In this example, we simply print out a ring's name and position when a RingMoveEvent happens.

import asyncio

from aiotaika import TaikaClient
from aiotaika.ring import RingMoveEvent

async def main() -> None:
    async with TaikaClient(
        host="127.0.0.1", username="root", password=""
    ) as taika:
        async with taika.events() as events:
            async for event in events:
                if isinstance(event, RingMoveEvent):
                    print(f"Ring {event.metadata.name} position:")
                    print(f"x: {event.position.x}, z: {event.position.z}")
                    print(f"height: {event.position.y}")


try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass

Requirements:

Hardware

  • Taika Development Kit

Software

Note: these should be automatically satisfied if aiotaika is installed via pip.

You can find precise version requirements from pyproject.toml

  • Python
  • asyncio-mqtt
  • aiomysql

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

aiotaika-0.1.2.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

aiotaika-0.1.2-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file aiotaika-0.1.2.tar.gz.

File metadata

  • Download URL: aiotaika-0.1.2.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for aiotaika-0.1.2.tar.gz
Algorithm Hash digest
SHA256 51494f6f4c01064d50bec55be5ede5a4e293726f53ca62ac1479a21876919555
MD5 8d366599c36d1d4a0f5dd7239ec1d49e
BLAKE2b-256 462da3f9aeeca39126e40292298e738141213d9fbbdd4c2bbed5778fcb167f22

See more details on using hashes here.

File details

Details for the file aiotaika-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aiotaika-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for aiotaika-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 641eed4ee168d7508ce467730153e1af9cbe7fa5e9f5f2d78fce1ebaccd8313a
MD5 7e136c641a7db5fe27f426487871fe2a
BLAKE2b-256 c2644836f42f3dbb1ad85ddb2355b24e556c8c0ae25356408690cb2a27cfb409

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