Here's the code:Packet is empty/stale
Make sure the server is in Live mode or playing in playback
Code: Select all
function NatNetPollingSample
fprintf( 'NatNet Polling Sample Start\n' )
% create an instance of the natnet client class
fprintf( 'Creating natnet class object\n' )
natnetclient = natnet;
% connect the client to the server (multicast over local loopback) -
% modify for your network
fprintf( 'Connecting to the server\n' )
natnetclient.HostIP = '192.168.1.98';
natnetclient.ClientIP = '192.168.1.98';
natnetclient.ConnectionType = 'Multicast';
natnetclient.connect;
if ( natnetclient.IsConnected == 0 )
fprintf( 'Client failed to connect\n' )
fprintf( '\tMake sure the host is connected to the network\n' )
fprintf( '\tand that the host and client IP addresses are correct\n\n' )
return
end
% get the asset descriptions for the asset names
model = natnetclient.getModelDescription;
if ( model.RigidBodyCount < 1 )
fprintf('No Rigid Bodies Detected\n')
fprintf('Closing...\n')
return
end
% Poll for the rigid body data a regular intervals (~1 sec) for 10 sec.
fprintf( '\nPrinting rigid body frame data approximately every second for 10 seconds...\n\n' )
for idx = 1 : 10
java.lang.Thread.sleep( 996 );
data = natnetclient.getFrame; % method to get current frame
if (isempty(data.RigidBody(1)))
fprintf( '\tPacket is empty/stale\n' )
fprintf( '\tMake sure the server is in Live mode or playing in playback\n\n')
return
end
fprintf( 'Frame:%6d ' , data.Frame )
fprintf( 'Time:%0.2f\n' , data.Timestamp )
for i = 1:model.RigidBodyCount
fprintf( 'Name:"%s" ', model.RigidBody( i ).Name )
fprintf( 'X:%0.1fmm ', data.RigidBody( i ).x * 1000 )
fprintf( 'Y:%0.1fmm ', data.RigidBody( i ).y * 1000 )
fprintf( 'Z:%0.1fmm\n', data.RigidBody( i ).z * 1000 )
end
end
disp('NatNet Polling Sample End' )
end
Any help would be greatly appreciated!