Rigid Body "Tracked" Flag Streaming

NatNet, VRPN, TrackD, and Plugins
Post Reply
smith32
Posts: 11
Joined: Wed Mar 24, 2010 2:13 pm

Rigid Body "Tracked" Flag Streaming

Post by smith32 »

Hi guys,

First off I want to say how much I appreciate the great support that is provided here. Also, I wanted to update folks with my lab's current use of TrackingTools. We have 6 V100R2 cameras that we regularly move around the lab to get 6DOF position/attitude of rigid bodies. The quick (and very accurate) calibration makes the system extremely flexible. We stream the data into a real-time (Windows and QNX) closed-loop control system using MATLAB and Simulink to achieve a very tight position and attitude control system. So far everything works great.

What we're running into now is that occasionally trackables are lost (untracked) for one or two frames. This could probably be alleviated by changing our camera setup or changing the markers on the rigid body but realistically it's bound to happen once and a while, which is totally acceptable. However, the data that is streamed via NatNet does not show (as far as I know) when the rigid body is "Untracked". Instead, the client just receives all 0's for position and attitude. These instantaneous jumps to 0 are a menace for accurate closed-loop control. One could say that the easy fix would be to assume that all 0's indicate an untracked rigid body but that's not a good solution for every setup. Here's an exert from the PacketClient output for a tracked and untracked 3 marker rigid body without streaming the individual marker data:

Tracked:

Begin Packet
-------
Message ID : 7
Byte count : 128
Frame # : -1
Marker Set Count : 0
Unidentified Marker Count : 0
Rigid Body Count : 1
ID : 1
pos: [0.03,-0.80,-0.08]
ori: [0.02,0.01,0.00,1.00]
Marker Count: 3
Marker 0: id=1 size=0.0 pos=[-0.02,-0.79,-0.17]
Marker 1: id=2 size=0.0 pos=[0.08,-0.79,-0.02]
Marker 2: id=3 size=0.0 pos=[0.04,-0.82,-0.05]
Mean marker error: 0.00
Skeleton Count : 0
latency : 1160250113
End Packet
-------------

Untracked:

Begin Packet
-------
Message ID : 7
Byte count : 128
Frame # : -1
Marker Set Count : 0
Unidentified Marker Count : 0
Rigid Body Count : 1
ID : 1
pos: [0.00,0.00,0.00]
ori: [0.00,0.00,0.00,0.00]
Marker Count: 3
Marker 0: id=0 size=0.0 pos=[0.00,0.00,0.00]
Marker 1: id=0 size=0.0 pos=[0.00,0.00,0.00]
Marker 2: id=0 size=0.0 pos=[0.00,0.00,0.00]
Mean marker error: 0.00
Skeleton Count : 0
latency : 1160564086
End Packet
-------------

It would be really nice if a boolean flag for each rigid body was included in the packet so the client knows if the data it receives is valid or not. Maybe it's already there and I just haven't been able to find it.

Thanks for the support.

Andrew
NaturalPoint - Mike
Posts: 1896
Joined: Tue Feb 01, 2011 8:41 am
Location: Corvallis, OR

Re: Rigid Body "Tracked" Flag Streaming

Post by NaturalPoint - Mike »

Would it be possible to have a check for two markers at 0,0,0?
Two markers with identical positions would be otherwise impossible, and thus a good check against importing untracked frames.
smith32
Posts: 11
Joined: Wed Mar 24, 2010 2:13 pm

Re: Rigid Body "Tracked" Flag Streaming

Post by smith32 »

Ya I thought of that ... you could actually take it one step further where you check to see if all the markers are equal (or equal to 0). That would be a workable solution. Since by your answer I didn't miss a "Tracked" flag anywhere in the packet that will be the test I will code up.

Thanks for the help.

Andrew
orhirshfeld
Posts: 16
Joined: Tue Jun 17, 2014 9:42 am

