Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
wwwtyro's avatar
wwwtyro
Honored Guest
11 years ago

Linux support added to python-ovrsdk.

Link: http://www.tyrovr.com/2014/06/02/python-ovrsdk.html

example:

    
import time
from ovrsdk import *

ovr_Initialize()
hmd = ovrHmd_Create(0)
hmdDesc = ovrHmdDesc()
ovrHmd_GetDesc(hmd, byref(hmdDesc))
print hmdDesc.ProductName
ovrHmd_StartSensor( \
hmd,
ovrSensorCap_Orientation |
ovrSensorCap_YawCorrection,
0
)

while True:
ss = ovrHmd_GetSensorState(hmd, ovr_GetTimeInSeconds())
pose = ss.Predicted.Pose
print "%10f %10f %10f %10f" % ( \
pose.Orientation.w,
pose.Orientation.x,
pose.Orientation.y,
pose.Orientation.z
)
time.sleep(0.016)


output:

Oculus Rift DK1
1.000000 0.000000 0.000000 0.000000
0.992197 0.124599 -0.000122 0.004537
0.992192 0.124621 0.000212 0.004909
0.992168 0.124852 0.000430 0.003814
0.992249 0.124183 -0.000085 0.004583
0.992164 0.124768 0.000595 0.006597
0.992263 0.124067 -0.000134 0.004630
0.992276 0.123989 0.000412 0.003885
0.992275 0.123943 0.000745 0.005242
0.992168 0.124891 0.001882 0.001237
0.992377 0.123240 -0.000291 0.000687
0.992316 0.123698 -0.000632 0.002837
0.991962 0.126352 0.000245 0.006768

3 Replies

  • You may wish to take a look at my fork here. I've made a number of changes to the code.


    • Renamed the package to 'oculusvr'

    • Renamed the mapped ovr structure types to be more GL/python-like: ovrMatrix4f becomes mat4, ovrHmdDesc becomes hmd_desc, etc

    • Consolidated the python code into a single file in the top level package __init__.py. Your windows/wrapper.py and linux/wrapper.py are nearly identical. There's not much point in keeping them as separate files

    • Added the DLL's I've built for my Java bindings, which includes 32 and 64 bit dlls for windows and 64 bit dlls for Linux and OSX.

    • Added the proper license file, since generated code based off the Oculus headers would be covered under the same license as the Oculus SDK itself.

    • Added a friendly wrapper class Rift, which lets you have access to all the functionality with a more python-like interface. Many of the functions in the C API are mapped with reasonable default values. See the sample below.


    My updated example code looks like this:


    import time
    from oculusvr import Rift

    Rift.initialize()

    rift = Rift()
    time.sleep(0.1)
    rift.start_sensor()
    hmdDesc = rift.get_desc()
    print hmdDesc.ProductName
    print hmdDesc.MaxEyeFov[0].UpTan


    while True:
    ss = rift.get_sensor_state()
    pose = ss.Predicted.Pose
    print "%10f %10f %10f %10f" % ( \
    pose.Orientation.w,
    pose.Orientation.x,
    pose.Orientation.y,
    pose.Orientation.z
    )
    time.sleep(0.5)

    rift.destroy()
    rift = None
    Rift.shutdown()
  • mrnitro's avatar
    mrnitro
    Honored Guest
    Look very interesting!
    I did not look into oculus / python connection yet , is there some 3d framework that can be used with your wrapper?

    keep up the good work!:)
  • wwwtyro's avatar
    wwwtyro
    Honored Guest
    "mrnitro" wrote:
    Look very interesting!
    I did not look into oculus / python connection yet , is there some 3d framework that can be used with your wrapper?

    keep up the good work!:)


    I've used pyglet with it in the past, and things went swimmingly. I believe there are a number of people working on more modern solutions, but I am am unaware of anything that has yet come to fruition.