Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Is it possible to read position of a single marker from Motive Tracker in Unity (C#)

Discussion in 'AR/VR (XR) Discussion' started by carvinx, Nov 1, 2015.

  1. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hello, everyone

    I have a big problem by reading the position of single marker...i dont know if it is possible to get the position data of "labeled" or "unlabeled" single marker of Motive Tracker (Optitrack)?

    I have tried to use 3-Marker-construction for 1 finger (3 sphere marker on a finger) and i can read the rigidbody into Unity, but they are still flippen, if i trun the marker around.

    So i want to try to use only a marker for 1 finger and to get the position of that marker...

    I really need some solution for this and need to know:

    1. If there is a 3rd party programm to do it? where to finde it?

    2. How should i do it with VRPN Streaming (example?)?

    3. Are the markers flipping in 3d szene if i move with them?

    I really need your help!!!

    Thank your very much!

    regards.
     
  2. Omnifinity

    Omnifinity

    Joined:
    Nov 3, 2015
    Posts:
    17
  3. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi, Omnifinity

    Thank you for your anwser.

    Have you the same project with the same marker construction like i descripted? What were you written ist not the answer of my question, because i am not asking how to read the data from Motive to Unity, you must first understand the question!

    flipping is a wrong word sorry, i meant tipping -> video : http://de.tinypic.com/player.php?v=dqmxiu&s=8#.Vhf0Xvntmko

    regards
     
  4. Omnifinity

    Omnifinity

    Joined:
    Nov 3, 2015
    Posts:
    17
    Carvinx,
    I think that I understand your problem now.

    First, You can not have a single marker as a uniquely tracked entity single a marker is spherical and thus look the same to all cameras. It needs to be combined with more markers to give it a unique pattern.

    Second, It seems like when you aim your hand toward the screen (and say hello) the markers on the thumb get occluded (either by the other fingers of your hand or the palm). Your camera setup can not detect all markers because of this and thus interprets the position of your thumb as "up side down" which gives you that tipping movement.

    How have you mounted your cameras? You might be needing more in order to combat optical occlusion. This is the problem with a camera setup and can be solved by adding more cameras or through sensor fusion with IMU's (e.g. like Worldviz does with their PPT (Precision Position Tracking) system.
    This is one reason why you are seeing several hand input devices in the shape of gloves to interpret your hand movements. The problem with those is that they drift if they are not combined with an external tracking system.
     
  5. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi, Omni

    Thank you for answer.

    1. i think it is possible to read the position of single marker from Motive to Unity, i am testing a way without using 3-marker-construction for each finger, just only one marker for one finger...and i get the data in Unity.

    Link: https://onedrive.live.com/redir?resid=99BD429D9DB0CE51!2635&authkey=!AJHWu4NECtJfUak&v=3&ithint=photo,png


    2. In the video i was moving my hand with my self-made-glove & marker-construction in the front of the screen, so the 3d finger objects i created in Unity were moving with me, there is no any issues. I can go forward, backward, to left or right without tuning.

    But if i turn my finger/Hand sometimes 90 or 180 degrees, i have the problem which i showed your, they were tipping 180 degrees to another side.

    And if i make a bigger distance between the reflective balls of my construction, it will be better but the problem is still there...That is my only problem for now...

    3. The camera is the 3d glasses with 6 markers. -> Link: https://onedrive.live.com/redir?resid=99BD429D9DB0CE51!2636&authkey=!AOrA2LrpYDS0Y98&v=3&ithint=photo,png

    Sorry, i dont think it will depend on the setting of camera / glasses.

    >>> But i get the next problem about the position of single markers, i dont know why it showed me that data of other markers = data of labeled markers after running the NatNet sdk sampleClient.exe...

    Other markers should nocht be the labeled markers?!

    Thank your very much!

    regards.
     
    Last edited: Nov 9, 2015
  6. Omnifinity

    Omnifinity

    Joined:
    Nov 3, 2015
    Posts:
    17
    Hi,
    is your math using euler angles or quaternions? maybe you are experiencing gimbal lock?

    well yes, you can get the position of individual markers but you cannot solve the orientation of it. for that you need more markers.
     
  7. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi,

    Yes, i am using euler angles to convert the axis of Motive to Unity-axis, it is correct what i got, then i am using euler function to convert it back to quaternion. Yes i thought the problem should be Gimbal lock, but the problem is still there without using euler angles function.

    It is not tipping for my glasses with 6 markers, because the distance is bigger between markers, but i cant make the construction for the 3-marker-finger object bigger, because i must put my finger together, if i do it, my finger objects will be too close to each other that the Motive cant distinguish between two fingers, do you understand what i am meaning?

    So it is only the limit of this construction.

    I just think i dont need the orientation any more, i can check if the 3d object is touched by my finger object in unity by using collider function...But i dont understand the results i described in my last post.

    WHY: data of other markers = data of labeled markers after running the NatNet sdk sampleClient.exe ?

    Link: https://onedrive.live.com/redir?resid=99BD429D9DB0CE51!2635&authkey=!AJHWu4NECtJfUak&v=3&ithint=photo,png

    Thank you
     
  8. Omnifinity

    Omnifinity

    Joined:
    Nov 3, 2015
    Posts:
    17
    Yes I understand. Which cameras have you got? How many?

    I fear you sadly will have a hard time making it work on finger level due to fingers occluding each other.

    I dont have the source code available here in the example right now but i think there are some compile time conditional expressions there making it possible for you to choose what to print out or not. Check there. Sorry cant help more at the moment...
     
  9. GoesTo11

    GoesTo11

    Joined:
    Jul 22, 2014
    Posts:
    604
    What cameras are you using and how are they setup. My marker setup will have similar spacing between markers (although they won't move around as much).
     
  10. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi, Omni

    " fingers occluding each other " is the problem of my project, it could be also a reason for flipping.

    I think, It is possible to only choose unlabeled markers, but if you run the official example SampleClient.exe or PacketClient.exe (exp: SampleClient.exe 127.0.0.1 127.0.0.1) you will see that the data of unlabeled markers (other markers) = data of labeled markers, Why?

    Any idea?
     
  11. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi, GoesTo11

    I am using the 3d glasses of BenQ as my main camera for tracking my finger, and i am using Motive Tracker as tracking system and MiddleVR free edition (setting for glasses and distance of screen...) for 3d stereometric image.

    In my project they will move with me without delay, the only problem is they are flipping if i turn them sometimes...and that problem is not allowed for my project...

    Any idea?

    Thank you very much.

    regards
     
    Last edited: Nov 10, 2015
  12. Omnifinity

    Omnifinity

    Joined:
    Nov 3, 2015
    Posts:
    17
    Sorry I cannot help further since we do now work with individual markers at that level (we mainly use with rigid bodies and higher order).

    Can you defined the id of each marker in Optitrack (as you can do in the rigid body tab).

    Try to ask at the Naturalpoint forum instead.
     
  13. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi, Omni

    Are you using the standard black MarkerSet of Optitrack with 8 legs? How do you read the data of rigidbodies from Motive to your programm (Unity too?) ? And are your rigidbodies flipping too?

    Like you know, i cant define ids of single marker but i can read all data of markers(unlabeled + labeled, RB) into unity, i can only manuell check the id in a loop of makers and use them...

    But i have another problem, it lags very, if i move my finger in tracking area...so i would say [ my finger moves --- after more than 20 secs --- rigidbodies moves ]...

    Thank you.
     
  14. Omnifinity

    Omnifinity

    Joined:
    Nov 3, 2015
    Posts:
    17
    Hi, we use customer markers and the small black plates with antennas.
    We use data read/write through either VRPN or custom access through NatNet. We send this over UDP to Unity. No flipping of markers. No latency.

    What more can you tell about the latency and your implementation in Unity?
     
  15. carvinx

    carvinx

    Joined:
    Mar 19, 2014
    Posts:
    34
    Hi, Omni

    Thank you for your answer and i have following question:

    1. What kind of VRPN are you using? (VRPN Wrapper?)

    2. How does your customer markers look like, would you like to send me a image (my email: huboode@googlemail.com)

    3. For my customer 3-Marker-construction for each finger, i dont have any latency, the only problem i have is flipping.

    4. For One-Marker-Construction for each finger, i do have high latency, because of long packet from streaming, so i am try to cut it to the part which i need.

    Thanks

    cheers!

    Carvin
     
  16. oysteasm

    oysteasm

    Joined:
    Feb 1, 2016
    Posts:
    1
    Hi, carvinx

    How are you reading the single markers in Untiy?

    Thanks!
     
  17. iko79

    iko79

    Joined:
    Jan 21, 2013
    Posts:
    45
    There is a very simple way of adding this functionality in the official Optitrack Untiy Plugin (I'm referring to version 1.0.1 here, but I expect you will get this done in future releases in a similar way):

    In Assets/OptiTrack/Scripts/OptitrackStreamingClient.cs, there is a method called OnNatNetFrameReceived, where you get NatNetClient.NativeFrameReceivedEventArgs eventArgs as an argument. The class already implements doing most of the marshalling for you, although it is not used by the plugin (yet?), giving you an sFrameOfMocapData struct, which contains the fields OtherMarkersCount and OtherMarkers. I added a list of OptitrackMarkerState to the OptitrackStreamingClient class like this

    private List<OptitrackMarkerState> m_latestOtherMarkerStates = new List<OptitrackMarkerState>();

    and added this to the OnNatNetFrameReceived method, just above the code where updating of rigid bodies is done:

    sFrameOfMocapData frame = eventArgs.MarshaledFrame;
    //Debug.Log( "labeled: " + frame.LabeledMarkerCount + ", other: " + frame.OtherMarkerCount + ", sets: " + frame.MarkerSetCount );

    float[] vec = new float[3 * frame.OtherMarkerCount];
    System.Runtime.InteropServices.Marshal.Copy( frame.OtherMarkers, vec, 0, vec.Length );

    m_latestOtherMarkerStates.Clear();
    for( int i = 0; i < frame.OtherMarkerCount; i++ )
    {
    OptitrackMarkerState state = new OptitrackMarkerState();
    state.Position = new Vector3( -vec[i * 3 + 0], vec[i * 3 + 1], vec[i * 3 + 2] );
    //TODO: where do i get the size from?
    state.Size = 0.01f;

    m_latestOtherMarkerStates.Add( state );
    //Debug.Log( "marker #" + i + ": [" + vec[i * 3 + 0] + ", " + vec[i * 3 + 1] + ", " + vec[i * 3 + 2] );
    }


    Works like a charm for me. You can also go ahead and implement an editor script so you have the markers drawn in the Unity scene view, use OptitrackRigidBodyEditor.cs as a reference, it isn't too hard.
     
    imaos likes this.