LogoLogo
WebsiteSupportDownloadsForumsQuick LinksContact Us
v2.3
v2.3
  • OptiTrack Support Documentation
  • WHAT'S NEW
    • Unreal Engine: OptiTrack InCamera VFX
  • QUICK START GUIDES
    • Quick Start Guide: Getting Started
    • Quick Start Guide: Precision Capture
    • Quick Start Guide: Tutorial Videos
    • Quick Start Guide: Prime Color Setup
    • Quick Start Guide: Active Marker Tracking
    • Quick Start Guide: Outdoor Tracking Setup
  • HARDWARE
    • Cameras
      • Ethernet Cameras
        • PrimeX 41
        • PrimeX 22
        • PrimeX 13
        • PrimeX 13W
        • SlimX 13
        • Prime Color
      • USB Cameras
        • Slim 3U
        • Flex 13
        • Flex 3
        • V120:Duo
        • V120:Trio
        • V120:Duo and Trio Setup
        • Adjusting Global Origin for Tracking Bars
    • Prepare Setup Area
    • Camera Mount Structures
    • Camera Placement
    • Camera Network Setup
    • Aiming and Focusing
    • Camera Status Indicators
  • MOTIVE
    • Installation and Activation
    • Motive Basics
    • Calibration
      • Continuous Calibration
      • Calibration Squares
    • Markers
    • Assets
      • Gizmo Tool: Translate, Rotate, and Scale
    • Rigid Body Tracking
      • Aligning Rigid Body Pivot Point with a Replicated 3D Model
    • Skeleton Tracking
    • Data Recording
      • Data Types
    • Labeling
    • Data Editing
    • Data Export
      • Data Export: BVH
      • Data Export: C3D
      • Data Export: CSV
      • Data Export: FBX
      • Data Export: TRC
    • Data Streaming
    • Camera Video Types
    • Audio Recording
    • Motive HotKeys
    • Measurement Probe Kit Guide
    • Motive Batch Processor
    • Reconstruction and 2D Mode
    • Tracking Bar Coordinate System
      • Transforming Coordinate System: Global to Local
  • MOTIVE UI PANES
    • Application Settings
      • Settings: Live Reconstruction
      • Settings: General
      • Settings: Views
      • Settings: Assets
        • Skeletons
        • Rigid Body
      • Settings: Camera
    • Mouse and Keyboard
    • Assets Pane
    • Builder Pane
    • Calibration Pane
    • Control Deck
    • Data Pane
    • Data Streaming Pane
    • Devices Pane
    • Edit Tools Pane
    • Graph View Pane
    • Info Pane
    • Labels Pane
    • Log Pane
    • Marker Sets Pane
      • Marker Name XML Files
    • Measurement Pane
    • Probe Pane
    • Properties Pane
      • Properties Pane: Camera
      • Properties Pane: Force Plates
      • Properties Pane: NI-DAQ
      • Properties Pane: OptiHub2
      • Properties Pane: Rigid Body
      • Properties Pane: Skeleton
      • Properties Pane: Take
      • Properties Pane: eSync2
    • Reference View pane
    • Status Panel
    • Toolbar/Command Bar
    • Viewport
  • PLUGINS
    • OptiTrack Unreal Engine Plugin
      • Unreal Engine: OptiTrack Live Link Plugin
      • Unreal Engine: OptiTrack Streaming Client Plugin
      • Unreal Engine: HMD Setup
      • Unreal Engine: MotionBuilder Workflow
      • Unreal Engine VCS Inputs
    • OptiTrack Unity Plugin
      • Unity: HMD Setup
    • OptiTrack OpenVR Driver
    • Autodesk Maya
      • Autodesk Maya: OptiTrack Insight VCS Plugin
    • Autodesk MotionBuilder
      • Autodesk MotionBuilder Plugin
      • Autodesk MotionBuilder: OptiTrack Skeleton Plugin
      • Autodesk MotionBuilder: OptiTrack Optical Plugin
      • Autodesk MotionBuilder: OptiTrack Insight VCS Plugin
      • Autodesk MotionBuilder: Timecode Data
    • OptiTrack Peripheral API
    • External Plugins
      • Houdini 19 Integration
  • ACTIVE COMPONENTS
    • Active Components Hardware
      • Active Puck
      • CinePuck
      • BaseStation
      • Information for Assembling the Active Tags
      • Manus Glove Setup
    • Configuration
      • Active Batch Programmer
      • Active Hardware Configuration: PuTTY
      • Active Component Firmware Compatibility
    • Active Marker Tracking
      • Active Finger Marker Set
      • Active Marker Tracking: IMU Setup
  • SYNCHRONIZATION
    • Synchronization Hardware
      • External Device Sync Guide: eSync 2
      • External Device Sync Guide: OptiHub2
    • Synchronization Setup
    • OptiTrack Timecode
  • VIRTUAL PRODUCTION
    • Unreal Engine: OptiTrack InCamera VFX
    • Entertainment Marker Sets
    • PrimeX 41
  • MOVEMENT SCIENCES
    • Movement Sciences Hardware
      • General Motive Force Plate Setup
      • AMTI Force Plate Setup
      • Bertec Force Plate Setup
      • Kistler Force Plate Setup
      • Delsys EMG Setup
      • NI-DAQ Setup
      • Multiple Device Setup
      • Prime Color Setup
    • Movement Sciences Marker Sets
      • Biomechanics Marker Sets
      • Biomech (57)
      • Rizzoli Marker Sets
    • For Visual3D Users
  • VIRTUAL REALITY
    • VR Plugins
      • VR Unreal Engine
        • OptiTrack Unreal Engine Plugin
        • Unreal Engine: OptiTrack Live Link Plugin
        • Unreal Engine: OptiTrack Streaming Client Plugin
        • Unreal Engine VCS Inputs
      • VR Unity
        • OptiTrack Unity Plugin
      • VR OpenVR
        • OptiTrack OpenVR Driver
    • VR HMD Setup
      • Unreal Engine: HMD Setup
      • Unity: HMD Setup
      • Manually Calibrating the HMD Pivot Point
      • Sync Configuration with an HTC Vive System
    • Navigation Controller Guide
    • SlimX 13
    • Active Marker Tracking
      • Active Finger Marker Set
      • Active Marker Tracking: IMU Setup
    • Synchronization Hardware
      • External Device Sync Guide: eSync 2
      • External Device Sync Guide: OptiHub2
  • ANIMATION
    • Autodesk Maya
      • Autodesk Maya: OptiTrack Insight VCS Plugin
    • Autodesk MotionBuilder
      • Autodesk MotionBuilder Plugin
      • Autodesk MotionBuilder: OptiTrack Skeleton Plugin
      • Autodesk MotionBuilder: OptiTrack Optical Plugin
      • Autodesk MotionBuilder: OptiTrack Insight VCS Plugin
      • Autodesk MotionBuilder: Timecode Data
  • ROBOTICS
    • PrimeX 22
    • Outdoor Tracking Setup
  • DEVELOPER TOOLS
    • Developer Tools Overview
    • NatNet SDK
      • NatNet 4.0
      • NatNet: Class/Function Reference
      • NatNet: Creating a Managed (C sharp) Client Application
      • NatNet: Creating a Native (C++) Client Application
      • NatNet: Data Types
      • NatNet: Matlab Wrapper
      • NatNet: Migration to NatNet 3.0 libraries
      • NatNet: RebroadcastMotiveData Sample
      • NatNet: Remote Requests/Commands
      • NatNet: Sample Projects
      • NatNet: Unicast Data Subscription Commands
      • Latency Measurements
    • Motive API
      • Motive API: Quick Start Guide
      • Motive API Overview
      • Motive API: Function Reference
      • Motive API Camera Calibration
    • Camera SDK
      • Camera SDK Classes
        • Class: cCameraGroupFilterSettings
        • Class: cCameraGroupMarkerSizeSettings
        • Class: cCameraGroupPointCloudSettings
        • Class: cCameraModule
        • Class: cRigidBodySettings
        • Class: cRigidBodySolutionTest
        • Class: cTTAPIListener
        • Class: cUID
  • MARKER SETS
    • Full Body
      • Baseline (37)
      • Baseline + Hinged Toe (41)
      • Baseline + Hinged Toe, with Headband (41)
      • Baseline + 13 Additional Markers (50)
      • Biomech (57)
      • Conventional (39)
    • Full Body + Fingers
      • Baseline + Hinged Toe + Fingers (49)
      • Baseline + 11 Additional Markers + Fingers (54)
      • Manus Glove Setup
    • Upper
      • Baseline Upper (25)
      • Baseline Upper Body + Fingers (33)
      • Conventional Upper (27)
    • Lower
      • Baseline Lower (20)
      • Helen Hayes Lower (19)
      • Conventional Lower (16)
    • Hand and Fingers
      • Left and Right Hand (11)
      • Active Finger Marker Set
    • Rizzoli Marker Sets
    • Entertainment Marker Sets
    • Rigid Body Skeleton Marker Set
  • GENERAL TROUBLESHOOTING
    • Troubleshooting
    • Running Motive on High DPI Displays
    • Firewall Settings
