WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-03-2011, 08:07 AM
initionSteve initionSteve is offline
Member
 
Join Date: Sep 2011
Posts: 3
Vizuniverse and grabhand

Hi,

Is there any documentation for how to use grabhand and vizuniverse? I've found two references that mention it in passing:
http://kb.worldviz.com/articles/1517
http://docs.worldviz.com/vizard/viztracker_setup.htm
and nothing else.

My task is to create a multi-user grabbing environment without using a cluster. I was hoping that I could use two grabhands on a single pc, with both a local sensor and a remote sensor running over VRPN. I would then sync the views on both the local and remote PCs.

Is there an example of how to add create multiple grabhands from multiple sensors in a single instance of vizard?

Thanks
Steve
Reply With Quote
  #2  
Old 10-03-2011, 03:30 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Hello Steve,

Here is an example showing how to create 2 GrabHand objects. You'll see from the GrabHand constructor, it has 2 dependencies:
-- a list of 3D nodes with physics shapes to grab
-- A hand object
---- Hand objects depend on having a InputSensor object that detects user input

The first half of the code sets up a local GrabHand controlled by the mouse. The second half is a code outline for setting up a remotely controlled hand.

Code:
import viz
viz.go()
viz.phys.enable() #must enable physics for grab to work
viz.add('lab.osgb')
viz.MainView.setPosition([0, 1.8, -2])

#objects to grab
grabObjects = []
for i in range(10):
	box = viz.add('box.wrl', pos=[i/2.0, 1.7, i])
	box.collideBox() #must have physics shape to grab
	box.disable(viz.DYNAMICS) #no need for gravity
	box.grabbed = 0
	grabObjects.append(box)

#LOCAL HAND
#hand object that supplies user input: grabbing or not
import hand
mouseButtonControl = hand.MultiInputSensor(pinchButtons=[viz.MOUSEBUTTON_LEFT,viz.MOUSEBUTTON_RIGHT], fistButtons=[viz.MOUSEBUTTON_MIDDLE])
localHand = hand.add(mouseButtonControl)

#move hand position
import vizuniverse
handTracker = vizuniverse.VUTrackerMouse2D() #just a 3D node to supply position and orientation for hand.
viz.link(handTracker, localHand)

import GrabHand
GrabHand.GrabHand(grabObjects, localHand, springs=False) #springs only work on dynamics enabled physics shapes


#TODO FOR REMOTE HAND CONTROLLED VIA NETWORK
# Create local hand input object:
networkHandInput = hand.MultiInputSensor()
def onStartGrabFromNetworkEvent(): #called via network event callback, say viz.NETWORK_EVENT
	networkHandInput.startPinch()
def onEndGrabFromNetworkEvent(): #called via network event callback, say viz.NETWORK_EVENT
	networkHandInput.endPinch()
	
#create hand object
remoteHand = hand.add(networkHandInput)

# Get 3D position of remote hand
vrpn = viz.add('vrpn7.dle')
remoteHandTracker = vrpn.addTracker('Tracker0@localhost', 0)
viz.link(remoteHandTracker, remoteHand)

#create grabhand object
import GrabHand
GrabHand.GrabHand(grabObjects, remoteHand, springs=False) #springs only work on dynamics enabled physics shapes

WorldViz is still working to officially fold-in the two modules you mentioned so docs/examples are still sparse. Happy to provide more explanation if needed.

On the networking architecture side, I think your project is simple enough to just use a 'peer to peer' design where all clients hold the same representation of the world. The Tutorial:Networking in the Vizard help is an example of this. When world behavior is not deterministic, like with dynamic physics, then you should setup a client/server architecture. The viznet library in the install will help with this and I attached a zip with examples.
Attached Files
File Type: zip networking examples.zip (7.4 KB, 709 views)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #3  
Old 10-04-2011, 04:34 AM
initionSteve initionSteve is offline
Member
 
Join Date: Sep 2011
Posts: 3
Thanks Paul,

That's exactly what I needed. I was planning to follow the tutorial for this, so it's good to get confirmation that it's a good idea. It's also good to know where I should shift to the more complex architecture.

Thanks once again,
Steve
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


All times are GMT -7. The time now is 07:45 AM.


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