Skip to main content

Python NatNet Client

Python client for Optitrack NatNet streams.

Installation

Install this package via pip:

pip install natnet

Usage

The following example highlights the basic usage of this package:

import time

from natnet import DataDescriptions, DataFrame, NatNetClient


def receive_new_frame(data_frame: DataFrame):
    global num_frames
    num_frames += 1


def receive_new_desc(desc: DataDescriptions):
    print("Received data descriptions.")


num_frames = 0
if __name__ == "__main__":
    streaming_client = NatNetClient(server_ip_address="127.0.0.1", local_ip_address="127.0.0.1", use_multicast=False)
    streaming_client.on_data_description_received_event.handlers.append(receive_new_desc)
    streaming_client.on_data_frame_received_event.handlers.append(receive_new_frame)

    with streaming_client:
        streaming_client.request_modeldef()

        for i in range(10):
            time.sleep(1)
            streaming_client.update_sync()
            print(f"Received {num_frames} frames in {i + 1}s")

In this example, we first instantiate NatNetClient with the connection parameters and attach one callback function to each of its events. The streaming_client.on_data_description_received_event event is triggered whenever a new data description packet arrives, while the streaming_client.on_data_frame_received_event event is triggered on each incoming data frame. For the configuration of the NatNet server, please refer to the official documentation.

You can process data synchronously, as in this example, by calling streaming_client.update_sync() in your run loop. Alternatively, you can call streaming_client.run_async() once after connecting, which will handle data asynchronously in two additional threads.

We then use the streaming_client instance as a context manager, which is equivalent to calling streaming_client.connect() (and streaming_client.shutdown() afterwards). After the client has been connected, we request the model definitions from the server, which causes it to send a data description packet. Note that data frames do not have to be explicitly requested, but are continuously streamed once a connection has been established.

Apart from requesting model definitions, the NatNetClient class allows sending arbitrary commands to the NatNet server via the send_command and send_request functions. For a list of different commands and requests, please refer to the official documentations.

Notes

As of Motive version 2.3, the marker positions of rigid bodies are only transmitted correctly if "Y-up" is selected in the streaming pane. If "Z-up" is selected, the frame of the rigid bodies is rotated but the marker positions are not, resulting in wrong positions of the markers relative to the rigid body.

License

The project is licensed under the MIT license.

Contributing

If you wish to contribute to this project, you are welcome to create a pull request. Please run the pre-commit hooks before submitting your pull request. To install the pre-commit hooks, run:

  1. Install pre-commit
  2. Install the Git hooks by running pre-commit install or, alternatively, run `pre-commit run --all-files manually.

Metadata

Release files for natnet 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for natnet 0.3.0
File Size Uploaded Provenance
natnet-0.3.0.tar.gz 13.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for natnet 0.3.0
File Interpreter ABI Platform
natnet-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / natnet-0.3.0.tar.gz

Download URL natnet-0.3.0.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
652b0fdc939a374e11559142cff4cfa104ec82e041c99652312c470dee7fd34b
BLAKE2b-256 checksum
How to use checksums
6a545a239bcb2e3bbb18615af7ed8bf67786f4751ebb81dc4d38056cb8506dc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Release files / natnet-0.3.0-py3-none-any.whl

Download URL natnet-0.3.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03502685885b8bdd292f74a3c4a791b21d9f90373f679e44671b52582619d0b7
BLAKE2b-256 checksum
How to use checksums
d3199cc3248b9fc7c2765266a31e9d142f08dd1cccddfef3f18b77754a348546
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

Security for natnet 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for natnet-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page