Vizard 7 » Tutorials & Examples » Hardware » 5DT data gloves » Tutorial: 5DT data gloves
7.6

Tutorial: 5DT data gloves

This tutorial will show you how to use a 5DT data glove to add hand movement to your Vizard worlds.

This content is discussed in more detail in the reference section.

Getting your glove working

If you have trouble getting the code in this tutorial to work, you can find the complete example script handTracking.py in the \tutorials\hardware directory.

 

To get your data glove up and running, plug it in and add the script below. The Vizard hand module provides a model of a hand and uses the data from the 5DT sensor to animate that hand.

import viz
import vizact
import hand

viz.setMultiSample(4)
viz.fov(60)
viz.go()

#Identify the data glove's port.
PORT_5DT_USB = 0

#Add the 5DT sensor
sensor = viz.addSensor('5dt.dls')

#Create a hand object from the data glove
glove = hand.add(sensor,hand.GLOVE_5DT)

#Place the hand in front of the user
glove.setEuler([0,-90,0])
viz.MainView.setPosition([0,0.02,-0.4])

Run the script and you should see your moving hand.

 

The 5DT sensor also identifies various hand gestures and returns a unique numerical id number for each of those gestures. Let's add some code that pulls in those values from the sensor and then prints the name of the corresponding gestures. Add the following to your script:

#Add an array with all the gesture names from the 5DT user's manual.
gestureName = ['Fist', 'Index finger point', 'Middle finger point',
'Two finger point', 'Ring finger point', 'Ring-Index finger point',
'Ring-middle finger point', 'Three finger point', 'Little finger point',
'Index and little finger point', 'Little-middle finger point',
'Not ring finger point', 'Little-ring finger point',
'Not middle finger point', 'Not index finger point',
'Flat hand', 'Undefined']

gestureText = viz.addText( '', viz.SCREEN )
gestureText.setPosition(0.5,0.1)
gestureText.alignment(viz.ALIGN_CENTER)

def getGesture():
    gesture = int(sensor.get()[-1])
    gestureText.message(gestureName[gesture])

vizact.ontimer(0, getGesture)

Getting your glove working

A bird in the hand