WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-19-2012, 05:28 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Avatar mimicking after

Hi all,

I'm trying to make an avatar mimic the head movements of a participant with a delay of 4 seconds. In the code below, I'm writing the euler information of the viz.MainView to a file (1.log) and after 4 seconds, I'm trying to read from the beginning of that same file (thus creating a delay of 4 seconds). But after 4 seconds, I get an error message (IOError: [Errno 0] Error) and I think that's because I'm reading from the same file I'm writing to. I understand this could be problematic, but I don't know an other approach for my problem. Any help is greatly appreciated!

Regards,
Frank
Code:
import viz
import vizact
import viztask
import time

viz.go()

#CONSTANTS
PATH = '.\\'
PARTICIPANT = 1
TRACKING_DATA = open(PATH+str(PARTICIPANT)+".log", 'w+')
TIMER_SPEED = 0.1
SEC_DELAY = 4

def logTrackingData():
    orientation = viz.MainView.getEuler()
    data = str(orientation[0])+' '+str(orientation[1])+' '+str(orientation[2])+'\n'
    TRACKING_DATA.write(data)

def readTrackingData():
    rotation = TRACKING_DATA.readline()
    print rotation

def readWithDelay():
    #Wait 4 seconds
    yield viztask.waitTime(SEC_DELAY)
    vizact.ontimer(TIMER_SPEED, readTrackingData)

vizact.ontimer(TIMER_SPEED, logTrackingData)
viztask.schedule(readWithDelay())
Reply With Quote
  #2  
Old 04-19-2012, 07:03 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Would it work for you to save the data in a list and read it from there?
Reply With Quote
  #3  
Old 04-20-2012, 01:32 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Works like a charm, thanks Jeff! My solution consists of using three lists (one for yaw, pitch, and roll) which I append the current yaw, pitch, and roll to and start reading from the beginning after waiting 4 seconds. My only 'concern' now is that each list is growing with 10 floats/second, so they will get pretty big after a few minutes (my experiment will last around 10 to 15 minutes of mimicking I guess). Of course I could delete the information from the list after it has been read, but will the size of the lists pose any problem at all?
Reply With Quote
  #4  
Old 04-20-2012, 06:17 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
For anyone with the same problem, here's my solution I eventually used:
Code:
import viz
import vizact
import viztask

viz.go()

#CONSTANTS
TIMER_SPEED = 0.1
SEC_DELAY = 4

yaw_list = []
pitch_list = []
roll_list = [] 

def logTrackingData():
	orientation = viz.MainView.getEuler()
	yaw_list.append(orientation[0])
	pitch_list.append(orientation[1])
	roll_list.append(orientation[2])
	
def readTrackingData():
	global yaw, pitch, roll
	#Read information
	yaw = yaw_list[0]
	pitch = pitch_list[0]
	roll = roll_list[0]
	#Delete information already read
	yaw_list.pop(0)
	pitch_list.pop(0)
	roll_list.pop(0)

def readWithDelay():
	#Wait 4 seconds
	yield viztask.waitTime(SEC_DELAY)
	vizact.ontimer(TIMER_SPEED, readTrackingData)

vizact.ontimer(TIMER_SPEED, logTrackingData)
viztask.schedule(readWithDelay())
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
Avatar & Motion Capture Interface Angie Vizard 1 08-05-2010 06:17 PM
avatar scale and link.setpos conflict? sircedric4 Vizard 0 09-29-2009 07:48 AM
Collision of an avatar with a quad Frank Verberne Vizard 8 06-04-2008 09:44 AM
Looking through the eyes of an avatar Frank Verberne Vizard 2 04-01-2008 05:52 AM
How to make avatar's eyes to blink when speaking michelcm3 Vizard 12 01-15-2008 08:48 AM


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


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