PDA

View Full Version : linking viewpoint to viz.node


dcnieho
11-03-2014, 02:00 AM
Some background first:
I have a project in which the mainview is linked to 6DOF data recorded when walking with HMD. There are some transforms in between the data from the tracker and the position/orientation in the virtual world, implemented with pre and post actions on the link.
The 6DOF data from the tracker as well as transformed to the virtual world are stored to file.

Now, I'd like to replay this data. So simply use the stored tracker position/orientation data as input to the link transform chain to generate the same frames/views as during previous walking (there are other things going on in the code, changing as little as possible by simply providing fake/replayed tracker data is the best solution to implement what I want). I thought I could easily do this by simply using an empty node (viz.addGroup()), setting its position and orientation each frame and using that in place of the tracker linkable as source for the link with mainview. However, the orientation data is ignored, that is, the mainview is oriented always as if all input orientation data is 0.


trackerLinkable = viz.addGroup()
fileReader = MatFileReader()
vizact.onupdate(viz.PRIORITY_PLUGINS,fileReader.ge tNextRealPosOri,trackerLinkable) # see below for relevant bits

headLink = viz.link(headTrack, viz.MainView)
vizact.onupdate(viz.PRIORITY_PLUGINS+2,headLink.up date) # viz.PRIORITY_PLUGINS+1 reserved
#headLink.postEuler(), etc...

class MatFileReader():
def getNextRealPosOri(self,output=None):
# get next rawPos and rawOri from loaded file
if output is not None:
output.setPosition(rawPos)
output.setEuler(rawOri)
print (output.getPosition(),output.getEuler()) # prints what is expected. e.g. getMatrix() also looks right
So above works as expected for as far as I can debug it, but it seems the orientation information is lost somewhere along the way. when I do

print (viz.MainView.getPosition(),viz.MainView.getEuler( ))
I get [0,0,0] from getEuler.

A second problem I have is that this appears to run at 30 Hz instead of 60. Am I doing something very suboptimal causing the slowdown?

What have I forgotten? Is there a better way to implement something like this?

Thank you!

dcnieho
11-03-2014, 03:13 AM
I can no longer edit my post, but I have fixed the problem of orientation data disappearing. Now it is just left to wondering what is so suboptimal about what I'm doing that I achieve only 30 fps, and wondering whether there is a better way to implement such a data replay.

Thanks again!

Jeff
11-04-2014, 12:38 PM
Does the 30 fps only happen when you're playing back the data from file or also during recording? Have you tried reading the data using a director function (http://docs.worldviz.com/vizard/#Director_basics.htm) or storing in a list before playback.

dcnieho
11-04-2014, 06:35 PM
Hi Jeff,

Thanks for the suggestions. Data is recorded at 60 fps, and also i have not implemented any throttling to mimic the recorded timestamps of each frame. It should simply play v-synced. I do read the file to memory first into a 2d numpy array and then return one row from there at a time, getting the six values.

I am not sure how it would work with the director function. i use the scheduling and plenty of yields for the experiment logic, while behind the scene updating each frame is taking care of the data coming in, as I believe happens for real tracker sources as well. More importantly, with the director function, would i be able to specify with what priority the function gets called? It needs to be called at viz.PRIORITY_PLUGINS as the links further leading to an updated mainview run at viz.PRIORITY_PLUGINS+1 and viz.PRIORITY_PLUGINS+2.

All that said, it seems there were some other parts of the program that could be done more efficiently and now things appear to run smoothly most of the time.

Thanks a lot, for thinking along and the suggestions!
Dee