Powered by GitBook
On this page
  • ErrorCode
  • NatNetClient Class
  • Constructor and Destructor
  • Member Methods
  • NatNet C++ API Functions
  • Function list

Was this helpful?

Export as PDF
  1. DEVELOPER TOOLS
  2. NatNet SDK

NatNet: Class/Function Reference

PreviousNatNet 4.0NextNatNet: Creating a Managed (C sharp) Client Application

Last updated 2 years ago

Was this helpful?

This page provides function and class references of the NatNet SDK library.

The class (or NatNetClientML from the managed assembly) is the key object of the SDK. An instance of this client class allows an application to connect to a server application and query data. are provided with the C++ library for a more convenient use of the SDK tools. For additional information, refer to the provided headers files (native) or reference the NatNatML.dll file (managed).

Note:

  • NatNet SDK is backwards compatible.

  • Deprecated methods from previous SDK versions are not documented on this page, and their use in new applications is discouraged. They are subject to removal in a future version of the SDK. Refer to the header files for complete descriptions.

  • The NatNetServer class has been deprecated for versions 3.0 and above.

  • Note that some parts of the managed .NET assembly may be slightly different from the native library reference provided here. Refer to the NatNetML.dll file using an object browser for detailed information.

ErrorCode

Most of the NatNet SDK functions return their operation results in an integer type representation named ErrorType, which is just an enumerator that describes operation results as the following:

