NatNet: Unicast Data Subscription Commands

 Main PageNatNet SDKNatNet: Unicast Data Subscription Commands

Page Scope

This page provides instructions on how to use the subscribe commands in natNet. This feature is supported for Unicast streaming clients only.

Overview[edit]


Starting from Motive 2.2, the size of the data packets that are streamed over Unicast can be configured from each NatNet client. More specifically, each client can now send commands to the Motive server and subscribe to only the data types that they need to receive. For situations where we must stream to multiple wireless clients through Unicast, this will greatly reduce the size of individual frame data packets, and help to ensure that each client continuously receives frame data packets streamed out from Motive.

Notes[edit]

  • Supported for Unicast only.
  • Supported for Motive versions 2.2 or above.
  • This configuration is not necessary when streaming over a wired network since streaming packets are less likely to be dropped.
  • To make sure the packet size is minimized, it is recommended to clear out the filter at the beginning.

Use[edit]


In order to set which type of tracking data gets included in the streamed packets, a filter must be set by sending subscription commands to Motive. This filter will allow client applications to receive only the desired data over a wireless Unicast network. To setup the filter, each NatNet client application(s) needs to call the SendMessageAndWait method and send one of the following subscribe subscription command to the Motive server:

  • “SubscribeToData, [Data Type], [Name of the Asset]
  • “SubscribeByID, RigidBody, [StreamingID]
  • “SubscribedDataOnly”

Info2.png

Examples:

NatNetClient natnetClient;

// Sets the filter so that the client receives only 6DOF data from RigidBody-1 tracking. 
natnetCient.SendMessageAndWait("SubscribeToData,RigidBody,RigidBody-1") 

// Sets the filter so that the client receives data from assets with specific streaming ID 
natnetClient.SendMessageAndWait("SubscribeByID,RigidBody,2")

SubscribeToData[edit]

The SubscribeToData command allows you set up the filter so that NatNet client receives only the data types that it has subscribed to. Using this command, each client can subscribe to specific data types included in NatNet data packets. To set up the filter, the following string command must be sent to the Motive server using SendMessageAndWait method:

string command = "SubscribeToData,[Type],[Name]

Type[edit]

In the Type field, you will be specifying which data type to subscribe to. The following values are accepted:

  • RigidBody
  • Skeleton
  • ForcePlate
  • Device
  • LabeledMarkers
  • MarkersetMarkers
  • LegacyUnlabeledMarkers
  • AllTypes

Name[edit]

Once the type field is specified, you can also subscribe to a specific asset by inputting the name of the rigid body. You can also input "All" or leave the name field empty to subscribe to all of the assets in that data type.

Info2.png

Examples

If you wish to subscribe to a rigid body named Bat, you will be sending the following string command:

string command = "SubscribeToData,RigidBody,Bat";

You can also subscribe to specific skeleton also. The following command subscribes to Batter skeleton only:

string command = "SubscribeToData,Skeleton,Batter";

To subscribe to all rigid bodies in the data stream:

string command = "SubscribeToData,RigidBody,all";

Warning2.png

Please note that Motive will not validate the presence of the requested asset, please make sure they are present on the server-side.

SubscribeByID[edit]

Another option for subscribing to a specific data is by providing the asset ID. This works only with rigid bodies that has Streaming ID values. This command may be easier to use when streaming to multiple clients with many rigid bodies.

Info2.png

Examples

For subscribing to a rigid body with streaming ID 3:

string command = "SubscribeByID,RigidBody,3";

Multiple Filters[edit]


Subscription filters are additive. When needed, you can send multiple subscription commands to set multiple filters. If a subscription filter contradicts one another, the order of precedence listed (high-to-low) below is followed:

Filter Precedence Order:

  1. Specified asset, either by name or the streaming ID.
  2. Specified data type, all
  3. Specified data type, none
  4. All types, all
  5. All types, none
  6. Unspecified – respects Motive settings.

Unsubscribing / Clearing Filters[edit]


To clear the subscription filter, a client application can send an empty subscribe command OR disconnect and reconnect entirely. It’s suggested to clear the filter at the beginning to make sure the client application(s) is subscribing only to the data that’s necessary.

If you subscribe to a rigid body with a specific name or specific streaming ID, commands for unsubscribing to all will not unsubscribe to that specific object. To stop receiving data for a particular object, whether it's a rigid body or a skeleton, the client will need to send an unsubscribe command for that specific object also.

// Clearing the filter
NatNetClient natnetClient;

//Clearing the subscription filter to all assets
natnetClient.SendMessageAndWait(“SubscribeToData”)
natnetClient.SendMessageAndWait(“SubscribeByID”)

//Clearing subscription filter for a rigid body with Streaming ID 3.
natnetClient.SendMessageAndWait("SubscribeByID,RigidBody,3");

//Unsubscribing to a rigid body with streaming ID 3 and a skeleton named "Batter"
natnetClient.SendMessageAndWait("SubscribeByID,RigidBody,3,None");  
natnetClient.SendMessageAndWait("SubscribeToData,Skeleton,Batter,None");

Testing Commands Using Sample Project[edit]


For quickly testing the NatNet commands, you can utilize the WinFormSamples program provided in the NatNet SDK package. This program has commands tab which can be used for calling the SendMessageAndWait method. Using this input field, you can test the command string to test out its results.

Subscribing to shotgun rigid body from WinFormSamples app.