Motion tracking client for optitracks systems.
pip install git+https://github.com/lunarring/NatNetSDK_4.1.0.git
poetry add git+https://github.com/lunarring/NatNetSDK_4.1.0.git
NatNet SDK is a library that allows you to communicate with the NatNet Server and retrieve data from the server. This library has been created to work with the NatNet protocol and is used to retrieve data from the server.
from natnetpacket.NatNetClient import NatNetClient
client = NatNetClient()
client.set_client_address(optionsDict["clientAddress"]) # Set local IPv4 from the machine you are using to communicate to the NatNet Server
client.set_server_address(optionsDict["serverAddress"]) # Set the server IPv4 from the machine running the NatNet Server
client.set_use_multicast(optionsDict["use_multicast"]) # MultiCast (True) / UniCast (False)
NatNet Client work's based on callback function and to set the function is:
def receive_new_frame(data_dict : Dict) -> None:
'''
{
"frame_number" : int # Contains the frame ID of the current iteration
"marker_set_count" : int # Number of marker sets in the data
"unlabeled_markers_count" : int # Number of unlabeled markers in the data
"rigid_body_count" : int # Number of rigid bodies in the data
"skeleton_count" : int # Number of skeletons in the data
"asset_count" : int # Number of assets in the data
"labeled_marker_count" : int # Number of labeled markers in the data
"timecode" : float # Timecode of the data
"timecode_sub" : float # Subtimecode of the data
"timestamp" : float # Timestamp of the data
"is_recording" : bool # Indicates if the data is being recorded
"tracked_models_changed" : tracked_models_changed # Indicates if the tracked models have changed
"mocap_data" : MoCapData # Mocap data for the current frame (all the information send by the system)
}
'''
client.new_frame_listener = receive_new_frame
How to start retrieving data from the server
is_running = streaming_client.run() # -> bool
[Coder]
[Lab]