PDA

View Full Version : Temporal delay on movement


westbyb
03-14-2013, 04:26 PM
I was wondering if there was a way to delay the input sent for movement. I'm using vizcam.addWalkNavigate() to control my movement currently, and I was wondering if there was a way to have my movement be slightly delayed from my actual input, so that I can, for example, press the key to move forward and then a second or two later, the movement would actually occur.

Thanks in advance!

Jeff
03-15-2013, 06:49 AM
You could try something like the following:
import viz
import vizact
import vizcam

viz.go()

DELAY = 2
dojo = viz.add('dojo.osgb')
walkNav = vizcam.addWalkNavigate()

recordedData = []
def RecordTrackingData():
recordedData.append( (walkNav.getPosition(), walkNav.getQuat()) )
vizact.onupdate(0,RecordTrackingData)

def ApplyTrackingData():
pos,ori = recordedData.pop(0)
viz.MainView.setPosition([pos[0],1.8,pos[2]])
viz.MainView.setQuat(ori)

ApplyDataCallback = vizact.onupdate(0,ApplyTrackingData)
ApplyDataCallback.setEnabled(viz.OFF)

vizact.ontimer2(DELAY,0,ApplyDataCallback.setEnabl ed,viz.ON)

westbyb
05-21-2013, 03:20 PM
Fantastic! That worked for using addWalkNavigate, but I'm now using VRPN 7 to get location data, as such:

vrpn = viz.add('vrpn7.dle')
headPos = vrpn.addTracker( 'PPT0@'+PPT_MACHINE,0)
iLabs = viz.addExtension( 'inertiallabs.dle' )
headOri = iLabs.addSensorBus(port=INERTIALLABS_HEAD_PORT)[0]

I've tried subbing these values into the code that worked previously, but it's seeming that won't be possible. How should I go about implementing the same idea using vrpn?

Jeff
05-21-2013, 05:46 PM
Are you getting any errors? Can you post the code you tested with?

westbyb
05-23-2013, 02:41 PM
No errors, but here's the code I'm working with:

viztracker.go()
recordedData = []
def RecordTrackingData():
recordedData.append( (headPos.getPosition(), headOri.getQuat()) )
vizact.onupdate(0,RecordTrackingData)

def ApplyTrackingData():
pos,ori = recordedData.pop(0)
viz.MainView.setPosition([pos[0],1.8,pos[2]])
viz.MainView.setQuat(ori)

ApplyDataCallback = vizact.onupdate(0,ApplyTrackingData)
ApplyDataCallback.setEnabled(viz.OFF) #OFF

vizact.ontimer2(TIME_DELAY,0,ApplyDataCallback.set Enabled,viz.ON) #ON

I imagine that switching from viz.go() to viztracker.go() is what's causing the issue. I swapped viz.OFF/ON with viztracker.OFF/ON with no results.

Jeff
05-23-2013, 06:06 PM
The manual setting of the viewpoint in your script is overridden by the viewpoint link defined in the viztracker file. For this custom viewpoint movement its probably best to configure the trackers in this script and not use viztracker.