Re: Rigid Body "Tracked" Flag Streaming

Post by orhirshfeld »

Hello
I know you posted here to get answer and not get motre questions
But I wish to ask for your help

I need to create interface between Simulink to Motive I already succeed to interface between Matlab and Motive through NatNet, I reviewed the sample available with NatNet SDK to do so but I'm having trouble to migrate it to Simulink, I tried using Matlab function block unsuccessfully, it's have problem to use the dll command.

the error i got from Simulink is : Undefined function or variable 'NatNetML.NatNetClientML'.

I want to thanks Glen Lichtwark sample that helped me writing interface to matlab http://www.mathworks.com/matlabcentral/ ... optitrack-

the code i tried is the follwing:

Code: Select all

function [x,y,z,yaw,pitch,roll] = Location_Orinteation_Motive_64bit(RigidBody_ID) %#codegen
coder.extrinsic('–sync:on','quaternion','fullfile','NET.addAssembly','addpath')
dllPath = fullfile('c:','NatNetSDK2.5','lib','x64','NatNetML.dll');
assemblyInfo = NET.addAssembly(dllPath);
addpath('E:\Motive')
dllPath = fullfile('c:','NatNetSDK2.5','lib','x64','NatNetML.dll');
assemblyInfo = NET.addAssembly(dllPath);
theClient = NatNetML.NatNetClientML(0); % Input = iConnectionType: 0 = Multicast, 1 = Unicast
% Connect to an OptiTrack server (e.g. Motive)
HostIP = char('127.0.0.1');
theClient.Initialize(HostIP, HostIP); % Flg = returnCode: 0 = Success
% data
 frameOfData = theClient.GetLastFrameOfData()
 rigidBodyData = frameOfData.RigidBodies(RigidBody_ID)
 x=rigidBodyData.x
 y=rigidBodyData.y
 z=rigidBodyData.y
% angle 
q = quaternion( rigidBodyData.qx, rigidBodyData.qy, rigidBodyData.qz, rigidBodyData.qw ); % extrnal file quaternion.m
qRot = quaternion( 0, 0, 0, 1);     % rotate pitch 180 to avoid 180/-180 flip for nicer graphing
q = mtimes(q, qRot);
angles = EulerAngles(q,'zyx');
yaw = angles(2) * 180.0 / pi;
pitch = -angles(1) * 180.0 / pi;   % must invert due to 180 flip above
roll = -angles(3) * 180.0 / pi;   % must invert due to 180 flip above 
thanks
Or Hirshfeld
http://il.linkedin.com/pub/or-hirshfeld/4b/79/577/
tinito
Posts: 2
Joined: Mon Nov 17, 2014 1:34 pm

Re: Rigid Body "Tracked" Flag Streaming

Post by tinito »

NaturalPoint - Mike wrote:Would it be possible to have a check for two markers at 0,0,0?
Two markers with identical positions would be otherwise impossible, and thus a good check against importing untracked frames.
Hi,

I'm trying to filter out untracked rigid bodies too, but I do not see "0, 0, 0" as position for untracked rigid bodies, I just see the last known position in the received packets. Is this an option which I can disable?

Thanks,
Martino
tinito
Posts: 2
Joined: Mon Nov 17, 2014 1:34 pm

Re: Rigid Body "Tracked" Flag Streaming

Post by tinito »

NaturalPoint - Mike wrote:Would it be possible to have a check for two markers at 0,0,0?
Two markers with identical positions would be otherwise impossible, and thus a good check against importing untracked frames.
Hi,

I'm experiencing the same problem: I need to check if a rigid body is tracked or not, and I could find no flags in NatNet packets. I tried with the proposed solution (check if two markers are at 0,0,0), but with the current version of Motive (1.5.1) the behavior seems different: I receive the last known position of each marker, instead of 0,0,0.

Is this due to a sotware update or this is some feature I can disable somehow?

Thanks,
Martino
Post Reply