python side of hobo_vr
Project description
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
to install the development version, do the following:
git clone https://github.com/okawo80085/hobo_vr
cd ./hobo_vr
python setup.py install --user
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())
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
virtualreality-0.0.3.tar.gz
(36.4 kB
view hashes)
Built Distribution
Close
Hashes for virtualreality-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 096777038115cd0360d3337b12b5786bb1e7294d2f8baec40a356b6415e73f5d |
|
MD5 | 95fe338af55a855487315247946e1fd6 |
|
BLAKE2b-256 | 451facda38b64d50751688a10d5aa58798525f66041ae408da73d54db2373ec3 |