Need Help to Output Delta Displacements

NatNet, VRPN, TrackD, and Plugins
Post Reply
shahil
Posts: 3
Joined: Fri Feb 19, 2016 3:59 pm

Need Help to Output Delta Displacements

Post by shahil »

Hi,

I'm hoping someone can help me out with a simple coding task. I want to stream the displacement data from the Motive software from a couple of rigid bodies, but I want to display the delta displacments from their initial positions. I basically want to zero out the initial positions so that I only see the deltas when the targets move.

I'm trying to use the NatNetSDK WinFormsSample application code to do this, but am having some trouble (pardon me, I'm a beginner when it comes to coding). I'm trying to capture the initial value of the rigid body position at rb.x, rb.y, and rb,z, and then simply minus this value from the outputed number in the display. Does anyone know how to capture those initial position values? It doesn't seem to be working when I simply equate a temp variable to the rb.x/y/z floats.

Any quick help would be much appreciated.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Need Help to Output Delta Displacements

Post by morgan »

The initial values need to be stored in persistent variables (either static, or global, or class members). If you are just storing them in local variables on the stack in the data handler they would reinitialzed every frame.

I'd probably create a list of initposes, 1 for each rigidbody.

Here's some C# pseudocode for the Winforms sample:

Code: Select all


// Init Pose type
public class InitPose
{
      int RigidBodyID;
      double x;
      double y;
      double z;
}

// Add List of these to the winforms form class
    public partial class Form1 : Form
    {
        List<InitPose> mListInitPoses = new List<InitPose>();
        ...

// Initialize each init pose on first frame of data
void ProcessFrameOfData(ref NatNetML.FrameOfMocapData data)
{ 
            // First frame of data?  Store off the init poses 
            for (int i = 0; i < m_FrameOfData.nRigidBodies; i++)
            {
                NatNetML.RigidBodyData rb = m_FrameOfData.RigidBodies[i];
                InitPose pose;
                pose.ID = rb.ID;
                pose.x = rb.x;
                pose.y = rb.y;
                pose.z = rb.z;
                mListInitPoses.add(pose);
            }

      ...
}

Hope this helps,

Morgan
Post Reply