Welcome to Qualisys SDK for Python’s documentation!

This document describes the Qualisys SDK for Python version 3.0.2

NOTE: Major versions introduces breaking changes. More info…

Installation:

This package is a pure python package and requires at least Python 3.5.3, the easiest way to install it is:

python -m pip install qtm-rt

Example usage:

The following code demonstrates how to stream 3D markers from QTM. To keep the code short, it assumes that QTM is already streaming data, either live or RT from file.

"""
    Minimal usage example
    Connects to QTM and streams 3D data forever
    (start QTM first, load file, Play->Play with Real-Time output)
"""

import asyncio
import qtm_rt


def on_packet(packet):
    """ Callback function that is called everytime a data packet arrives from QTM """
    print("Framenumber: {}".format(packet.framenumber))
    header, markers = packet.get_3d_markers()
    print("Component info: {}".format(header))
    for marker in markers:
        print("\t", marker)


async def setup():
    """ Main function """
    connection = await qtm_rt.connect("127.0.0.1")
    if connection is None:
        return

    await connection.stream_frames(components=["3d"], on_packet=on_packet)


if __name__ == "__main__":
    asyncio.ensure_future(setup())
    asyncio.get_event_loop().run_forever()

QTM RT Protocol

An instance of QRTConnection is returned when qtm_rt.connect successfully connects to QTM.

Functions marked as async need to be run in a async function and awaited, please see example above.

async qtm_rt.connect(host, port=22223, version='1.25', on_event=None, on_disconnect=None, timeout=5, loop=None) QRTConnection

Async function to connect to QTM

Parameters:
  • host – Address of the computer running QTM.

  • port – Port number to connect to, should be the port configured for little endian.

  • version – Version of the rt protocol to use. Default is the latest version. The Qualisys Python sdk does not support versions older than 1.8.

  • on_disconnect – Function to be called when a disconnect from QTM occurs.

  • on_event – Function to be called when there’s an event from QTM.

  • timeout – The default timeout time for calls to QTM.

  • loop – Alternative event loop, will use asyncio default if None.

Return type:

A QRTConnection

QRTConnection

class qtm_rt.QRTConnection(protocol: QTMProtocol, timeout)

Represent a connection to QTM.

Returned by connect() when successfuly connected to QTM.

disconnect()

Disconnect from QTM.

has_transport()

Check if connected to QTM

async qtm_version()

Get the QTM version.

async byte_order()

Get the byte order used when communicating (should only ever be little endian using this library).

async get_state()

Get the latest state change of QTM. If the connect() on_event callback was set the callback will be called as well.

Return type:

A qtm_rt.QRTEvent

async await_event(event=None, timeout=30)

Wait for an event from QTM.

Parameters:
  • event – A qtm_rt.QRTEvent to wait for a specific event. Otherwise wait for any event.

  • timeout – Max time to wait for event.

Return type:

A qtm_rt.QRTEvent

async get_parameters(parameters=None)

Get the settings for the requested component(s) of QTM in XML format.

Parameters:

parameters – A list of parameters to request. Could be ‘all’ or any combination of ‘general’, ‘3d’, ‘6d’, ‘analog’, ‘force’, ‘gazevector’, ‘eyetracker’, ‘image’, ‘skeleton’, ‘skeleton:global’, ‘calibration’.

Return type:

An XML string containing the requested settings. See QTM RT Documentation for details.

async get_current_frame(components=None) QRTPacket

Get measured values from QTM for a single frame.

Parameters:

components – A list of components to receive, could be any combination of ‘2d’, ‘2dlin’, ‘3d’, ‘3dres’, ‘3dnolabels’, ‘3dnolabelsres’, ‘analog’, ‘analogsingle’, ‘force’, ‘forcesingle’, ‘6d’, ‘6dres’, ‘6deuler’, ‘6deulerres’, ‘gazevector’, ‘eyetracker’, ‘image’, ‘timecode’, ‘skeleton’, ‘skeleton:global’

Return type:

A qtm_rt.QRTPacket containing requested components

async stream_frames(frames='allframes', components=None, on_packet=None)
Stream measured frames from QTM until stream_frames_stop()

is called.

Parameters:
  • frames – Which frames to receive, possible values are ‘allframes’, ‘frequency:n’ or ‘frequencydivisor:n’ where n should be desired value.

  • components – A list of components to receive, could be any combination of ‘2d’, ‘2dlin’, ‘3d’, ‘3dres’, ‘3dnolabels’, ‘3dnolabelsres’, ‘analog’, ‘analogsingle’, ‘force’, ‘forcesingle’, ‘6d’, ‘6dres’, ‘6deuler’, ‘6deulerres’, ‘gazevector’, ‘eyetracker’, ‘image’, ‘timecode’, ‘skeleton’, ‘skeleton:global’

