Closed johannesvollmer closed 3 years ago
Thank you for raising this question. We will get back to you on this soon.
You can create anchors and have a watcher for anchors in the same session. There is a limitation that a session can only have at most one active watchers at a time, as mentioned here - https://docs.microsoft.com/en-us/cpp/api/spatial-anchors/ndk/cloudspatialanchorsession#createwatcher. Our samples demonstrate as examples of how the capabilities - creating anchors and querying for them can be used. Since the anchors are already tracked (located) after their creation, it may be clearer to demonstrate querying anchors in our samples by starting afresh with a new session where the anchors are not yet located and using a watcher to locate them. Thanks for pointing out to us what is unclear from the samples so we could improve our samples/documentation in the future.
Awesome, thank you a lot for the insights :) great to hear that it's possible to do both at the same time.
One more question, if you don't mind: Why does GetActiveWatchers()
return a list if only one watcher can be active? Is it planned to have multiple watchers active in the future?
That's an interesting observation. At this time, ASA SDK supports 01 active watcher at a time and so the API GetActiveWatchers
may appear providing more flexibility then currently required. I can not confirm on ASA deliverables in the future but it's great to see potential interest on the feature. Thanks.
Thank you for the time to answer these questions, it really helped me :)
@phamqduc Hi I am building an application where I want to be able to see nearby anchors as I am creating and placing my new anchor. This however seems to be really difficult. Everything I have tried so far has no succes.
I am trying to do this with the coarseRelocalisation code, I tested what would happen If I skip the create anchorand saveoncloud step. When trying this out, I can progress through all steps without any error and it even find all anchors I have placed (As it proceeds to the next step asking if I want to stop the watcher as well as telling me it found 42 anchors nearby with the enumerateallnearbyanchors function) The problem is however that I can see those anchors - I just see what I see through my camera without virtual cubes being placed on the anchors location.
Could any of you provide me more insight on how to do this or provide me with a small piece of code?
case AppState.DemoStepCreateSession:
if (CloudManager.Session == null)
{
await CloudManager.CreateSessionAsync();
}
currentCloudAnchor = null;
currentAppState = AppState.DemoStepStartSession;
break;
case AppState.DemoStepConfigSession:
ConfigureSession();
currentAppState = AppState.DemoStepStartSession;
break;
case AppState.DemoStepStartSession:
await CloudManager.StartSessionAsync();
currentAppState = AppState.DemoStepCreateLocationProvider;
break;
case AppState.DemoStepCreateLocationProvider:
locationProvider = new PlatformLocationProvider();
CloudManager.Session.LocationProvider = locationProvider;
currentAppState = AppState.DemoStepConfigureSensors;
break;
case AppState.DemoStepConfigureSensors:
SensorPermissionHelper.RequestSensorPermissions();
ConfigureSensors();
currentAppState = AppState.DemoStepStopSession;
//Enable advancing to next step on Air Tap, which is an easier interaction for placing the anchor.
//(placing the anchor with Air tap automatically advances the demo).
enableAdvancingOnSelect = true;
break;
//case AppState.DemoStepCreateLocalAnchor:
// if (spawnedObject != null)
// {
// currentAppState = AppState.DemoStepSaveCloudAnchor;
// }
// enableAdvancingOnSelect = false;
// break;
//case AppState.DemoStepSaveCloudAnchor:
// currentAppState = AppState.DemoStepSavingCloudAnchor;
// await SaveCurrentObjectAnchorToCloudAsync();
// break;
case AppState.DemoStepStopSession:
CloudManager.StopSession();
CleanupSpawnedObjects();
await CloudManager.ResetSessionAsync();
locationProvider = null;
currentAppState = AppState.DemoStepCreateSessionForQuery;
break;
case AppState.DemoStepCreateSessionForQuery:
ConfigureSession();
locationProvider = new PlatformLocationProvider();
CloudManager.Session.LocationProvider = locationProvider;
ConfigureSensors();
currentAppState = AppState.DemoStepStartSessionForQuery;
break;
case AppState.DemoStepStartSessionForQuery:
await CloudManager.StartSessionAsync();
currentAppState = AppState.DemoStepLookForAnchorsNearDevice;
break;
case AppState.DemoStepLookForAnchorsNearDevice:
currentAppState = AppState.DemoStepLookingForAnchorsNearDevice;
currentWatcher = CreateWatcher();
break;
case AppState.DemoStepLookingForAnchorsNearDevice:
break;
case AppState.DemoStepStopWatcher:
if (currentWatcher != null)
{
currentWatcher.Stop();
currentWatcher = null;
}
currentAppState = AppState.DemoStepStopSessionForQuery;
break;
case AppState.DemoStepStopSessionForQuery:
CloudManager.StopSession();
currentWatcher = null;
locationProvider = null;
currentAppState = AppState.DemoStepComplete;
break;
case AppState.DemoStepComplete:
currentCloudAnchor = null;
currentAppState = AppState.DemoStepCreateSession;
CleanupSpawnedObjects();
break;
default:
Debug.Log("Shouldn't get here for app state " + currentAppState.ToString());
break;
minor edit from @msftradford to format the code correctly
Hi @justinLifelike, thanks for reaching out! Would you mind filling out the bug report template for this? Thanks!
The samples always reset and then recreate a new session for every action. Is this necessary or exemplary? Is it possible to watch for anchors and upload an anchor at the same time?