virtualreality
python side of hobo_vr
mainly used for writing posers
has many helpful utilities for positional tracking, serial/socket/bluetooth communication, etc.
has an async socket server
installation
to install the module, run the following command:
python -m pip install virtualreality
if you want to have camera based tracking, install it with the camera extra
python -m pip install virtualreality[camera]
to install the development version, do the following:
git clone https://github.com/okawo80085/hobo_vr
cd ./hobo_vr
python -m pip install -e .
quick example
import asyncio
import time
import numpy as np
from virtualreality import templates
class MyPoser(templates.PoserTemplate):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@templates.PoserTemplate.register_member_thread(1 / 100)
async def example_thread1(self):
'''moves the headset in a circle'''
h = 0
while self.coro_keep_alive["example_thread1"].is_alive:
try:
self.pose.x = np.sin(h)
self.pose.y = np.cos(h)
h += 0.01
await asyncio.sleep(self.coro_keep_alive["example_thread1"].sleep_delay)
except Exception as e:
print(f"example_thread1 failed: {e}")
break
self.coro_keep_alive["example_thread1"].is_alive = False
@templates.PoserTemplate.register_member_thread(1 / 100, runInDefaultExecutor=True)
def example_thread2(self):
'''moves the left controller up and down'''
h = 0
while self.coro_keep_alive["example_thread2"].is_alive:
try:
self.pose_controller_l.y = 1+np.cos(h*3)/5
h += 0.01
time.sleep(self.coro_keep_alive["example_thread2"].sleep_delay)
except Exception as e:
print(f"example_thread2 failed: {e}")
break
self.coro_keep_alive["example_thread2"].is_alive = False
poser = MyPoser()
asyncio.run(poser.main())
poser client example
import asyncio
import time
import numpy as np
from virtualreality import templates
poser = templates.PoserClient()
@poser.thread_register(1/60)
async def example_thread():
'''moves the headset in a circle'''
h = 0
while poser.coro_keep_alive["example_thread"].is_alive:
poser.pose.y = round(np.sin(h), 4)
poser.pose.x = round(np.cos(h), 4)
h += 0.01
await asyncio.sleep(poser.coro_keep_alive["example_thread"].sleep_delay)
@poser.thread_register(1/60, runInDefaultExecutor=True)
def example_thread2():
'''moves the controller up and down'''
while poser.coro_keep_alive["example_thread2"].is_alive:
poser.pose_controller_l.x = 1+np.cos(h*3)/5
time.sleep(poser.coro_keep_alive["example_thread2"].sleep_delay)
asyncio.run(poser.main())
udu poser client example
u - unlimited
d - devices
u - upgrade
buts its more like a mode
here is an example
"""
udu poser client example
more info: help(templates.UduPoserTemplate)
"""
import asyncio
import time
import numpy as np
import pyrr
from virtualreality import templates
from virtualreality.server import server
poser = templates.UduPoserClient("h c t")
# ^^^^^
# this dictates devices used
# for this example its:
# hmd controller tracker
# poser = templates.UduPoserClient("h c c") btw normal posers use this device configuration
@poser.thread_register(1 / 60)
async def example_thread():
# spins all devices in an orbit
h = 0
while poser.coro_keep_alive["example_thread"].is_alive:
x, y, z, w = pyrr.Quaternion.from_y_rotation(h)
for i in range(len(poser.poses)):
poser.poses[i].x = np.sin(h / (i + 1))
poser.poses[i].z = np.cos(h / (i + 1))
poser.poses[i].r_x = x
poser.poses[i].r_y = y
poser.poses[i].r_z = z
poser.poses[i].r_w = w
h += 0.01
await asyncio.sleep(poser.coro_keep_alive["example_thread"].sleep_delay)
# any poser can do this actually
@poser.thread_register(1 / 60)
async def example_receive_haptics_thread():
while poser.coro_keep_alive["example_receive_haptics_thread"].is_alive:
# check for new reads
if poser.last_read:
print (poser.last_read) # print received
poser.last_read = b"" # reset
await asyncio.sleep(poser.coro_keep_alive["example_receive_haptics_thread"].sleep_delay)
asyncio.run(poser.main())
unlike normal posers, udu posers generate pose structs on start
you then need use those pose structs as the value for DeviceManifestList in the driver config
more examples
there is also poser_3dof_hmd_only.py, its an udu poser with actual 3dof(hmd only) tracking(more info in the example itself)
Metadata
Release files for virtualreality 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| virtualreality-0.1.2.tar.gz | 46.1 kB | Without provenance | Details for virtualreality-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| virtualreality-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for virtualreality-0.1.2-py3-none-any.whl |
Total release size: 102.7 kB
Release files / virtualreality-0.1.2.tar.gz
| Download URL | virtualreality-0.1.2.tar.gz |
|---|---|
| Size | 46.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
635d453fe6f35bf6ae102951af83e3e08eb7a908cbf5e2c3eadfb690aefca029
|
|
BLAKE2b-256 checksum How to use checksums |
0300016f3a661716b5680d6acbfb7984bb59cb266695f561d4caf1b3a22eae50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5
|
Release files / virtualreality-0.1.2-py3-none-any.whl
| Download URL | virtualreality-0.1.2-py3-none-any.whl |
|---|---|
| Size | 56.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b3a9492730074e22b0f01c0751214152ef674c1b94f8f8c338896a911614ae4
|
|
BLAKE2b-256 checksum How to use checksums |
149de5c294566be3744f9264b53ba250725c14d5bb15dc0d10d25c2653742b8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5
|
Security for virtualreality 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.