WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Controller Coordinates and Euler angles (https://forum.worldviz.com/showthread.php?t=5843)

biomech_dave 09-09-2016 04:12 PM

Controller Coordinates and Euler angles
 
Hello! I'm using the Vive for proprioceptive reseach and need to get the coordinates of the controllers. I am new to Python but I tried manipulating the steamvr example like this:

import viz
import vizact
import vizshape
import steamvr

for controller in steamvr.getControllerList():
print "connected"
total = 0
if total == 0:
left_controller = controller
total += 1
else:
right_controller = controller

print right_controller.getPosition()

I get an error that 'right_controller' is not defines. I'd like to get the Euler angle and position output continuously while the programming is running. Any thoughts would be helpful.

Thanks!
Dave

Jeff 09-10-2016 02:09 AM

If both controllers are connected, try the following:

Code:

rightController = steamvr.getControllerList()[0]
leftController = steamvr.getControllerList()[1]

def printData():
        print 'pos right:',rightController.getPosition()
        print 'pos left :',leftController.getPosition()
       
vizact.onupdate(0,printData)

However, I would recommend using vizconnect to connect to the Vive in Vizard. In the preset configuration list there is a 'HTC Vive' option. That connects to all hardware and renders a hand for each controller. The transport allows you to navigate using the controller track pad. You can also get the controller position in your own script:

Code:

rightTracker = vizconnect.getTracker('r_hand_tracker').getRaw()
leftTracker = vizconnect.getTracker('l_hand_tracker').getRaw()

def printData():
        print 'pos right:',rightTracker.getPosition()
        print 'pos left :',leftTracker.getPosition()
       
vizact.onupdate(0,printData)


biomech_dave 09-12-2016 04:25 PM

Great! That helped a lot! I also have the code for the module generated by vizconnect which will help.

Thanks again for the really quick reply.

Cheers,


All times are GMT -7. The time now is 02:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC