private Anchor createAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(hitResult.CreateAnchor());

            visual.SetColor(readyColor);
            visual.Render(arFragment);
            anchorVisuals[""] = visual;

            RunOnUiThread(() =>
            {
                scanProgressText.Visibility = ViewStates.Visible;
                if (enoughDataForSaving)
                {
                    statusText.Text         = "Ready to save";
                    actionButton.Text       = "Save cloud anchor";
                    actionButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    statusText.Text = "Move around the anchor";
                }
            });

            currentDemoStep = DemoStep.SaveCloudAnchor;

            return(visual.LocalAnchor);
        }
        public async void OnLocateButtonClicked(object sender, EventArgs args)
        {
            if (this.currentStep == DemoStep.DemoStepChoosing)
            {
                this.currentStep   = DemoStep.DemoStepEnteringAnchorNumber;
                this.textView.Text = "Enter an anchor number and press locate";
                this.EnableCorrectUIControls();
            }
            else
            {
                string inputVal = this.anchorNumInput.Text;
                if (!string.IsNullOrEmpty(inputVal))
                {
                    RetrieveAnchorResponse response = await this.anchorSharingServiceClient.RetrieveAnchorIdAsync(inputVal);

                    if (response.AnchorFound)
                    {
                        this.AnchorLookedUp(response.AnchorId);
                    }
                    else
                    {
                        this.RunOnUiThread(() => {
                            this.currentStep = DemoStep.DemoStepChoosing;
                            this.EnableCorrectUIControls();
                            this.textView.Text = "Anchor number not found or has expired.";
                        });
                    }

                    this.currentStep = DemoStep.DemoStepLocating;
                    this.EnableCorrectUIControls();
                }
            }
        }
        private async void transitionToSaving(AnchorVisual visual)
        {
            Log.Debug("ASADemo:", "transition to saving");
            currentStep = DemoStep.Saving;
            enableCorrectUIControls();
            Log.Debug("ASADemo", "creating anchor");
            CloudSpatialAnchor cloudAnchor = new CloudSpatialAnchor();

            visual.SetCloudAnchor(cloudAnchor);
            cloudAnchor.LocalAnchor = visual.LocalAnchor;
            try
            {
                var anchor = await cloudAnchorManager.CreateAnchorAsync(cloudAnchor);

                String anchorId = anchor.Identifier;
                Log.Debug("ASADemo:", "created anchor: " + anchorId);
                visual.SetColor(savedColor);
                anchorVisuals[anchorId] = visual;
                anchorVisuals.Remove("");

                Log.Debug("ASADemo", "recording anchor with web service");
                AnchorPoster poster = new AnchorPoster(SharingAnchorsServiceUrl);
                Log.Debug("ASADemo", "anchorId: " + anchorId);
                var result = await poster.PostAnchorAsync(anchorId);

                anchorPosted(result);
            }
            catch (System.Exception ex)
            {
                string exceptionMessage = (ex is CloudSpatialException cse) ? cse.ErrorCode.ToString() : ex.Message;
                createAnchorExceptionCompletion(exceptionMessage);
                visual.SetColor(failedColor);
            }
        }
        private void OnSessionUpdated(object sender, SessionUpdatedEvent eventArgs)
        {
            float progress = eventArgs.Status.RecommendedForCreateProgress;

            this.enoughDataForSaving = progress >= 1.0;
            lock (this.progressLock)
            {
                if (this.currentDemoStep == DemoStep.SaveAnchor)
                {
                    this.RunOnUiThread(() =>
                    {
                        this.scanProgressText.Text = $"Scan progress is {Math.Min(1.0f, progress):0%}";
                    });

                    if (this.enoughDataForSaving && this.actionButton.Visibility != ViewStates.Visible)
                    {
                        // Enable the save button
                        this.RunOnUiThread(() =>
                        {
                            this.statusText.Text         = "Ready to save";
                            this.actionButton.Text       = "Save cloud anchor";
                            this.actionButton.Visibility = ViewStates.Visible;
                        });
                        this.currentDemoStep = DemoStep.SaveAnchor;
                    }
                }
            }
        }
        private Anchor CreateAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(arFragment, hitResult.CreateAnchor());

            visual.SetColor(this, Color.Yellow);
            visual.AddToScene(this.arFragment);
            this.anchorVisuals[string.Empty] = visual;

            this.RunOnUiThread(() =>
            {
                this.scanProgressText.Visibility = ViewStates.Visible;
                if (this.enoughDataForSaving)
                {
                    this.statusText.Text         = "Ready to save";
                    this.actionButton.Text       = "Save cloud anchor";
                    this.actionButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    this.statusText.Text = "Move around the anchor";
                }
            });

            this.currentDemoStep = DemoStep.SaveAnchor;

            return(visual.LocalAnchor);
        }
        private void onSessionUpdated(object sender, SessionUpdatedEventArgs args)
        {
            float progress = args.P0.Status.RecommendedForCreateProgress;

            enoughDataForSaving = progress >= 1.0;
            lock (progressLock) {
                if (currentDemoStep == DemoStep.SaveCloudAnchor)
                {
                    DecimalFormat decimalFormat = new DecimalFormat("00");
                    RunOnUiThread(() => {
                        string progressMessage = $"Scan progress is {progress.ToString("P0")}";
                        scanProgressText.Text  = progressMessage;
                    });

                    if (enoughDataForSaving && actionButton.Visibility != ViewStates.Visible)
                    {
                        // Enable the save button
                        RunOnUiThread(() => {
                            statusText.Text         = "Ready to save";
                            actionButton.Text       = "Save cloud anchor";
                            actionButton.Visibility = ViewStates.Visible;
                        });
                        currentDemoStep = DemoStep.SaveCloudAnchor;
                    }
                }
            }
        }
        private void anchorSaveSuccess(CloudSpatialAnchor result)
        {
            saveCount++;

            anchorID = result.Identifier;
            Log.Debug("ASADemo:", "created anchor: " + anchorID);

            AnchorVisual visual = anchorVisuals[""];

            visual.SetColor(savedColor);
            anchorVisuals[anchorID] = visual;
            anchorVisuals.Remove("");

            if (basicDemo || saveCount == numberOfNearbyAnchors)
            {
                RunOnUiThread(() => {
                    statusText.Text         = "";
                    actionButton.Visibility = ViewStates.Visible;
                });

                currentDemoStep = DemoStep.CreateSessionForQuery;
                advanceDemo();
            }
            else
            {
                // Need to create more anchors for nearby demo
                RunOnUiThread(() => {
                    statusText.Text         = "Tap a surface to create next anchor";
                    actionButton.Visibility = ViewStates.Invisible;
                });

                currentDemoStep = DemoStep.CreateLocalAnchor;
            }
        }
        public void OnCreateButtonClicked(object sender, EventArgs args)
        {
            if (currentStep == DemoStep.MindrStart)
            {
                DestroySession();

                currentStep       = DemoStep.MindrName;
                textView.Text     = "Name your MindR!";
                createButton.Text = "Set name";
                EnableCorrectUIControls();
            }

            if (currentStep == DemoStep.MindrName)
            {
                if (string.IsNullOrWhiteSpace(anchorNumInput.Text))
                {
                    textView.Text = "Please name your MindR";
                    return;
                }

                createButton.Text = "Save";

                textView.Text = "Scan your environment and place a MindR";
                DestroySession();

                cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session);

                cloudAnchorManager.OnSessionUpdated += (_, sessionUpdateArgs) =>
                {
                    SessionStatus status = sessionUpdateArgs.Status;

                    if (currentStep == DemoStep.MindrCreate)
                    {
                        float progress = status.RecommendedForCreateProgress;
                        if (progress >= 1.0)
                        {
                            if (anchorVisuals.TryGetValue(string.Empty, out AnchorVisual visual))
                            {
                                //Transition to saving...
                                TransitionToSaving(visual);
                            }
                            else
                            {
                                feedbackText = "Tap somewhere to place a MindR.";
                            }
                        }
                        else
                        {
                            feedbackText = $"Progress is {progress:0%}";
                        }
                    }
                };

                currentStep = DemoStep.MindrCreate;
                EnableCorrectUIControls();

                cloudAnchorManager.StartSession();
            }
        }
 private void createAnchorExceptionCompletion(string message)
 {
     textView.Text = message;
     currentStep   = DemoStep.Choosing;
     cloudAnchorManager.Stop();
     cloudAnchorManager = null;
     enableCorrectUIControls();
 }
示例#10
0
 private void CreateAnchorExceptionCompletion(string message)
 {
     this.textView.Text = message;
     this.currentStep   = DemoStep.Start;
     this.cloudAnchorManager.StopSession();
     this.cloudAnchorManager = null;
     this.EnableCorrectUIControls();
 }
 void anchorPosted(String anchorNumber)
 {
     textView.Text = "Anchor Number: " + anchorNumber;
     currentStep   = DemoStep.Choosing;
     cloudAnchorManager.Stop();
     cloudAnchorManager = null;
     clearVisuals();
     enableCorrectUIControls();
 }
示例#12
0
        private void AnchorLookedUp(string anchorId)
        {
            Log.Debug("ASADemo", "anchor " + anchorId);
            this.anchorId = anchorId;
            this.DestroySession();

            bool anchorLocated = false;

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);
            this.cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                       this.RunOnUiThread(() =>
            {
                CloudSpatialAnchor anchor = args.Anchor;
                LocateAnchorStatus status = args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    anchorLocated = true;

                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };
                    foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.AddToScene(this.arFragment);
                    this.anchorVisuals[cloudAnchorIdentifier] = foundVisual;
                }
            });

            this.cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) =>
            {
                this.currentStep = DemoStep.Start;

                this.RunOnUiThread(() =>
                {
                    if (anchorLocated)
                    {
                        this.textView.Text = "Anchor located!";
                    }
                    else
                    {
                        this.textView.Text = "Anchor was not located. Check the logs for errors and\\or create a new anchor and try again.";
                    }

                    this.EnableCorrectUIControls();
                });
            };
            this.cloudAnchorManager.StartSession();
            AnchorLocateCriteria criteria = new AnchorLocateCriteria();

            criteria.SetIdentifiers(new string[] { anchorId });
            this.cloudAnchorManager.StartLocating(criteria);
        }
 private void StartDemo()
 {
     this.saveCount = 0;
     this.StartNewSession();
     this.RunOnUiThread(() =>
     {
         this.scanProgressText.Visibility = ViewStates.Gone;
         this.statusText.Text             = "Tap a surface to create an anchor";
         this.actionButton.Visibility     = ViewStates.Invisible;
     });
     this.currentDemoStep = DemoStep.CreateAnchor;
 }
 private void startDemo()
 {
     saveCount = 0;
     startNewSession();
     RunOnUiThread(() =>
     {
         scanProgressText.Visibility = ViewStates.Gone;
         statusText.Text             = "Tap a surface to create an anchor";
         actionButton.Visibility     = ViewStates.Visible;
     });
     currentDemoStep = DemoStep.CreateLocalAnchor;
 }