Error Name
Integer
Description

ErrorCode_OK

0

Operation successful

ErrorCode_Internal

1

Suspect internal errors. Contact support.

ErrorCode_External

2

External errors. Make sure correct parameters are used for input arguments when calling the methods.

ErrorCode_Network

3

The error occurred on the network side.

ErrorCode_Other

4

Unlisted error is conflicting the method call.

ErrorCode_InvalidArgument

5

Invalid input arguments have been inputted.

ErrorCode_InvalidOperation

6

Invalid operation.

NatNetClient Class

Constructor and Destructor

NatNetClient::NatNetClient()

Constructor: Creates a new instance of a NatNetClient class. Defaults to multicast connection if no input is given.

NatNetClient::NatNetClient(iConnectionType)

Constructor: Creates a new instance of a NatNet Client using the specified connection protocol; either unicast or multicast.

Input: iConnectionType: (0 = Multicast, 1 = Unicast).

This approach is being deprecated. The NatNetClient class now determines the connection type through sNatNetClientConnectParams input when calling the NatNetClient::Connect method.

NatNetClient::~NatNetClient()

Destructor: Destructor

Member Methods

NatNetClient::Connect

ErrorCode        Connect( const sNatNetClientConnectParams& connectParams );

Description

This method connects an instantiated NatNetClient object to a server application (e.g. Motive) at the inputted IP address.

