Server connected but GetLastFrameOfData() under c++ does not work

NatNet, VRPN, TrackD, and Plugins
Post Reply
aaarthur
Posts: 3
Joined: Fri Aug 03, 2018 11:23 am

Server connected but GetLastFrameOfData() under c++ does not work

Post by aaarthur » Fri Aug 03, 2018 10:57 pm

Hello,

I am having some trouble using GetLastFrameOfData() in Visual Studio 2017 to get any data from the server. I have two computers, one as server and the other as a client, and I am using NatNet 2.8 x64. I tried the SampleClient.cpp, and "theClient->SetDataCallback( DataHandler, theClient )" works fine and displays the data.

Code: Select all

[Client] Handling packet from 192.168.1.106: Command=7, nDataBytes=212
FrameID : 26576331
Timestamp :  110734.71
Latency :  110734.71
Timecode : 00:00:00:00.0
Other Markers [Count=0]
Rigid Bodies [Count=1]
Rigid Body [ID=1  Error=0.00  Valid=1]
        x       y       z       qx      qy      qz      qw
        0.28    1.08    -0.24   -0.05   0.87    -0.07   0.48
        Rigid body markers [Count=6]
                MarkerID:1      MarkerSize:0.00 MarkerPos:-0.67,0.41,-0.20
                MarkerID:2      MarkerSize:0.00 MarkerPos:-0.67,0.40,-0.26
                MarkerID:3      MarkerSize:0.00 MarkerPos:-0.74,0.43,-0.18
                MarkerID:4      MarkerSize:0.00 MarkerPos:-0.78,0.43,-0.24
                MarkerID:5      MarkerSize:0.00 MarkerPos:-0.74,0.41,-0.28
                MarkerID:6      MarkerSize:0.00 MarkerPos:0.00,0.00,0.00
Skeletons [Count=0]
Labeled Markers [Count=0]
However, when I disabled "theClient->SetDataCallback( DataHandler, theClient )" and tried to receive data by GetLastFrameOfData(). I have added the following codes after it has retrieved Data Descriptions:

Code: Select all

	sFrameOfMocapData* pData = theClient->GetLastFrameOfData();
	cout << "pData->nRigidBodies: " << pData->nRigidBodies << endl;
	cout << "pData->nMarkerSets: " << pData->nMarkerSets << endl;
But all I received were zeros. The result is displayed as follows:

Code: Select all

Connecting to server at 192.168.1.106...
Connecting to server at LocalMachine
NatNet Sample Client (NatNet ver. 2.8.0.0)
[SampleClient] Server application info:
Application: Motive (ver. 1.79.0.0)
NatNet Version: 2.8.0.0
Client IP:192.168.1.104
Server IP:192.168.1.106
Server Name: XXXX

Client initialized and ready.
[SampleClient] Sending Test Request

[SampleClient] Requesting Data Descriptions...[SampleClient] Received 3 Data Descriptions:
Data Description # 0 (type=1)
RigidBody Name : Rigid Body 1
RigidBody ID : 1
// More info here, omitted for brevity. 

Client is connected to server and listening for data...
pData->nRigidBodies: 0
pData->nMarkerSets: 0
Does anyone know why? Really appreciate the help!

Best,
Arthur

steven.andrews
NaturalPoint Employee
NaturalPoint Employee
Posts: 461
Joined: Mon Jan 19, 2015 11:52 am

Re: Server connected but GetLastFrameOfData() under c++ does not work

Post by steven.andrews » Tue Aug 07, 2018 10:52 am

Hello Arthur,

Thank you for reaching out to the community regarding this question.

GetLastFrameOfData has been deprecated and is no longer supported under C++. Data should be polled from the data callback function instead.

If you encounter any issues with the callback, please feel free to reach out to us directly.

Best,
Steven
--
Steven Andrews
OptiTrack | Senior Customer Support Engineer
help.naturalpoint.com
support@optitrack.com

aaarthur
Posts: 3
Joined: Fri Aug 03, 2018 11:23 am

Re: Server connected but GetLastFrameOfData() under c++ does not work

Post by aaarthur » Sat Aug 18, 2018 3:39 am

steven.andrews wrote:
Tue Aug 07, 2018 10:52 am
Hello Arthur,

Thank you for reaching out to the community regarding this question.

GetLastFrameOfData has been deprecated and is no longer supported under C++. Data should be polled from the data callback function instead.

If you encounter any issues with the callback, please feel free to reach out to us directly.

Best,
Steven
--
Steven Andrews
OptiTrack | Senior Customer Support Engineer
help.naturalpoint.com
support@optitrack.com
Hello Steven,

Thanks for the reply.

I am using the version of 2.8 where that function has not been deprecated yet. I am sure the OptiTrack server is in the same version and can send data for GetLastFrameOfData (since I tried in MATLAB and it works fine). But it just doesn't work in c++. I have no idea why.

Best,
Arthur

Post Reply