Package: virtualreality
virtualrealitypython side ofhobo_vrmainly used for writing posershas many helpful utilities for positional tracking, serial/socket/bluetooth communication, etc.has an async socket serverinstallationto install the module, run the following command:python -m pip install virtualrealityif you want to have camera based tracking, install it with thecameraextrapython -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 exampleimportasyncioimporttimeimportnumpyasnpfromvirtualrealityimporttemplatesclassMyPoser(templates.PoserTemplate):def__init__(self,*args,**kwargs):super().__init__(*args,**kwargs)@templates.PoserTemplate.register_member_thread(1/100)asyncdefexample_thread1(self):'''moves the headset in a circle'''h=0whileself.coro_keep_alive["example_thread1"].is_alive:try:self.pose.x=np.sin(h)self.pose.y=np.cos(h)h+=0.01awaitasyncio.sleep(self.coro_keep_alive["example_thread1"].sleep_delay)exceptExceptionase:print(f"example_thread1 failed:{e}")breakself.coro_keep_alive["example_thread1"].is_alive=False@templates.PoserTemplate.register_member_thread(1/100,runInDefaultExecutor=True)defexample_thread2(self):'''moves the left controller up and down'''h=0whileself.coro_keep_alive["example_thread2"].is_alive:try:self.pose_controller_l.y=1+np.cos(h*3)/5h+=0.01time.sleep(self.coro_keep_alive["example_thread2"].sleep_delay)exceptExceptionase:print(f"example_thread2 failed:{e}")breakself.coro_keep_alive["example_thread2"].is_alive=Falseposer=MyPoser()asyncio.run(poser.main())poser client exampleimportasyncioimporttimeimportnumpyasnpfromvirtualrealityimporttemplatesposer=templates.PoserClient()@poser.thread_register(1/60)asyncdefexample_thread():'''moves the headset in a circle'''h=0whileposer.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.01awaitasyncio.sleep(poser.coro_keep_alive["example_thread"].sleep_delay)@poser.thread_register(1/60,runInDefaultExecutor=True)defexample_thread2():'''moves the controller up and down'''whileposer.coro_keep_alive["example_thread2"].is_alive:poser.pose_controller_l.x=1+np.cos(h*3)/5time.sleep(poser.coro_keep_alive["example_thread2"].sleep_delay)asyncio.run(poser.main())udu poser client exampleu - unlimited
d - devices
u - upgradebuts its more like a modehere is an example"""udu poser client examplemore info: help(templates.UduPoserTemplate)"""importasyncioimporttimeimportnumpyasnpimportpyrrfromvirtualrealityimporttemplatesfromvirtualreality.serverimportserverposer=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)asyncdefexample_thread():# spins all devices in an orbith=0whileposer.coro_keep_alive["example_thread"].is_alive:x,y,z,w=pyrr.Quaternion.from_y_rotation(h)foriinrange(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=xposer.poses[i].r_y=yposer.poses[i].r_z=zposer.poses[i].r_w=wh+=0.01awaitasyncio.sleep(poser.coro_keep_alive["example_thread"].sleep_delay)# any poser can do this actually@poser.thread_register(1/60)asyncdefexample_receive_haptics_thread():whileposer.coro_keep_alive["example_receive_haptics_thread"].is_alive:# check for new readsifposer.last_read:print(poser.last_read)# print receivedposer.last_read=b""# resetawaitasyncio.sleep(poser.coro_keep_alive["example_receive_haptics_thread"].sleep_delay)asyncio.run(poser.main())unlike normal posers, udu posers generate pose structs on startyou then need use those pose structs as the value forDeviceManifestListin the driver configmore info on udumore exampleshobo_vr's examplesthere is alsoposer_3dof_hmd_only.py, its an udu poser with actual 3dof(hmd only) tracking(more info in the example itself)