PDA

View Full Version : getPosition and getEuler using oculus with xbox or keyboard


bbb
01-12-2016, 08:25 AM
Hello,

I'm trying to find a function like viz.MainView.getPosition and
viz.MainView.getEuler for a combination of oculus DK2 with keyboard or xbox.

For example, if i have a link between oculus and keyboard like this:

# Key commands
KEYS = { 'forward' : viz.KEY_UP
,'back' : viz.KEY_DOWN
,'left' : viz.KEY_LEFT
,'right' : viz.KEY_RIGHT
,'reset' : 'r'
,'camera' : 'c'
,'help' : ' '
}
# Setup navigation node and link to main view
navigationNode = viz.addGroup()
viewLink = viz.link(navigationNode, viz.MainView)
viewLink.preMultLinkable(hmd.getSensor())

# Setup arrow key navigation
MOVE_SPEED = 2.0
def UpdateView():
yaw,pitch,roll = viewLink.getEuler()
m = viz.Matrix.euler(yaw,0,0)
dm = viz.getFrameElapsed() * MOVE_SPEED
if viz.key.isDown(KEYS['forward']):
m.preTrans([0,0,dm])
if viz.key.isDown(KEYS['back']):
m.preTrans([0,0,-dm])
if viz.key.isDown(KEYS['left']):
m.preTrans([-dm,0,0])
if viz.key.isDown(KEYS['right']):
m.preTrans([dm,0,0])
navigationNode.setPosition(m.getPosition(), viz.REL_PARENT)
vizact.ontimer(0,UpdateView)

how do i get position and orientation?

Thanks :)

bbb
01-12-2016, 08:34 AM
I mean how do i get x,y,z position and orientation? I need to write the changes in position and orientation every 0.1 ms into a file for analaysis.

haohaoxuexi1
01-12-2016, 01:14 PM
you can define a function to get the position of the sensor

and use "ontimer" to run the function every frame

the command should be getPosition and getEuler

hope it can help you

bbb
01-13-2016, 06:52 AM
Thanks for your answer, i thought about it myself but the problem with that as far
as i understand is it only give me position and orientation from the HMD sensor but not from keyboard/xbox movememt or HMD&keyboard/xbox movement togethere.