Search Unity

ARKit 2 and MultiPeer Connectivity to share anchors

Discussion in 'ARKit' started by T1nk35B3ll, Sep 27, 2018.

  1. T1nk35B3ll

    T1nk35B3ll

    Joined:
    Aug 22, 2017
    Posts:
    2
    I'm trying to share an anchor between two devices.
    All the examples show that we can share the WorldMap, using the serialized format of the ARWorldMap, but I don't understand how I can get the anchors from the ARWorldMap to render these anchors on the other device.

    I use the MultiPeer Connectivity feature. I am able to share the ARWorldMap.
    Reading the Apple's documentation, the ARSession contains the anchors saved in the map. Each anchor should have a name property that we could use to determine which 3D model to display when we resume a session.
    Regarding the Unity plugin, I don't find a way to get those anchors.

    Can someone could enlighten me ?

    For the info : Unity 2018.2.7 + iPhone 7 and iPhone X both on iOS 12, MultiPeer Connectivity plugin from Prime 31
     
  2. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    157
    this is currently not supported by the plugin. You could add that functionality to the plugin or share a dictionary consisting of anchor identifiers and descriptions when you share the map
     
  3. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    792
    I'm not sure this is true - ARWorldMap contains any user anchors too I believe. I haven't tried this myself, but if you add user anchors before you save the ARWorldMap, when you load ARWorldMap and it relocalizes, you should get your ARUserAnchorAdded callbacks for every user anchor that was saved.
     
  4. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    157
    that's true but the anchors have a random identifier, so you can't tell what that anchor represents unless you save and synchronize that meta data
     
  5. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    792
    You are right dangit! User anchors have a name field that you can provide, but the plugin does not use the initWithName:transform method to create anchors. Feature request?
     
  6. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    792
  7. NAKAS

    NAKAS

    Joined:
    Jan 16, 2013
    Posts:
    20
  8. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    157
    Would be great, or i make a pull reuest on the weekend
     
    karsnen, fbenedetti and jimmya like this.
  9. karsnen

    karsnen

    Joined:
    Feb 9, 2014
    Posts:
    65
    @MrMatthias && @jimmya

    Did you guys find a solution for this?

    Intention

    I have virtual objects when I am trying to create an experience. I store the positional and rotational values of the those objects for to reproduce. I am trying to find the best recommend way to reproduce the virtual object when loading a saved/recorded ARWorldMap. I find discrepancy with respect to Apple documents.


    Method for reproduction

    By saving the positional & rotational values of the virtual objects whiling save ARWorldMap - I am thinking about instantiating the virtual objects at those positional & rotational values, when loading a saved ARWorldMap. As soon as the objects are loaded, planning to add ArAnchor to those objects to respond to anchor updates.

    Even with this approach, I am unclear as of what Mapping State should I instantiate those virtual objects. At what context, should I reproduce those virtual objects?



    ------------------------------------------ TLDR



    ARWorldMap : https://developer.apple.com/documentation/arkit/arworldmap



    Scenario

    According to Apple docs, ARWorldMap has set of anchors recorded in the world map [link]. But with Unity's UnityEngine.XR.iOS.ARWorldMap, that recorded data is not exposed.
    With regard to the example posted on Apple's website,

    [https://developer.apple.com/documentation/arkit/creating_a_persistent_ar_experience]

    They recommend to use the recorded ARAnchor's name from ARWorldMap to instantiated the virtual content.

    Questions

    1. Missing out on recorded anchor data in UnityEngine.XR.iOS.ARWorldMap, is this intentional or do you have timeline for development?
     
  10. owain_rich

    owain_rich

    Joined:
    Jun 20, 2016
    Posts:
    3
    @jimmya @karsnen @NAKAS

    I wondered if anyone had any success with this? I figured if I could send a string via MultiPeer Connectivity as well as the anchor data I could use the string to select which 3D model would be created for a given anchor.

    So I'm trying to combine these two MultiPeer Connectivity examples, one that sends ARKit UserAnchors and one that sends strings (see below for the links - I'm getting blocked from posting them as it's my first post here).

    The reason for this is that I want to send both Anchors and strings between two phones. Both projects work individually but when I try to combine the code I get a crash when sending a string on the receiving device.

    As far as I can see both sets of code extend the UnityMCSessionNativeInterface class to serialise data and use Observables to listen for this data. I've tried various methods of combining the code but I always get a crash when sending a string on the receiving device.

    Any help would be massively appreciated.

    Thanks.

    Owain
     
  11. owain_rich

    owain_rich

    Joined:
    Jun 20, 2016
    Posts:
    3
    Ah unfortunately I can't post links on here for some reason.
     
  12. stich34

    stich34

    Joined:
    Nov 11, 2016
    Posts:
    7
  13. stich34

    stich34

    Joined:
    Nov 11, 2016
    Posts:
    7