Input Parameters:

  • Connection parameters object.

Returns:

sNatNetClientConenectParams:

  • Declared under the NatNetTypes.h file.

  • Local address. IP address of the localhost where the client application is running.

  • Server address. IP address where the server application is streaming to.

  • (Optional) Command port. Defaults to 1510.

  • (Optional) Data port. Defaults to 1511.

  • (Optional) Multicast IP address. Defaults to 239.255.42.99:1511.

typedef struct sNatNetClientConnectParams
{
    ConnectionType connectionType;
    uint16_t serverCommandPort;
    uint16_t serverDataPort;
    const char* serverAddress;
    const char* localAddress;
    const char* multicastAddress;

#if defined(__cplusplus)
    sNatNetClientConnectParams()
        : connectionType( ConnectionType_Multicast )
        , serverCommandPort( 0 )
        , serverDataPort( 0 )
        , serverAddress( NULL )
        , localAddress( NULL )
        , multicastAddress( NULL )
    {
    }
#endif
} sNatNetClientConnectParams;

NatNetClient::Disconnect

ErrorCode        Disconnect();

Description

Calling this method disconnects the client from the Motive server application.

Input Parameters:

  • None

Returns:

NatNetClient::SetFrameReceivedCallback

ErrorCode        SetFrameReceivedCallback( NatNetFrameReceivedCallback pfnDataCallback, void* pUserContext = 0 );

Description

This method sets a frame handler function and creates a new thread for receiving and processing each frame of capture data.

  • Managed Assembly: Use OnFrameReady event type to add a function delegate.

Input Parameters:

  • pfnDataCallback: A NatNetFrameReceivedCallback function. NatNetFrameReceivedCallback is a type of a pointer to a frame handler function which processes each incoming frame of tracking data. Format of the inputted function must agree with the following type definition:

typedef void (NATNET_CALLCONV* NatNetFrameReceivedCallback)(sFrameOfMocapData* pFrameOfData, void* pUserData);

  • User definable data: the Client object.

Returns:

NatNetClient::SendMessageAndWait

ErrorCode	SendMessageAndWait( const char* szRequest, 
                                    void** ppServerResponse, 
                                    int* pResponseSize );
ErrorCode	SendMessageAndWait( const char* szRequest,
                                    int tries, int timeout, 
                                    void** ppServerResponse,
                                    int* pResponseSize );

Description

Input Parameters:

  • szRequest: NatNet command.

  • tries: Number of attempts to send the command. Default: 10.

  • timeout: Number of milliseconds to wait for a response from the server before the call times out. Default: 20.

  • ppServerResponse: Application defined response.

  • pResponseSize: Number of bytes in response

Returns:

NatNetClient::GetServerDescription

ErrorCode        GetServerDescription( sServerDescription* pServerDescription );

Description

Requests a description of the current NatNet server that a client object is connected to and saves it into an instance of sServerDescription. This call is blocked until the request is responded or times out.

Input Parameters:

  • Declared sServerDescription object.

Returns:

NatNetClient::GetDataDescriptionList

int   GetDataDescriptions( sDataDescriptions** pDataDescriptions );

Description

Input Parameters:

  • Pointer to an sDataDescriptions pointer which receives the address of the client's internal sDataDescriptions object. This pointer is valid until the client is destroyed or until the next call to GetDataDescriptions.

Returns:

NatNetClient::SecondsSinceHostTimestamp

double    SecondsSinceHostTimestamp( uint64_t hostTimestamp ) const;

Description

Input Parameters:

  • (uint64_t) A timestamp value from a sFrameOfMocapData struct.

Returns:

(double) The time, in seconds, past since the provided timestamp.

NatNet C++ API Functions

Once the NatNetSDK library has been imported into a client application, the following helper functions can be used.

These functions are available ONLY for C++ applications.

