Vizard 7 » Reference » Input Devices » Position and Orientation Trackers » Trackd
7.6

Trackd plug-in

This plug-in provides support for Trackd tracker and controller devices.

Initialization

The Trackd plug-in is implemented as a Vizard extension, with the following methods/constants:

Method

Description

<trackd>.addTracker(key,sensor=0)

Returns the tracker at the specified shared memory key. If the tracker supports multiple sensors, you can specify which sensor to return. If sensor is set to the <trackd>.SENSOR_ALL flag, then a list of all sensors at the specified key will be returned.

<trackd>.addController(key)

Returns the controller at the specified shared memory key.

<trackd>.SENSOR_ALL

Flag that can be passed as the sensor argument to the <trackd>.addTracker command, causing it to return all sensors on the specified key.

The Trackd tracker and controller objects are standard extension sensor objects. The tracker objects contain 6DOF position and orientation data. The controller objects provide raw data and button events.

Example

The following example shows how to create the Trackd extension:

trackd = viz.add('trackd.dle')

This example shows how to connect to 2 Trackd sensors at key 1000 and one sensor at key 1001:

sensor1 = trackd.addTracker(1000)
sensor2 = trackd.addTracker(1000,sensor=1)

sensor3 = trackd.addTracker(1001)

The next example shows how to connect to all Trackd sensors at key 4000 and print the position of each sensor:

sensors = trackd.addTracker(4000,sensor=trackd.SENSOR_ALL)

for s in sensors:
    print(s.getPosition())

The following code shows how to connect to a Trackd controller at key 2000, print the raw data, and handle button events from the controller:

controller = trackd.addController(2000)

#Print controller data
print(controller.getData())

#Handle controller button events
def onSensorDown(e):
    if e.object is controller:
        print('Button',e.button,'down')
viz.callback(viz.SENSOR_DOWN_EVENT,onSensorDown)

def onSensorUp(e):
    if e.object is controller:
        print('Button',e.button,'up')
viz.callback(viz.SENSOR_UP_EVENT,onSensorUp)