View Single Post
  #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