示例#15
0
 private void AnchorPosted(string anchorNumber)
 {
     this.RunOnUiThread(() =>
     {
         this.textView.Text = "Anchor Number: " + anchorNumber;
         this.currentStep   = DemoStep.Start;
         this.cloudAnchorManager.StopSession();
         this.cloudAnchorManager = null;
         this.ClearVisuals();
         this.EnableCorrectUIControls();
     });
 }
 private void AnchorPosted(string anchorNumber)
 {
     RunOnUiThread(() =>
     {
         textView.Text = "MindR saved, pasted url on clipboard";
         currentStep   = DemoStep.MindrStart;
         cloudAnchorManager.StopSession();
         cloudAnchorManager = null;
         ClearVisuals();
         EnableCorrectUIControls();
         createButton.Text = "Create";
     });
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_shared);

            arFragment             = (ArFragment)SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment);
            arFragment.TapArPlane += (sender, args) => OnTapArPlaneListener(args.HitResult, args.Plane, args.MotionEvent);

            sceneView = arFragment.ArSceneView;

            exitButton            = (Button)FindViewById(Resource.Id.mainMenu);
            exitButton.Click     += OnExitDemoClicked;
            exitButton.Visibility = ViewStates.Gone;
            textView            = (TextView)FindViewById(Resource.Id.textView);
            textView.Visibility = ViewStates.Visible;
            locateButton        = (Button)FindViewById(Resource.Id.locateButton);
            locateButton.Click += OnLocateButtonClicked;
            createButton        = (Button)FindViewById(Resource.Id.createButton);
            createButton.Click += OnCreateButtonClicked;
            anchorNumInput      = (EditText)FindViewById(Resource.Id.anchorNumText);
            editTextInfo        = (TextView)FindViewById(Resource.Id.editTextInfo);
            backingPlateTwo     = (LinearLayout)FindViewById(Resource.Id.backingplateTwo);

            currentStep = DemoStep.MindrStart;

            EnableCorrectUIControls();

            Scene scene = sceneView.Scene;

            scene.Update += (_, args) =>
            {
                // Pass frames to Spatial Anchors for processing.
                cloudAnchorManager?.Update(sceneView.ArFrame);
            };

            // Initialize the colors.
            MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Red)).GetAsync().ContinueWith(materialTask => failedColor        = (Material)materialTask.Result);
            MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Green)).GetAsync().ContinueWith(materialTask => savedColor       = (Material)materialTask.Result);
            MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.DarkBlue)).GetAsync().ContinueWith(materialTask => selectedColor = (Material)materialTask.Result);
            MaterialFactory.MakeOpaqueWithColor(this, new Color(Android.Graphics.Color.Orange)).GetAsync().ContinueWith(materialTask =>
            {
                readyColor = (Material)materialTask.Result;
                foundColor = readyColor;
            });

            // HAX
            LocateAllAnchors();
        }
        private void TransitionToSaving(AnchorVisual visual)
        {
            Log.Debug("ASADemo:", "transition to saving");
            this.currentStep = DemoStep.SavingAnchor;
            this.EnableCorrectUIControls();
            Log.Debug("ASADemo", "creating anchor");
            CloudSpatialAnchor cloudAnchor = new CloudSpatialAnchor();

            //Date d1 = new Date(2030, 11, 21);
            //cloudAnchor.Expiration = d1;

            visual.CloudAnchor      = cloudAnchor;
            cloudAnchor.LocalAnchor = visual.LocalAnchor;

            this.cloudAnchorManager.CreateAnchorAsync(cloudAnchor)
            .ContinueWith(async cloudAnchorTask =>
            {
                try
                {
                    CloudSpatialAnchor anchor = await cloudAnchorTask;

                    string anchorId = anchor.Identifier;
                    Log.Debug("ASADemo:", "created anchor: " + anchorId);
                    visual.SetColor(this, Color.Green);
                    this.anchorVisuals[anchorId] = visual;
                    this.anchorVisuals.TryRemove(string.Empty, out _);

                    Log.Debug("ASADemo", "recording anchor with web service");
                    Log.Debug("ASADemo", "anchorId: " + anchorId);
                    SendAnchorResponse response = await this.anchorSharingServiceClient.SendAnchorIdAsync(anchorId);
                    this.AnchorPosted(response.AnchorNumber);
                }
                catch (CloudSpatialException ex)
                {
                    this.CreateAnchorExceptionCompletion($"{ex.Message}, {ex.ErrorCode}");
                }
                catch (Exception ex)
                {
                    this.CreateAnchorExceptionCompletion(ex.Message);
                    visual.SetColor(this, Color.Red);
                }
            });
        }
        private void AnchorLookedUp(string anchorId)
        {
            Log.Debug("ASADemo", "anchor " + anchorId);
            this.anchorId = anchorId;
            this.DestroySession();

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);
            this.cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                       this.RunOnUiThread(() =>
            {
                CloudSpatialAnchor anchor = args.Args.Anchor;
                LocateAnchorStatus status = args.Args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };
                    foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.Render(this.arFragment);
                    this.anchorVisuals[cloudAnchorIdentifier] = foundVisual;
                }
            });

            this.cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) =>
            {
                this.currentStep = DemoStep.DemoScreenshotMode;

                this.RunOnUiThread(() =>
                {
                    this.textView.Text = "Anchor located! Grab A Screenshot!";
                    this.EnableCorrectUIControls();
                });
            };
            this.cloudAnchorManager.StartSession();
            AnchorLocateCriteria criteria = new AnchorLocateCriteria();

            criteria.SetIdentifiers(new string[] { anchorId });
            this.cloudAnchorManager.StartLocating(criteria);
        }
        private void OnLocateAnchorsCompleted(object sender, LocateAnchorsCompletedEvent _)
        {
            if (this.anchorsToLocate > 0)
            {
                // We didn't find all of the anchors.
                this.StopWatcher();
                this.RunOnUiThread(() =>
                {
                    this.statusText.Text         = "Not all anchors were located. Check the logs for errors and\\or try again.";
                    this.actionButton.Visibility = ViewStates.Visible;
                    this.actionButton.Text       = "Cleanup anchors";
                });
                this.currentDemoStep = DemoStep.End;

                return;
            }

            this.anchorsToLocate = 0;

            this.RunOnUiThread(() => this.statusText.Text = "Anchor located!");

            if (!this.basicDemo && this.currentDemoStep == DemoStep.LocateAnchor)
            {
                this.RunOnUiThread(() =>
                {
                    this.actionButton.Visibility = ViewStates.Visible;
                    this.actionButton.Text       = "Look for anchors nearby";
                });
                this.currentDemoStep = DemoStep.LocateNearbyAnchors;
            }
            else
            {
                this.StopWatcher();
                this.RunOnUiThread(() =>
                {
                    this.actionButton.Visibility = ViewStates.Visible;
                    this.actionButton.Text       = "Cleanup anchors";
                });
                this.currentDemoStep = DemoStep.End;
            }
        }
        public void OnLocateButtonClicked(object sender, EventArgs args)
        {
            if (this.currentStep == DemoStep.Start)
            {
                this.currentStep   = DemoStep.EnterAnchorNumber;
                this.textView.Text = "Enter an anchor number and press locate";
                this.EnableCorrectUIControls();
            }
            else
            {
                string inputVal = this.anchorNumInput.Text;
                if (!string.IsNullOrEmpty(inputVal))
                {
                    Task.Run(async() =>
                    {
                        RetrieveAnchorResponse response = await this.anchorSharingServiceClient.RetrieveAnchorIdAsync(inputVal);

                        if (response.AnchorFound)
                        {
                            this.AnchorLookedUp(response.AnchorId);
                            //Intent intent = new Intent(this, typeof(AnimalActivity));
                            //intent.PutExtra("anchor", response.AnchorId);
                            //this.StartActivity(intent);
                        }
                        else
                        {
                            this.RunOnUiThread(() =>
                            {
                                this.currentStep = DemoStep.Start;
                                this.EnableCorrectUIControls();
                                this.textView.Text = "Anchor number not found or has expired.";
                            });
                        }
                    });

                    this.currentStep = DemoStep.LocateAnchor;
                    this.EnableCorrectUIControls();
                }
            }
        }
        private void anchorLookedUp(String anchorId)
        {
            Log.Debug("ASADemo", "anchor " + anchorId);
            this.anchorId = anchorId;
            destroySession();

            cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session);
            cloudAnchorManager.AnchorLocated += (s, e) =>
                                                RunOnUiThread(() =>
            {
                CloudSpatialAnchor anchor = e.P0.Anchor;
                if (e.P0.Status == LocateAnchorStatus.AlreadyTracked || e.P0.Status == LocateAnchorStatus.Located)
                {
                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor);
                    foundVisual.SetCloudAnchor(anchor);
                    foundVisual.AnchorNode.SetParent(arFragment.ArSceneView.Scene);
                    String cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.Render(arFragment);
                    anchorVisuals[cloudAnchorIdentifier] = foundVisual;
                }
            });


            cloudAnchorManager.LocateAnchorsCompleted += (s, e) =>
            {
                currentStep = DemoStep.Choosing;

                RunOnUiThread(() =>
                {
                    textView.Text = "Anchor located!";
                    enableCorrectUIControls();
                });
            };
            cloudAnchorManager.Start();
            AnchorLocateCriteria criteria = new AnchorLocateCriteria();

            criteria.SetIdentifiers(new string[] { anchorId });
            cloudAnchorManager.StartLocating(criteria);
        }
        public async void locateButtonClicked(View v)
        {
            if (currentStep == DemoStep.Choosing)
            {
                currentStep   = DemoStep.EnteringAnchorNumber;
                textView.Text = "Enter an anchor number and press locate";
                enableCorrectUIControls();
            }
            else
            {
                string inputVal = anchorNumInput.Text;
                if (!string.IsNullOrEmpty(inputVal))
                {
                    AnchorGetter anchorExchanger = new AnchorGetter(SharingAnchorsServiceUrl);
                    currentStep = DemoStep.StepLocating;
                    enableCorrectUIControls();
                    var anchor = await anchorExchanger.GetAnchor(inputVal);

                    anchorLookedUp(anchor);
                }
            }
        }
        private void onLocateAnchorsCompleted(object sender, LocateAnchorsCompletedEventArgs args)
        {
            RunOnUiThread(() => statusText.Text = "Anchor located!");

            if (!basicDemo && currentDemoStep == DemoStep.LookForAnchor)
            {
                RunOnUiThread(() =>
                {
                    actionButton.Visibility = ViewStates.Visible;
                    actionButton.Text       = "Look for anchors nearby";
                });
                currentDemoStep = DemoStep.LookForNearbyAnchors;
            }
            else
            {
                stopWatcher();
                RunOnUiThread(() => {
                    actionButton.Visibility = ViewStates.Visible;
                    actionButton.Text       = "Cleanup anchors";
                });
                currentDemoStep = DemoStep.End;
            }
        }
示例#25
0
        public void OnCreateButtonClicked(object sender, EventArgs args)
        {
            this.textView.Text = "Scan your environment and place an anchor";
            this.DestroySession();

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);

            this.cloudAnchorManager.OnSessionUpdated += (_, sessionUpdateArgs) =>
            {
                SessionStatus status = sessionUpdateArgs.Status;

                if (this.currentStep == DemoStep.CreateAnchor)
                {
                    float progress = status.RecommendedForCreateProgress;
                    if (progress >= 1.0)
                    {
                        if (this.anchorVisuals.TryGetValue(string.Empty, out AnchorVisual visual))
                        {
                            //Transition to saving...
                            this.TransitionToSaving(visual);
                        }
                        else
                        {
                            this.feedbackText = "Tap somewhere to place an anchor.";
                        }
                    }
                    else
                    {
                        this.feedbackText = $"Progress is {progress:0%}";
                    }
                }
            };

            this.cloudAnchorManager.StartSession();
            this.currentStep = DemoStep.CreateAnchor;
            this.EnableCorrectUIControls();
        }
        /* not used */

        public void OnLocateButtonClicked(object sender, EventArgs args)
        {
            if (currentStep == DemoStep.Start)
            {
                currentStep   = DemoStep.EnterAnchorNumber;
                textView.Text = "Enter an anchor number and press locate";
                EnableCorrectUIControls();
            }
            else
            {
                string inputVal = anchorNumInput.Text;
                if (!string.IsNullOrEmpty(inputVal))
                {
                    Task.Run(async() =>
                    {
                        RetrieveAnchorResponse response = await anchorSharingServiceClient.RetrieveAnchorIdAsync(inputVal);

                        if (response.AnchorFound)
                        {
                            AnchorLookedUp(response.AnchorId);
                        }
                        else
                        {
                            RunOnUiThread(() => {
                                currentStep = DemoStep.Start;
                                EnableCorrectUIControls();
                                textView.Text = "Anchor number not found or has expired.";
                            });
                        }
                    });

                    currentStep = DemoStep.LocateAnchor;
                    EnableCorrectUIControls();
                }
            }
        }
        public void createButtonClicked(View v)
        {
            textView.Text = "Scan your environment and place an anchor";
            destroySession();

            cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session);

            cloudAnchorManager.SessionUpdated += (s, args) =>
            {
                if (currentStep == DemoStep.Creating)
                {
                    float progress = args.P0.Status.RecommendedForCreateProgress;
                    if (progress >= 1.0)
                    {
                        AnchorVisual visual = anchorVisuals[""];
                        if (visual != null)
                        {
                            //Transition to saving...
                            transitionToSaving(visual);
                        }
                        else
                        {
                            feedbackText = "Tap somewhere to place an anchor.";
                        }
                    }
                    else
                    {
                        feedbackText = $"Progress is {progress.ToString("P2")}";
                    }
                }
            };

            cloudAnchorManager.Start();
            currentStep = DemoStep.Creating;
            enableCorrectUIControls();
        }
        private void AnchorSaveSuccess(CloudSpatialAnchor result)
        {
            this.saveCount++;

            this.anchorID = result.Identifier;
            Log.Debug("ASADemo:", "created anchor: " + this.anchorID);

            AnchorVisual visual = this.anchorVisuals[string.Empty];

            visual.SetColor(this, Color.Green);
            this.anchorVisuals[this.anchorID] = visual;
            this.anchorVisuals.TryRemove(string.Empty, out _);

            if (this.basicDemo || this.saveCount == numberOfNearbyAnchors)
            {
                this.RunOnUiThread(() =>
                {
                    this.statusText.Text         = string.Empty;
                    this.actionButton.Visibility = ViewStates.Visible;
                });

                this.currentDemoStep = DemoStep.StopSession;
                this.AdvanceDemo();
            }
            else
            {
                // Need to create more anchors for nearby demo
                this.RunOnUiThread(() =>
                {
                    this.statusText.Text         = "Tap a surface to create next anchor";
                    this.actionButton.Visibility = ViewStates.Invisible;
                });

                this.currentDemoStep = DemoStep.CreateAnchor;
            }
        }
示例#29
0
    void Proceed(object sender, ElapsedEventArgs e)
    {
        waitTimer.Enabled = false;
        waitTimer.Interval = WAIT_TIME;

        humanMoveComplete = false;
        leftAtTarget = false;
        rightAtTarget = false;

        wilsonState = 0;

        if (goBack) {	// try again
            if (currentStep < DemoStep.Step2A) {
                currentStep = DemoStep.Step1A;
            }
            else if (currentStep < DemoStep.Step3A) {
                currentStep = DemoStep.Step2A;
            }
            else if (currentStep < DemoStep.Step4A) {
                currentStep = DemoStep.Step3A;
            }
            else if (currentStep < DemoStep.Step5A) {
                currentStep = DemoStep.Step4A;
            }
            else if (currentStep < DemoStep.Step6) {
                currentStep = DemoStep.Step5A;
            }
        }
        else {
            currentStep = (DemoStep)((int)currentStep + 1);
        }
    }
示例#30
0
    void Repeat()
    {
        switch (currentStep) {
            case DemoStep.Step1A:
            case DemoStep.Step1B:
            case DemoStep.Step1C:
            case DemoStep.Step1D:
                currentStep = DemoStep.Step1A;
                break;

            case DemoStep.Step2A:
            case DemoStep.Step2B:
            case DemoStep.Step2C:
            case DemoStep.Step2D:
                currentStep = DemoStep.Step2A;
                break;

            case DemoStep.Step3A:
            case DemoStep.Step3B:
            case DemoStep.Step3C:
                currentStep = DemoStep.Step3A;
                break;

            case DemoStep.Step4A:
            case DemoStep.Step4B:
            case DemoStep.Step4C:
                currentStep = DemoStep.Step4A;
                break;

            case DemoStep.Step5A:
            case DemoStep.Step5B:
            case DemoStep.Step5C:
                currentStep = DemoStep.Step5A;
                break;

            default:
                break;
        }
    }
示例#31
0
    // Use this for initialization
    void Start()
    {
        Wilson = GameObject.Find ("Wilson");
        Diana = GameObject.Find ("Diana");
        animator = Wilson.GetComponent<Animator> ();
        relationTracker = GameObject.Find ("BehaviorController").GetComponent<RelationTracker> ();
        eventManager = GameObject.Find ("BehaviorController").GetComponent<EventManager> ();

        leftGrasper = animator.GetBoneTransform (HumanBodyBones.LeftHand).transform.gameObject;
        rightGrasper = animator.GetBoneTransform (HumanBodyBones.RightHand).transform.gameObject;

        graspController = Wilson.GetComponent<GraspScript> ();

        ikControl = Wilson.GetComponent<IKControl> ();
        leftTarget = ikControl.leftHandObj.GetComponent<IKTarget> ();
        rightTarget = ikControl.rightHandObj.GetComponent<IKTarget> ();
        headTarget = ikControl.lookObj.GetComponent<IKTarget> ();

        outputModality = GameObject.Find ("OutputModality").GetComponent<OutputModality>();

        goBack = false;

        currentStep = DemoStep.Step0;
        waitTimer = new Timer (WAIT_TIME);
        waitTimer.Enabled = false;
        waitTimer.Elapsed += Proceed;

        humanMoveComplete = false;
        leftAtTarget = false;
        rightAtTarget = false;
        eventManager.EventComplete += HumanMoveComplete;
        leftTarget.AtTarget += LeftAtTarget;
        rightTarget.AtTarget += RightAtTarget;
    }
        private void TransitionToSaving(AnchorVisual visual)
        {
            Log.Debug("ASADemo:", "transition to saving");
            currentStep = DemoStep.MindrSaving;
            EnableCorrectUIControls();
            Log.Debug("ASADemo", "creating anchor");
            CloudSpatialAnchor cloudAnchor = new CloudSpatialAnchor();

            visual.CloudAnchor      = cloudAnchor;
            cloudAnchor.LocalAnchor = visual.LocalAnchor;

            cloudAnchorManager.CreateAnchorAsync(cloudAnchor)
            .ContinueWith(async cloudAnchorTask =>
            {
                try
                {
                    CloudSpatialAnchor anchor = await cloudAnchorTask;

                    string anchorId = anchor.Identifier;

                    Log.Debug("ASADemo:", "created anchor: " + anchorId);

                    Log.Debug("ASADemo", "recording anchor with web service");
                    Log.Debug("ASADemo", "anchorId: " + anchorId);

                    //SendAnchorResponse response = await this.anchorSharingServiceClient.SendAnchorIdAsync(anchorId);

                    var saveAnchorResult = await _mindrService.CreateAnchorAsync(anchorNumInput.Text, anchor.Identifier);
                    if (saveAnchorResult != null)
                    {
                        CrossClipboard.Current.SetText($"{MindrService.MindrService.BaseUrl}{saveAnchorResult.uri}");
                        visual.SetColor(savedColor);
                        AnchorPosted("");

                        await Task.Delay(1000);
                        RunOnUiThread(() =>
                        {
                            var shareIntent = new Intent(Android.Content.Intent.ActionSend);
                            shareIntent.SetType("text/plain");
                            shareIntent.PutExtra(Intent.ExtraText, $"{MindrService.MindrService.BaseUrl}{saveAnchorResult.uri}");
                            StartActivity(shareIntent);
                        });
                        await Task.Delay(1000);

                        RunOnUiThread(LocateAllAnchors);
                    }
                    else
                    {
                        visual.SetColor(failedColor);
                        await cloudAnchorManager.DeleteAnchorAsync(anchor);
                    }

                    anchorVisuals[anchorId] = visual;
                    anchorVisuals.TryRemove(string.Empty, out _);
                }
                catch (CloudSpatialException ex)
                {
                    CreateAnchorExceptionCompletion($"{ex.Message}, {ex.ErrorCode}");
                }
                catch (Exception ex)
                {
                    CreateAnchorExceptionCompletion(ex.Message);
                    visual.SetColor(failedColor);
                }
            });
        }
