The NatNet SDK features sending remote commands/requests from a client application over to a connected server application (i.e. Motive).
The SendMessageAndWait method under NatNetClient class is the core method for sending remote commands. This function takes in a string value of the command and sends it over to the connected Motive server each time it's called, and once the server receives the remote command, corresponding actions will be performed. Please note that only a selected set of commands can be understood by the server, which are listed under the remote commands chart below.
NatNet commands are sent via the UDP connection, 1510 port by default.
Description
Sends a NatNet command to the NatNet server and waits for a response.
Input Parameters:
szRequest: NatNet command string, which is one of the commands listed on the below chart. If the command requires input parameters, corresponding parameters should be included in the command with comma delimiters. (e.g. string strCommand = "SetPlaybackTakeName," + TakeName;).
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.
Returns:
ErrorCode, On success, it returns 0 or ErrorCode_OK.
Motive Supported NatNet Commands/Requests
Supported for Motive 3.0 or above.
Subscription commands work with Unicast streaming protocol only. When needed, unicast clients can send subscription commands to receive only specific data types through the data stream. This allows users to minimize the size of streaming packets. For more information, read through the page.
Following is a general format used for the subscription command strings:
SubscribeToData,[DataType],[All or specific asset]
SubscribeByID,[DataType],[ID]
Below is a sample use of the NatNet commands from the application.
Start Recording
Framerate Query
Setting name of the recorded Take
Setting Motive Properties
pResponseSize: Number of bytes in response
Node name (if applicable)
Property name
Returns: Int
Sample command string:
For rigid body assets, Streaming ID of rigid bodies can be used in place of the stringNodeName. For example, string command for getting name of a rigid body with streaming ID of 3 would be:
eSync:2:
Beginning with Motive 3.1, accessing the eSync 2 no longer requires the inclusion of the device's serial number. For example:
Desired value
Returns: Int
Sample command string:
For rigid body assets, Streaming ID of rigid bodies can be used in place of the stringNodeName. For example, string command for enabling rigid body with streaming ID of 3 would be:
eSync:2:
Beginning with Motive 3.1, accessing the eSync 2 no longer requires the inclusion of the device's serial number.
Returns: Depends on the property type.
Sample command string:
ErrorCode SendMessageAndWait( const char* szRequest,
void** ppServerResponse,
int* pResponseSize );ErrorCode SendMessageAndWait( const char* szRequest,
int tries, int timeout,
void** ppServerResponse,
int* pResponseSize );string command = "LiveMode";string command = "UnitsToMillimeters";string command = "FrameRate";string command = "CurrentMode";string command = "StartRecording";string command = "StopRecording";string command = "LiveMode";string command = "EditMode";string command = "TimelinePlay";string command = "TimelineStop";string command = "SetPlaybackTakeName," + stringTakeName;string command = "SetRecordTakeName," + stringTakeName;string command = "SetCurrentSession," + stringSessionName;</source><source>string command = "SetCurrentSession," + "c:/folder"string folder = "CurrentSessionPath";string command = "SetPlaybackStartFrame," + stringFrameNumber;string command = "SetPlaybackStopFrame," + stringFrameNumber;string command = "SetPlaybackCurrentFrame," + stringFrameNumber;string enablelooping = "SetPlaybackLooping";
string disablelooping = "SetPlaybackLooping, 0";string command = "EnableAsset," + stringNodeName;string command = "DisableAsset," + stringNodeName;string command = "CurrentTakeLength";string command = "RecalibrateAsset";string command = "ResetAssetOrientation";private void RecordButton_Click(object sender, EventArgs e)
{
string command = "StartRecording";
int nBytes = 0;
byte[] response = new byte[10000];
int rc = m_NatNet.SendMessageAndWait(command, 3, 100, out response, out nBytes);
if (rc != 0)
{
OutputMessage(command + " not handled by server");
}
else
{
int opResult = System.BitConverter.ToInt32(response, 0);
if (opResult == 0)
OutputMessage(command + " handled and succeeded.");
else
OutputMessage(command + " handled but failed.");
}
}// [NatNet] [optional] Query mocap server for the current camera framerate
int nBytes = 0;
byte[] response = new byte[10000];
int rc;
rc = m_NatNet.SendMessageAndWait("FrameRate", out response, out nBytes);
if (rc == 0)
{
try
{
m_ServerFramerate = BitConverter.ToSingle(response, 0);
OutputMessage(String.Format(" Camera Framerate: {0}", m_ServerFramerate));
}
catch (System.Exception ex)
{
OutputMessage(ex.Message);
}
}private void SetRecordingTakeButton_Click(object sender, EventArgs e)
{
int nBytes = 0;
byte[] response = new byte[10000];
String strCommand = "SetRecordTakeName," + RecordingTakeNameText.Text;
int rc = m_NatNet.SendMessageAndWait(strCommand, out response, out nBytes);
}private void SetPropertyButton_Click(object sender, EventArgs e)
{
int nBytes = 0;
byte[] response = new byte[10000];
string command = "SetProperty," + NodeNameText.Text + "," + PropertyNameText.Text + "," + PropertyValueText.Text;
int rc = m_NatNet.SendMessageAndWait(command, out response, out nBytes);
if (rc != 0)
{
OutputMessage(command + " not handled by server");
}
else
{
int opResult = System.BitConverter.ToInt32(response, 0);
if (opResult == 0)
OutputMessage(command + " handled and succeeded.");
else
OutputMessage(command + " handled but failed.");
}
}string command = "GetProperty," + stringNodeName + "," + stringPropertyName;string command = "GetProperty," + "3"+ "," + "Name";GetProperty, eSync 2, SyncOutput1Enabledstring command = "SetProperty," + stringNodeName + "," + stringPropertyName + "," + stringPropertyValue;
//Sets the frame rate of the camera system to 180FPS.
string command = "SetProperty,Master Rate,180";
// Sets the gain on camera #13003 to 2.
"SetProperty," + "Prime 13 #13003", + "," + "Gain" + "," + "2";string command = "SetProperty," + "3"+ "," + "Enable" + "," + "True";string command = "GetTakeProperty," + takeName + "," + propertyName;
//Querying for EndFrame number on the currently loaded take. string command = "GetTakeProperty,,End Frame";