WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-26-2016, 07:03 AM
bbb bbb is offline
Member
 
Join Date: Nov 2015
Posts: 46
question regarding viz.getpostion written into text file

Hey all,
I'm using vizard 5.3 for navigation test using Oculus rift Dk2(runtime 0.8) and xbox one controller. In order to calculate some measurements from the experiment we write every 100ms:

# Get the tracking data.
def getData(tracking_data, startTime):
orientation = viz.MainView.getEuler()
position = viz.MainView.getPosition()
timeStamp = viz.tick()
# Make a string out of the data.
data = 'orientation: ' + str(orientation) + '\t' + 'position: ' + str(position) + '\t' 'time: ' + str(timeStamp - startTime) + '\n'
# Write it to the tracking file.
tracking_data.write(data)

The loop runs 3 times(3 tries per day for this test), each time is a different trial(try) and it uses the getData function to write to text file(different text file for each trial).

trials = range(1, 4)

for i in trials:
# enable movement
walking_transport.setEnabled(viz.ON)
# disable orientation
ori_transport.setEnabled(viz.OFF)

# store the time at which this trial started
startTime = viz.tick()
tracking_data = open(participant_code + '_hidden_12X12 trackingDataTrial' + str(i) + '.txt', 'a')
expTimer = vizact.ontimer(0.1, getData, tracking_data, startTime)

Sometimes it writes more data to text files than should be. It seems like the time start from the begining over and over and the last time it start, that is the correct data (i have another text file that the time of each trial is written in it, that is why i know the last data is the correct one). Does anyone can tell me way is it happening?

Thanks in advence.
Reply With Quote
  #2  
Old 07-27-2016, 03:32 AM
Erikvdb Erikvdb is offline
Member
 
Join Date: May 2013
Posts: 63
I'm not entirely sure what you mean, and it's hard to read the code without indentations (please use the CODE tags next time), but could it be that you are not stopping the timer and closing the datafile after each trial? If that's the case, the timer for the first trial just keeps on writing data during the second and third trial; the timer for the second trial will keep on writing during the third, and only the last one will write just the data of the last trial.
Reply With Quote
  #3  
Old 08-23-2016, 11:54 PM
bbb bbb is offline
Member
 
Join Date: Nov 2015
Posts: 46
Hi Erik,
Sorry for the using indentation and thanks for your answer.
My problem apperent to be pretty simple:
I used 'a' for append instead of 'w' for writing so whenever the file name was existing my latest data was added to the same file creating long ones.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
input from a text file dig Vizard 5 10-20-2013 01:20 AM
Use saved text file data as replay sources problem mizutani_jun Vizard 4 10-14-2010 04:49 PM
problems with output to a text file within executable Saz Vizard 1 07-01-2009 11:01 AM
Read file....many issues Uttama_vizard Vizard 9 07-08-2008 02:16 PM
I cannot show wrl file with text node sled Vizard 3 06-25-2003 07:52 AM


All times are GMT -7. The time now is 01:50 PM.


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