示例#33
0
    // Update is called once per frame
    void Update()
    {
        if (currentStep == DemoStep.Step0) {
            if ((int)(wilsonState & WilsonState.Rest) == 0) {
                waitTimer.Interval = WAIT_TIME + initialLeaderTime;
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Rest;
                Rest ();
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "Let's build a staircase!");
                }
            }
        }

        if (currentStep == DemoStep.Step1A) {
            goBack = false;
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block4"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "Take that block");
                }
            }
        }

        if (currentStep == DemoStep.Step1B) {
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block3"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And that block");
                }
            }
        }

        if (currentStep == DemoStep.Step1C) {
            if ((int)(wilsonState & WilsonState.LookForward) == 0) {
                wilsonState |= WilsonState.LookForward;
                LookForward ();
            }

            leftTarget.targetPosition = new Vector3 (1.0f, 2.5f, 0.0f);
            rightTarget.targetPosition = new Vector3 (-1.0f, 2.5f, 0.0f);

            if (leftAtTarget && rightAtTarget) {
                currentStep = (DemoStep)((int)currentStep + 1);
            }
        }

        if (currentStep == DemoStep.Step1D) {
            if ((int)(wilsonState & WilsonState.PushTogether) == 0) {
                wilsonState |= WilsonState.PushTogether;
                PushTogether ();
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And put them together");
                }
            }
            else {
                bool satisfied = false;
                foreach (List<GameObject> key in relationTracker.relations.Keys) {
                    if (key.SequenceEqual (new List<GameObject> (new GameObject[] {
                        GameObject.Find ("block4"),
                        GameObject.Find ("block3")
                    }))) {
                        string[] relations = relationTracker.relations [key].ToString ().Split (',');
                        if (relations.Contains ("left") && relations.Contains ("touching")) {
                            satisfied = true;
                            break;
                        }
                    }
                }

                if (humanMoveComplete) {
                    if (satisfied) {
                        if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod);
                            ThumbsUp ();
                            HeadNod ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "Great!");
                            }
                        }
                    }
                    else {
                        if ((int)(wilsonState & WilsonState.HeadShake) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= WilsonState.HeadShake;
                            HeadShake ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "That's not quite what I had in mind.");
                                goBack = true;
                            }
                        }
                    }
                }
            }
        }

        if (currentStep == DemoStep.Step2A) {
            goBack = false;
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block6"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "Take that block");
                }
            }
        }

        if (currentStep == DemoStep.Step2B) {
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block3"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And that block");
                }
            }
        }

        if (currentStep == DemoStep.Step2C) {
            if ((int)(wilsonState & WilsonState.LookForward) == 0) {
                wilsonState |= WilsonState.LookForward;
                LookForward ();
            }

            leftTarget.targetPosition = new Vector3 (1.0f, 2.5f, 0.0f);
            rightTarget.targetPosition = new Vector3 (-1.0f, 2.5f, 0.0f);

            if (leftAtTarget && rightAtTarget) {
                currentStep = (DemoStep)((int)currentStep + 1);
            }
        }

        if (currentStep == DemoStep.Step2D) {
            if ((int)(wilsonState & WilsonState.PushTogether) == 0) {
                wilsonState |= WilsonState.PushTogether;
                PushTogether ();
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And put them together");
                }
            }
            else {
                bool satisfied = false;
                foreach (List<GameObject> key in relationTracker.relations.Keys) {
                    if (key.SequenceEqual (new List<GameObject> (new GameObject[] {
                        GameObject.Find ("block6"),
                        GameObject.Find ("block3")
                    }))) {
                        string[] relations = relationTracker.relations [key].ToString ().Split (',');
                        if (relations.Contains ("right") && relations.Contains ("touching")) {
                            satisfied = true;
                            break;
                        }
                    }
                }

                if (humanMoveComplete) {
                    if (satisfied) {
                        if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod);
                            ThumbsUp ();
                            HeadNod ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "Great!");
                            }
                        }
                    }
                    else {
                        if ((int)(wilsonState & WilsonState.HeadShake) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= WilsonState.HeadShake;
                            HeadShake ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "That's not quite what I had in mind.");
                                goBack = true;
                            }
                        }
                    }
                }
            }
        }

        if (currentStep == DemoStep.Step3A) {
            goBack = false;
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block5"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "Take that block");
                }
            }
        }

        if (currentStep == DemoStep.Step3B) {
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block6"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And put it on that block");
                }
            }
        }

        if (currentStep == DemoStep.Step3C) {
            if ((int)(wilsonState & WilsonState.Claw) == 0) {
                wilsonState |= (WilsonState.Claw | WilsonState.LookForward);
                Claw (GameObject.Find ("block5").transform.position, GameObject.Find ("block6").transform.position);
                LookForward ();
            }
            else {
                bool satisfied = false;
                foreach (List<GameObject> key in relationTracker.relations.Keys) {
                    if (key.SequenceEqual (new List<GameObject> (new GameObject[] {
                        GameObject.Find ("block6"),
                        GameObject.Find ("block5")
                    }))) {
                        string[] relations = relationTracker.relations [key].ToString ().Split (',');
                        if (relations.Contains ("support")) {
                            satisfied = true;
                            break;
                        }
                    }
                }

                if (humanMoveComplete) {
                    if (satisfied) {
                        if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod);
                            ThumbsUp ();
                            HeadNod ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "Great!");
                            }
                        }
                    }
                    else {
                        if ((int)(wilsonState & WilsonState.HeadShake) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= WilsonState.HeadShake;
                            HeadShake ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "That's not quite what I had in mind.");
                                goBack = true;
                            }
                        }
                    }
                }
            }
        }

        if (currentStep == DemoStep.Step4A) {
            goBack = false;
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block2"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "Take that block");
                }
            }
        }

        if (currentStep == DemoStep.Step4B) {
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block3"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And put it on that block");
                }
            };
        }

        if (currentStep == DemoStep.Step4C) {
            if ((int)(wilsonState & WilsonState.Claw) == 0) {
                wilsonState |= (WilsonState.Claw | WilsonState.LookForward);
                Claw (GameObject.Find ("block2").transform.position,GameObject.Find ("block3").transform.position);
                LookForward ();
            }
            else {
                bool satisfied = false;
                foreach (List<GameObject> key in relationTracker.relations.Keys) {
                    if (key.SequenceEqual (new List<GameObject> (new GameObject[] {
                        GameObject.Find ("block3"),
                        GameObject.Find ("block2")
                    }))) {
                        string[] relations = relationTracker.relations [key].ToString ().Split (',');
                        if (relations.Contains ("support")) {
                            satisfied = true;
                            break;
                        }
                    }
                }

                if (humanMoveComplete) {
                    if (satisfied) {
                        if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod);
                            ThumbsUp ();
                            HeadNod ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "Great!");
                            }
                        }
                    }
                    else {
                        if ((int)(wilsonState & WilsonState.HeadShake) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= WilsonState.HeadShake;
                            HeadShake ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "That's not quite what I had in mind.");
                                goBack = true;
                            }
                        }
                    }
                }
            }
        }

        if (currentStep == DemoStep.Step5A) {
            goBack = false;
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block1"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "Take that block");
                }
            }
        }

        if (currentStep == DemoStep.Step5B) {
            if ((int)(wilsonState & WilsonState.Point) == 0) {
                waitTimer.Enabled = true;
                wilsonState |= WilsonState.Point;
                PointAt (GameObject.Find ("block5"));
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "And put it on that block");
                }
            }
        }

        if (currentStep == DemoStep.Step5C) {
            if ((int)(wilsonState & WilsonState.Claw) == 0) {
                wilsonState |= (WilsonState.Claw | WilsonState.LookForward);
                Claw (GameObject.Find ("block1").transform.position,GameObject.Find ("block5").transform.position);
                LookForward ();
            }
            else {
                bool satisfied = false;
                foreach (List<GameObject> key in relationTracker.relations.Keys) {
                    if (key.SequenceEqual (new List<GameObject> (new GameObject[] {
                        GameObject.Find ("block5"),
                        GameObject.Find ("block1")
                    }))) {
                        string[] relations = relationTracker.relations [key].ToString ().Split (',');
                        if (relations.Contains ("support")) {
                            satisfied = true;
                            break;
                        }
                    }
                }

                if (humanMoveComplete) {
                    if (satisfied) {
                        if ((int)(wilsonState & (WilsonState.ThumbsUp | WilsonState.HeadNod)) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= (WilsonState.ThumbsUp | WilsonState.HeadNod);
                            ThumbsUp ();
                            HeadNod ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "Great!");
                            }
                        }
                    }
                    else {
                        if ((int)(wilsonState & WilsonState.HeadShake) == 0) {
                            waitTimer.Enabled = true;
                            wilsonState |= WilsonState.HeadShake;
                            HeadShake ();
                            if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                                OutputHelper.PrintOutput (OutputController.Role.Planner, "That's not quite what I had in mind.");
                                goBack = true;
                            }
                        }
                    }
                }
            }
        }

        if (currentStep == DemoStep.Step6) {
            if ((int)(wilsonState & WilsonState.Rest) == 0) {
                wilsonState |= WilsonState.Rest;
                Rest ();
                if ((int)(outputModality.modality & OutputModality.Modality.Linguistic) == 1) {
                    OutputHelper.PrintOutput (OutputController.Role.Planner, "OK, we're done!");
                }
            }
        }

        /*if (Input.GetKeyDown (KeyCode.Space)) {
            wilsonState = 0;
            currentStep = (DemoStep)((int)currentStep + 1);
        }*/
    }
        public async void LocateAllAnchors()
        {
            await Task.Delay(2000);

            textView.Text = "Searching for MindRs...";

            // clean up prev session just in case
            DestroySession();

            // start locating
            cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session);

            var anchorLocated = false;

            cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                  RunOnUiThread(async() =>
            {
                CloudSpatialAnchor anchor = args.Anchor;
                LocateAnchorStatus status = args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };

                    var mr = await _mindrService.TryGetContentsForAnchor(anchor.Identifier);
                    textView.Visibility = ViewStates.Visible;
                    textView.Text       = mr != null ? mr.actualDesc : "No data found for MindR.";

                    foundVisual.AnchorNode.SetParent(arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.AddToScene(arFragment, textView.Text);
                    anchorVisuals[cloudAnchorIdentifier] = foundVisual;


                    foundVisual.AnchorNode.SetOnTouchListener(this);
                    anchorLocated = true;
                }
            });

            cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) =>
            {
                currentStep = DemoStep.MindrStart;

                RunOnUiThread(() =>
                {
                    textView.Text = anchorLocated ? "MindR(s) located!" : "Failed to find any MindRs.";

                    EnableCorrectUIControls();
                });
            };

            cloudAnchorManager.StartSession();

            await Task.Delay(2000);

            var ac  = new AnchorLocateCriteria();
            var ids = await _mindrService.GetAllAnchorIds();

            ac.SetIdentifiers(ids.ToArray());
            cloudAnchorManager.StartLocating(ac);
        }