Function list

NatNet_GetVersion

 NATNET_API void	NATNET_CALLCONV NatNet_GetVersion( unsigned char outVersion[4] );

Description

This function gets the version (#.#.#.#) of the NatNet SDK and saves it into an array.

Input Parameters:

  • Unsigned char array with a array length of 4.

Returns:

  • Void

NatNet_SetLogCallback

 NATNET_API void	NATNET_CALLCONV NatNet_SetLogCallback( NatNetLogCallback pfnLogCallback );

Description

This function assignes a callback handler function for receiving and reporting error/debug messages.

Input Parameters:

  • pfnLogCallback: NatNetLogCallback function. NatNetLogCallback is a type of a pointer to a callback function that is used to handle the log messages sent from the server application. Format of the linked function must agree with the following type definition:

typedef void (NATNET_CALLCONV* NatNetLogCallback)(Verbosity level, const char* message);

Returns:

  • Void

NatNet_DecodeID

 NATNET_API void	NATNET_CALLCONV NatNet_DecodeID( int compositeId,
           						int* pOutEntityId,
         						int* pOutMemberId );

Description

Input Parameters:

  • An ID value for a respective data set (sRigidBodyData, sSkeletonData, sMarker, or sFrocePLateData) from a sFrameOfMocapData packet.

  • Pointer to declared integer value for saving the entity ID and the member ID (e.g. Skeleton ID and its bone Rigid Body ID).

Returns:

  • Void

NatNet_DecodeTimecode

NATNET_API ErrorCode	NATNET_CALLCONV	NatNet_DecodeTimecode( 	unsigned int timecode,
           						unsigned int timecodeSubframe,
              						int* pOutHour, int* pOutMinute,
              						int* pOutSecond, int* pOutFrame,
             						int* pOutSubframe );

Description

Helper function to decode OptiTrack timecode data into individual components.

Input Parameters:

  • Timecode integer from a packet of sFrameOfMocapData. (timecode)

  • TimecodeSubframe integer from a packet of sFrameOfMocapData. (timecodeSubframe)

  • Pointers to declared integer variables for saving the hours (pOutHour), minutes (pOutMinute), seconds (pOutSecond), frames (pOutFrame), and subframes (pOutSubframe) values.

Returns:

NatNet_TimecodeStringify

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_TimecodeStringify( unsigned int timecode, 
              							unsigned int timecodeSubframe,
              							char* outBuffer,
              							int outBufferSize );

Description

Helper function to parse OptiTrack timecode into a user friendly string in the form hh:mm:ss:ff:yy

Input Parameters:

  • timecode: Timecode integer from a packet of sFrameOfMocapData. (timecode)

  • timecodeSubframe: TimecodeSubframe integer from a packet of sFrameOfMocapData. (timecodeSubframe)

  • outBuffer: Declared char for saving the output.

  • outBufferSize: size of the character array buffer (outBuffer).

Returns:

NatNet_CopyFrame

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_CopyFrame( sFrameOfMocapData* pSrc,
              						sFrameOfMocapData* pDst );

Description

This helper function performs a deep copy of frame data from pSrc into pDst. Some members of pDst will be dynamically allocated; use NatNet_FreeFrame( pDst ) to clean them up.

Input Parameters:

  • Pointer to two sFrameOfMocapData variables to copy from (pSrc) and copy to (pDst).

Returns:

NatNet_FreeFrame

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_FreeFrame( sFrameOfMocapData* pFrame );

Description

Frees the dynamically allocated members of a frame copy created using NatNet_CopyFrame function. Note that the object pointed to by pFrame itself is NOT de-allocated, but only its nested members which were dynamically allocated are freed.

Input Parameters:

  • sFrameOfMocapData that has been copied using the NatNet_CopyFrame function.

Returns:

Do not call this on any pFrame data that was not the destination of a call to NatNet_CopyFrame.

NatNet_FreeDescriptions

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_FreeDescriptions( sDataDescriptions* pFrame );

Description

Deallocates data descriptions pDesc and all of its members; after this call, this object is no longer valid.

Input Parameters:

  • Data descriptions (sDataDescriptions).

Returns:

NatNet_BroadcastServerDiscovery

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_BroadcastServerDiscovery( sNatNetDiscoveredServer* outServers, int* pInOutNumServers, unsigned int timeoutMillisec = 1000 );

Description

Sends broadcast messages to discover active NatNet servers and blocks for a specified time to gather responses.

Input Parameters:

  • outServers: An array of length equal to the input value of pInOutNumServers. This array will receive the details of all servers discovered by the broadcast.

  • pInOutNumServers: A pointer to an integer containing the length of the array. After this function returns, the integer is modified to contain the total number of servers that responded to the broadcast inquiry. If the modified number is larger than the original number passed to the function, there was insufficient space for those additional servers.

  • timeoutMillisec: Amount of time, in milliseconds, to wait for server responses to the broadcast before returning.

Returns:

NatNet_CreateAsyncServerDiscovery

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_CreateAsyncServerDiscovery( NatNetDiscoveryHandle* pOutDiscovery, NatNetServerDiscoveryCallback pfnCallback, void* pUserContext = NULL );

Description

Begin sending periodic broadcast messages to discover active NatNet servers in the background.

Input Parameters:

  • pOutDiscovery: Out pointer that will receive a handle representing the asynchronous discovery process. The handle returned should be passed to NatNet_FreeAsyncServerDiscovery method later for clean up.

  • pfnCallback: A NatNetServerDiscoveryCallback function pointer that will be invoked once for every new server that's discovered by the asynchronous search. The callback will also be passed onto the provided pUserContext argument.

  • pUserContext: User-specified context data to be passed to the provided pfnCallback when invoked.

Returns:

NatNet_FreeAsyncServerDiscovery

NATNET_API ErrorCode	NATNET_CALLCONV NatNet_CreateAsyncServerDiscovery( NatNetDiscoveryHandle* pOutDiscovery, NatNetServerDiscoveryCallback pfnCallback, void* pUserContext = NULL );

Description

Begin sending periodic broadcast messages to continuously search and discover active NatNet servers in the background.

Input Parameters:

  • pOutDiscovery: Out pointer that will receive a handle representing the asynchronous discovery process. The handle returned should be passed to NatNet_FreeAsyncServerDiscovery method later for clean up.

  • pfnCallback: A NatNetServerDiscoveryCallback function pointer that will be invoked once for every new server that's discovered by the asynchronous search. The callback will also be passed onto the provided pUserContext argument.

  • pUserContext: User-specified context data to be passed to the provided pfnCallback when invoked.

Returns:

The NatNetClient class is the main component of the NatNet SDK. Using an instance of the NatNetClient class, you can establish a network connection with a server application (e.g. Motive) and query data descriptions, tracking data, and send/receive remote commands. For detailed declarations, refer to the header file included in the SDK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

Sends a NatNet command to the NatNet server and waits for a response. See for more details.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

Requests a list of of the capture session and saves onto the declared instance of sDataDescriptions.

, On success, it returns 0 or ErrorCode_OK.

This method calculates and returns the time difference between a specific event in the processing pipeline and when the NatNet client application receives the tracking data. For example, if sFrameOfMocapData::CameraMideExposureTimestamp is inputted, it will return the latency from the camera exposure to when the tracking data is received. For more information on how it is used, read through the page.

Takes an ID of a data set (a marker, a Rigid Body, a Skeleton, or a force plate), and decodes its model ID and member ID into the provided integer variables. For example, ID of a Skeleton bone segment will be decoded into its model ID (Skeleton) and Rigid Body ID (bone). See .

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

, On success, it returns 0 or ErrorCode_OK.

NatNetClient.h
NatNet: Remote Requests/Commands
Latency Measurements
NatNet: Data Types
NatNetClient
API helper functions
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
ErrorCode
dataset descriptions