def __init__(self): ovr.initialize(None) self.session, luid = ovr.create() hmdDesc = ovr.getHmdDesc(self.session) print "Servo client running" # Used for anti-shaking self.xtemp=0 self.ytemp=0 self.ztemp=0
recvSock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP recvSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) recvSock.setblocking(False) recvSock.bind((UDP_IP, UDP_RECV_UNITY_PORT)) sendSock = socket.socket( socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP ################################################## ###Initialize OVR######################### ovr.initialize(None) hmd, luid = ovr.create() hmdDesc = ovr.getHmdDesc(hmd) angularAcc = ovr.Vector3f(0, 0, 0) linearAcc = ovr.Vector3f(0, 0, 0) timeSec = 0 ########################################## dateToday = str(datetime.date.today()) Ts = 0.01 reset = False start = True latched = False elapsed = 0.0 experimentStart = 0.0 previousTime = unix.time() scenario = 0
def init(self): self.session, self.luid = ovr.create() self.hmdDesc = ovr.getHmdDesc(self.session)
# import the necessary packages import websocket import time import subprocess import ovr import sys import math ovr.initialize(None) session, luid = ovr.create() hmdDesc = ovr.getHmdDesc(session) print "Servo client running" def on_message(ws, message): print message def on_error(ws, error): print "### error: ###" print error def on_close(ws): print "### closed ###" ovr.destroy(session) ovr.shutdown() def on_open(ws): print "### opened ###" ws.send("main_client") # Used for anti-shaking xtemp=0 ytemp=0
''' Created on Oct 13, 2018 @author: maddo ''' import sys import time import ovr ovr.initialize(None) session, luid = ovr.create() hmdDesc = ovr.getHmdDesc(session) print(hmdDesc.ProductName) ts = ovr.getTrackingState(session, ovr.getTimeInSeconds(), True) if ts.StatusFlags & (ovr.Status_OrientationTracked | ovr.Status_PositionTracked): pose = ts.HeadPose for t in range(100): # Query the HMD for the current tracking state. ts = ovr.getTrackingState(session, ovr.getTimeInSeconds(), True) if ts.StatusFlags & (ovr.Status_OrientationTracked | ovr.Status_PositionTracked): pose = ts.HeadPose #print(pose.ThePose.Orientation.x) #ovr.Quatf = Orientation, ovr.Vector3f = Position #print(pose) nextupdown = pose.ThePose.Orientation.z nextleftright = pose.ThePose.Orientation.y print(nextupdown) print(nextleftright) sys.stdout.flush()
UDP_SEND_UNITY_PORT = 25003 UDP_RECV_UNITY_PORT = 25005 recvSock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP recvSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) recvSock.setblocking(False) recvSock.bind((UDP_IP, UDP_RECV_UNITY_PORT)) sendSock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP ################################################## ###Initialize OVR######################### ovr.initialize(None) hmd, luid = ovr.create() hmdDesc = ovr.getHmdDesc(hmd) angularAcc = ovr.Vector3f(0,0,0) linearAcc = ovr.Vector3f(0,0,0) timeSec = 0 ########################################## dateToday = str(datetime.date.today()) Ts = 0.01 reset = False start = False latched = True elapsed = 0.0 experimentStart = 0.0 previousTime = unix.time() scenario = 0 iterations = num_iterations
def start_tracker_app(): oscIdentifier = '/pyBinSim' ip = '127.0.0.1' port = 10000 nSources = 1 minAngleDifference = 5 if (len(sys.argv)) > 1: for i in range(len(sys.argv)): if (sys.argv[i] == '-port'): port = int(sys.argv[i + 1]) if (sys.argv[i] == '-ip'): ip = sys.argv[i + 1] if (sys.argv[i] == '-nSources'): nSources = int(sys.argv[i + 1]) if (sys.argv[i] == '-angleStep'): minAngleDifference = int(sys.argv[i + 1]) # Internal settings: positionVector = np.arange(360) positionVectorSubSampled = range(0, 360, minAngleDifference) # Create OSC client parser = argparse.ArgumentParser() parser.add_argument("--ip", default=ip, help="The ip of the OSC server") parser.add_argument("--port", type=int, default=port, help="The port the OSC server is listening on") args = parser.parse_args() client = udp_client.SimpleUDPClient(args.ip, args.port) # Create OVR session ovr.initialize(None) session, luid = ovr.create() hmdDesc = ovr.getHmdDesc(session) print(hmdDesc.ProductName) try: while 1: # Query the HMD for the current tracking state. ts = ovr.getTrackingState(session, ovr.getTimeInSeconds(), True) if ts.StatusFlags & (ovr.Status_OrientationTracked | ovr.Status_PositionTracked): pose = ts.HeadPose.ThePose yawRad, pitchRad, rollRad = pose.Orientation.getEulerAngles( axis1=1, axis2=0, axis3=2, rotate_direction=1, handedness=1) yaw = int(round(np.rad2deg(yawRad))) pitch = int(round(np.rad2deg(pitchRad))) roll = int(round(np.rad2deg(rollRad))) # Adjustment to desired global origin yaw = 360 - yaw if yaw > 360: yaw = yaw - 360 print(['YAW: ', yaw, ' PITCH: ', pitch, 'ROLL: ', roll]) for n in range(0, nSources): # round yaw to angle stepsize yaw = min(positionVectorSubSampled, key=lambda x: abs(x - yaw)) #channel valueOne valueTwo ValueThree valueFour valueFive ValueSix binSimParameters = [n, yaw, n, 0, 0, 0, 0] print([' Yaw: ', yaw]) client.send_message(oscIdentifier, binSimParameters) #print pose sys.stdout.flush() time.sleep(0.020) except KeyboardInterrupt: # Break if ctrl+c is pressed ovr.destroy(session) ovr.shutdown() print('Done')
def init(self): self.hmd, self.luid = ovr.create() self.hmdDesc = ovr.getHmdDesc(self.hmd)