microsoft / MixedReality-WorldLockingTools-Unity

Unity tools to provide a stable coordinate system anchored to the physical world.
https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/README.html
MIT License
188 stars 45 forks source link

Add support for ASA v2.11 #239

Closed fast-slow-still closed 2 years ago

fast-slow-still commented 2 years ago

WLT currently supports ASA SDK versions v2.9.0 through v2.10.2.

The recent release of ASA v2.11.0 includes breaking changes that will need to be accommodated, while still supporting earlier versions.

Furthermore, the WLT-ASA shim includes workarounds for ASA bugs related to the camera parent having a non-identity transform. We worked with the ASA team on these, and they are hopefully fixed now. The fixes will need to be tested and the workarounds adjusted or removed.

fast-slow-still commented 2 years ago

Obviously this will entail heavy regression testing.

fast-slow-still commented 2 years ago

ASA v2.11.0 was apparently released 2021/11/19.

zantiu commented 2 years ago

Interesting timing. I just decided to give ASA another shot in combination with WLT and just got it working yesterday with ASA v2.11.0.

I first tried with the ASA-WLT demo but failed to get that work, not sure why. This is basically the approach that works for me:

// create the cloud anchor from a spacepin that has been positioned before by a QR code
var lockedPose = spacePin.LockedPose;
var spongyPose = WorldLockingManager.GetInstance().SpongyFromLocked.Multiply(lockedPose);
anchorHanger = new GameObject("anchorHanger");
anchorHanger.transform.SetGlobalPose(spongyPose); 
await anchorHanger.CreateNativeAnchor();
var nativeAnchor = anchorHanger.FindNativeAnchor();
var cloudAnchor = await nativeAnchor.ToCloud();
await spatialAnchorManager.CreateAnchorAsync(cloudAnchor);
var anchorId = cloudAnchor.Identifier; // use this to retrieve by id
// when an anchor has been located
public static void AnchorLocated(object sender, AnchorLocatedEventArgs args)
{
  var cloudAnchor = args.Anchor;
  Pose spongyPose = cloudAnchor.GetPose();
  var wltMgr = WorldLockingManager.GetInstance();
  var frozenPose = wltMgr.FrozenFromSpongy(spongyPose);
  spacePinPackage.UpdatePose(frozenPose);
}

The thing that took a while to figure out is that for creating the cloud anchor it needs to be positioned with the spongyPose. I'm not sure what the explanation is here but it works. And it was also not immediately clear from the ASA-WLT sample that it needed to be done like this. For now tested with three spacepins covering an area of about 4 x 10m.

fast-slow-still commented 2 years ago

Fixed with PR #241