Return type:

The string ‘Ok’ if successful

async stream_frames_stop()

Stop streaming frames.

async take_control(password)

Take control of QTM.

Parameters:

password – Password as entered in QTM.

async release_control()

Release control of QTM.

async new()

Create a new measurement.

async close()

Close a measurement

async start(rtfromfile=False)

Start RT from file. You need to be in control of QTM to be able to do this.

async stop()

Stop RT from file.

async load(filename)

Load a measurement.

Parameters:

filename – Path to measurement you want to load.

async save(filename, overwrite=False)

Save a measurement.

Parameters:
  • filename – Filename you wish to save as.

  • overwrite – If QTM should overwrite existing measurement.

async load_project(project_path)

Load a project.

Parameters:

project_path – Path to project you want to load.

async trig()

Trigger QTM, only possible when QTM is configured to use Software/Wireless trigger

async set_qtm_event(event=None)

Set event in QTM.

async send_xml(xml)

Used to update QTM settings, see QTM RT protocol for more information.

Parameters:

xml – XML document as a str. See QTM RT Documentation for details.

async calibrate(timeout=600)

Start calibration and return calibration result.

Parameters:

timeout – Calibration timeout.

Return type:

An XML string containing the calibration result. See QTM RT Documentation for details.

QRTPacket

class qtm_rt.QRTPacket(data)

Packet containing data measured with QTM.

Too check for existence of a specific component in a packet:

from qtm_rt.packet import QRTComponentType
if QRTComponentType.Component3d in packet.components:
    header, markers = packet.get_3d_markers()

Component retriever functions will return None if a component is not in the packet.

get_analog(component_info=None, data=None, component_position=None)

Get analog data.

get_analog_single(component_info=None, data=None, component_position=None)

Get a single analog data channel.

get_force(component_info=None, data=None, component_position=None)

Get force data.

get_force_single(component_info=None, data=None, component_position=None)

Get a single force data channel.

get_6d(component_info=None, data=None, component_position=None)

Get 6D data.

get_6d_residual(component_info=None, data=None, component_position=None)

Get 6D data with residual.

get_6d_euler(component_info=None, data=None, component_position=None)

Get 6D data with euler rotations.

get_6d_euler_residual(component_info=None, data=None, component_position=None)

Get 6D data with residuals and euler rotations.

get_image(component_info=None, data=None, component_position=None)

Get image.

get_3d_markers(component_info=None, data=None, component_position=None)

Get 3D markers.

get_3d_markers_residual(component_info=None, data=None, component_position=None)

Get 3D markers with residual.

get_3d_markers_no_label(component_info=None, data=None, component_position=None)

Get 3D markers without label.

get_3d_markers_no_label_residual(component_info=None, data=None, component_position=None)

Get 3D markers without label with residual.

get_2d_markers(component_info=None, data=None, component_position=None, index=None)

Get 2D markers.

Parameters:

index – Specify which camera to get 2D from, will be returned as first entry in the returned array.

get_2d_markers_linearized(component_info=None, data=None, component_position=None, index=None)

Get 2D linearized markers.

Parameters:

index – Specify which camera to get 2D from, will be returned as first entry in the returned array.

get_skeletons(component_info=None, data=None, component_position=None)

Get skeletons

get_gaze_vectors(component_info=None, data=None, component_position=None)

Get gaze vectors

get_eye_trackers(component_info=None, data=None, component_position=None)

Get eye trackers

QRTEvent

class qtm_rt.QRTEvent(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

QTM Event types

EventConnected = 1
EventConnectionClosed = 2
EventCaptureStarted = 3
EventCaptureStopped = 4
EventCaptureFetchingFinished = 5
EventCalibrationStarted = 6
EventCalibrationStopped = 7
EventRTfromFileStarted = 8
EventRTfromFileStopped = 9
EventWaitingForTrigger = 10
EventCameraSettingsChanged = 11
EventQTMShuttingDown = 12
EventCaptureSaved = 13
EventReprocessingStarted = 14
EventReprocessingStopped = 15
EventTrigger = 16
EventNone = 17

QRTComponentType

class qtm_rt.packet.QRTComponentType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

QTM Component types

Component3d = 1
Component3dNoLabels = 2
ComponentAnalog = 3
ComponentForce = 4
Component6d = 5
Component6dEuler = 6
Component2d = 7
Component2dLin = 8
Component3dRes = 9
Component3dNoLabelsRes = 10
Component6dRes = 11
Component6dEulerRes = 12
ComponentAnalogSingle = 13
ComponentImage = 14
ComponentForceSingle = 15
ComponentGazeVector = 16
ComponentTimecode = 17
ComponentSkeleton = 18
ComponentEyeTracker = 19

Exceptions

class qtm_rt.QRTCommandException(value)

Basic RT Command Exception