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.
pip install git+https://github.com/blazenkits/natnet2df.git
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 oneEdit -> Settings -> NatNet -> Enable
-
Using locally, Local Interface: Loopback / Transmission Type: Unicast
-
You must use Live Mode.
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().