Search Unity

Other Simulated environment with Image markers

Discussion in 'Unity MARS' started by Tryll, May 14, 2021.

  1. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    I'm working through my first app, and have a simulated environment with image markers placed. Things seem to work OK, but I'm wondering – should the camera be able to lose track of the image marker once it is triggered?

    From what I'm seeing, an image marker, once found, is never lost, and never "deactivates". This prevents markers from "firing again".

    So, how does one, lose, and then re-trigger a simulated image marker? Should this be possible to simulate?

    Or more to the point, how do I make it so that my app can lose, and then re-trigger actual image markers when "re-found"?
     
  2. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    Hello @Tryll


    Have you tried activating the "Reset on Loss" checkbox on the SetPoseAction component that is part of the image marker?
     
  3. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    I have tried the "Reset on loss" toggle. Unfortunately I don't see that it has any effect. I'm not really sure if the simulator is recognizing that the marker is lost, even if I turn away 180 degrees.

    Should a loss state actually deactivate the marker's children? Because, once the image is found once, it seems to be permanently found. (But then, I still have the un-navigable Device View issue, so I don't know if the simulated environment is actually working as intended.)
     
  4. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    Could you try it out on the device build since there is currently an issue with 2020?; if not, could you test out if it works on 2019.4 LTS? (on 2019.4 device view works correctly)
     
  5. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    OK, I'm installing the older Unity version, and I'll build up some kind of a test I guess.
     
  6. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    OK, in Unity 2019.4 device view DOES rotate with the mouse and WASD controls.

    However, it never loads the simulation environment, or any of my proxy objects.

    The simulation view still loads and shows the simulated environment, but device view remains empty with the default empty scene and Unity grid.

    This is a new project, with just U2019.4 and MARS. My OS is now OSX 11.3.1 (Big Sur) as I updated the OS in hopes it would improve this... it didn't.
     
  7. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    It seems that Device view will show the simulated environment in Unity 2019.4 if I choose "Environment" as the select type. The it shows up, and the view is navigable. 2021-05-14 at 12.11 PM.png

    So, once that is working, I'm kind of back at the original question... should synthetic image markers be capable of resetting once lost? Like the Game view, and the Simulation view, the Device view never seems to lose track of the image, and therefore it only "fires" one time. Does that represent expected behavior?

    In the actual application how can I reset an image marker after losing it? Is there an integrated way to get notified of markers found or lost? I guess I'd have expected the "Actions" tab in the proxy's inspector to offer me a way to send a message to another game object (or script) when these events occur.

    How are image marker lost and found supposed to work, beyond enabling the marker's child objects the first time it is located?

    Thanks.
     
  8. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    Hey @Tryll,

    We are looking into the image marker; in the meantime. I am running 2019.4 and can see it working with Content selected. Can you please tell us if you get any errors in the editor log? (not in the unity console, but in the OS Console) Screen Shot 2021-05-14 at 12.35.08 PM.png
     
    Last edited: May 14, 2021
  9. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    So, if I switch device view to Select Type "Content", all simulation environment and synthetic image markers disappear. The only thing remaining in the device view is the child object of the image marker.

    However, toggling the window's "run simulation" button (or play button) as well as the select type may make the simulation content appear or disappear. It is consistent, but they are definitely interacting with each other.

    Even when the simulated environment, and synthetic markers AND scene content is displayed, AND the device view is navigable – image markers never seem to become lost either through becoming obscured or completely being removed from the camera (user) FOV.

    Not really seeing anything written to the OS console, and the Unity console only shows some temporary issues which are clearable.
    2021-05-14 at 1.20 PM.png
     
  10. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    Those errors look like the initial errors you posted on the 2020 post and that could be affecting the simulation environment behavior. Do you have a set of steps we can try to try to reproduce that nullref?. Also I assume you are using 2019.4.26f1 (latest LTS) correct?
     
  11. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    Yes, 2019.4.26f1 (latest LTS) with MARS 1.3.0, under OSX 11.3.1
    Build settings are IOS, and the ARKit XR plugin is added through package manager. (although these issues showed with the build at "Current Platform" and no ARKit XR plugin as well.)

    Steps to reproduce (as far as I know)...
    1. make a new scene
    2. add MARS session
    3. create a simple image marker library with a few imported images
    4. Assign simple image marker library to mars session
    5. Add an image marker, select one from the assigned library
    6. Add a cube as a child of the image marker
    7. Add a synthetic image marker to the simulation through the mars panel
    8. position the marker
    My "actual" scene under Unity 2020 is quite a bit more involved, but all the problems I'm dealing there with show up with the above recipe.
     
  12. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    @Tryll

    If you add a `TrackingStateCondition` you will have the cube dissapear when its out of view. Check this out: ezgif-2-185bba253d1b.gif

    WRT the repro steps we are looking into that.
     
    JumpingGuy likes this.
  13. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    Confirmed, adding a tracking state condition set to limited does allow the image track to become appropriately lost.

    Is there some way to get notified of the state change? So far I haven't attempted to script on top of MARS code, as it already acts somewhat unpredictably even without my trying to hack on it. I'm reserving that part until I understand how it is supposed to work in the first place.

    What I'd really like is an event or broadcast message to fire that I can easily subscribe to.
     
  14. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    yes, Just implement `IMatchAcquireHandler` and `IMatchLossHandler` to know if that proxy gets matched or not. Just add this script to your proxy with the tracking state condition and you will see it printing on the console when It gets matched and goes lost.

    Code (CSharp):
    1. using Unity.MARS.Query;
    2. using UnityEngine;
    3.  
    4. public class CheckTracking : MonoBehaviour, IMatchAcquireHandler, IMatchLossHandler
    5. {
    6.     public void OnMatchAcquire(QueryResult queryResult)
    7.     {
    8.         Debug.Log("Image marker Matched!");
    9.     }
    10.  
    11.     public void OnMatchLoss(QueryResult queryResult)
    12.     {
    13.         Debug.Log("Image marker Lost!");
    14.     }
    15. }
     
  15. Tryll

    Tryll

    Joined:
    Oct 16, 2015
    Posts:
    30
    Thanks for that, it gives me a lot I can explore without trying to understand exactly how to interact with the internals of Mars.

    Now, using Game view in Unity 2020, with tracking state conditions, and OnMatchAcquire, I'm getting roughly the behavior I was expecting from the simulation, or Device View. Image Markers are found and lost and found again, and content is appropriately retriggering, so I'm starting to get somewhere.

    Certainly looking forward to the Mars 1.3.1 update which I hope makes things more predictable.
     
    jmunozarUTech likes this.