Skip to content

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

natnet2df

A python script to convert NatNet (Motive) data to a Pandas DataFrame. Basically it is a wrapper over the python natnet library.

Features:

  • Send commands to Motive via NatNet

  • Select capture times, which data to capture, and convert it into a pandas DataFrame.

Installation

pip install git+https://github.com/blazenkits/natnet2df.git

Usage

from natnet2df import context
from pandas import DataFrame
import pandas as pd

if __name__ == "__main__":
    
    records = []

    context.init(
        server_ip_address= "127.0.0.1",
        local_ip_address = "127.0.0.1"
    )    # Set up NatNet

    with context.connection:

        for capture_label in range(1, 1000): # Repeat 999 times

            print(f"Starting capture {capture_label}")

            capture: DataFrame = context.capture(3.0, f"Capture {capture_label}")  # Capture data and return a dataframe.

            records.append(                
                capture.groupby(["label", "rigid_body_id"]).agg(      
                    average_x=("x", "mean"),
                    average_y=("y", "mean"),
                    average_z=("z", "mean"),
                    )
            )   # Do operations on the dataframe
            
            context.sleep(2)    # Sleep for 2 seconds

        df = pd.concat(records)   # Join all dataframes into one

Motive Settings

Edit -> Settings -> NatNet -> Enable

  • Using locally, Local Interface: Loopback / Transmission Type: Unicast

  • You must use Live Mode.

Configuring DataFrames

You may configure a custom callback which converts NatNet data into rows of a Pandas DataFrame. By default it records these rows:

설명
frame_number Motive Frame Number
timestamp Motive timestamp
rigid_body_id rigid body ID
x, y, z position
qx, qy, qz, qw rotation
tracking_valid tracking validity
marker_error rigid body marker error

You may set this in set_capture_config().

About

Python module to convert NatNet data into pandas DataFrames

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages