WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-11-2010, 01:01 AM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
Unhappy Use saved text file data as replay sources problem

Hi.
I got problem using my saved data text file data as replay sources.
I took data from patriot as euler data and keyboard as my position data,and save this all in difference text file.
From this data,i want to make replay but i got some errors about strings.

I previously using matlab as my main sources and no problem using strings to make calculations but seems i cant do same thins in vizard.
Below is my commands.

openfile1=open('filename1.txt')

nposz=[]
for line in openfile1:
s=line.split()
nposz.append(s[0])

x=nposz[0]
y=nposz[162]
print x - y

I try to make easy calculation like above and this errors written in input/output window.

Traceback (most recent call last):
File "<string>", line 11, in ?
File "add_replay.py", line 217, in ?
print x - y
TypeError: unsupported operand type(s) for -: 'str' and 'str'

My question is how can i make calculation with this text data?
How can i use this data other than call it as strings?
I want to calculate the difference in every frame and use it as sources for my replay sources as below.

def replay(num):
n=0
while n<=162:
xposz=nposz[n+1]-nposz[n]
pos=viz.MainView.getPosition()
replay_data_pos=viz.MainView.setPosition(-44,1.8,pos(0)+xposz)
viz.callback(viz.TIMER_EVENT,replay)
viz.starttimer(0,.1,viz.FOREVER)

I dont want to make calculation in real time and i want to save in text data because want to use this data in future.
Is there some sources that i can read or explanations that i missed?
Really need help.
Thanks.
Reply With Quote
  #2  
Old 10-11-2010, 09:16 AM
masaki masaki is offline
Member
 
Join Date: Jan 2008
Posts: 63
Hello,

You need to convert your string data to int or float:
e.g.
nposz.append(float(s[0]))

Masaki
Reply With Quote
  #3  
Old 10-12-2010, 12:51 AM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
Thanks for the reply Masaki.
Yes it seems this is the function that i missed.
Thanks a lot.
Is there any sources or details i can read about calculation or related to this?
For now i searched just from this forum but it really great if someone can tell me the way to check all this command or function.
So i can study by myself and just asking when i not understand.

MJ
Reply With Quote
  #4  
Old 10-12-2010, 09:17 AM
masaki masaki is offline
Member
 
Join Date: Jan 2008
Posts: 63
The Python scripting language is open source so there is a ton of resources online. Vizard 3.0 uses Python 2.4. http://www.python.org/
Python and Vizard help docs are also included with Vizard, along with demos, tutorials, and examples. You might also want to also take a look at our "Teacher in a Book" - this is available from our downloads page.

Masaki
Reply With Quote
  #5  
Old 10-14-2010, 04:49 PM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
Thanks for the reply Masaki.
I already read all sections in "Teacher in a Book".
And from now i`ll take a look at resources online as my references.
Thanks again.

MJ
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
still problem with data from .exe file Saz Vizard 1 07-10-2009 10:12 AM
problems with output to a text file within executable Saz Vizard 1 07-01-2009 11:01 AM
writing joystick position to a data file Saz Vizard 3 12-17-2008 05:18 AM
Problem generating exe file Anfo Vizard 1 11-17-2008 04:21 PM
Flagging the Data Elittdogg Vizard 5 04-11-2008 11:40 AM


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


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