Main Page → NatNet SDK → NatNet: Remote Requests/Commands
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 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.
For a sample use of NatNet commands, refer to the provided WinFormSample.
ErrorCode SendMessageAndWait( const char* szRequest, void** ppServerResponse, int* pResponseSize );
ErrorCode SendMessageAndWait( const char* szRequest, int tries, int timeout, void** ppServerResponse, int* pResponseSize );
Sample command string:
<source>string command = "GetProperty," + stringNodeName + "," + stringPropertyName;</source>
{{{1}}}
<source>string command = "SetProperty," + stringNodeName + "," + stringPropertyName + "," + stringPropertyValue;</source>
Below is a sample use of the NatNet commands from the WinFormsSample application.
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."); } }