WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

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


Is there any documentation for how to use grabhand and vizuniverse? I've found two references that mention it in passing:
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?

Reply With Quote
Old 10-03-2011, 04:30 PM
Gladsomebeast Gladsomebeast is offline
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.

import viz
viz.phys.enable() #must enable physics for grab to work
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

#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., localHand)

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

# Create local hand input object:
networkHandInput = hand.MultiInputSensor()
def onStartGrabFromNetworkEvent(): #called via network event callback, say viz.NETWORK_EVENT
def onEndGrabFromNetworkEvent(): #called via network event callback, say viz.NETWORK_EVENT
#create hand object
remoteHand = hand.add(networkHandInput)

# Get 3D position of remote hand
vrpn = viz.add('vrpn7.dle')
remoteHandTracker = vrpn.addTracker('Tracker0@localhost', 0), 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 (7.4 KB, 549 views)
Paul Elliott
WorldViz LLC
Reply With Quote
Old 10-04-2011, 05:34 AM
initionSteve initionSteve is offline
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,
Reply With Quote

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 10:50 AM.

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