Example #1
0
    public async void FocusObjectDone()
    {
        try {
            CurrentPointLabel.text = "";

            // TODO: znovupovolit zavření menu
            //GetComponent<SimpleSideMenu>().handleToggleStateOnPressed = true;
            //GetComponent<SimpleSideMenu>().overlayCloseOnPressed = true;
            currentFocusPoint = -1;

            await WebsocketManager.Instance.ObjectAimingDone();

            FocusObjectDoneButton.SetInteractivity(false, "No aiming in progress");
            CancelAimingButton.SetInteractivity(false, "No aiming in progress");
            NextButton.SetInteractivity(false, "No aiming in progress");
            PreviousButton.SetInteractivity(false, "No aiming in progress");
            SavePositionButton.SetInteractivity(false, "No aiming in progress");
            StartObjectFocusingButton.SetInteractivity(true);
            if (currentObject is ActionObject3D actionObject3D)
            {
                actionObject3D.Highlight();
            }
            AimingInProgress = false;
        } catch (Base.RequestFailedException ex) {
            Base.NotificationsModernUI.Instance.ShowNotification("Failed to focus object", ex.Message);
        }
    }
Example #2
0
    public async void StartObjectFocusing()
    {
        if (!SceneManager.Instance.IsRobotAndEESelected())
        {
            Base.NotificationsModernUI.Instance.ShowNotification("Failed to update object position", "No robot or end effector available");
            return;
        }
        try {
            AimingInProgress = true;
            string armId = null;
            if (SceneManager.Instance.SelectedRobot.MultiArm())
            {
                armId = SceneManager.Instance.SelectedArmId;
            }
            await WebsocketManager.Instance.ObjectAimingStart(currentObject.Data.Id,
                                                              SceneManager.Instance.SelectedRobot.GetId(),
                                                              SceneManager.Instance.SelectedEndEffector.GetName(),
                                                              armId);

            currentFocusPoint = 0;
            UpdateCurrentPointLabel();
            //TODO: ZAJISTIT ABY MENU NEŠLO ZAVŘÍT když běží focusing - ideálně nějaký dialog
            //GetComponent<SimpleSideMenu>().handleToggleStateOnPressed = false;
            //GetComponent<SimpleSideMenu>().overlayCloseOnPressed = false;

            await CheckDoneBtn();

            SavePositionButton.SetInteractivity(true);
            CancelAimingButton.SetInteractivity(true);
            StartObjectFocusingButton.SetInteractivity(false, "Already aiming");
            if (currentObject is ActionObject3D actionObject3D)
            {
                actionObject3D.UnHighlight();
            }
            if (!automaticPointSelection && currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints.Count > 1)
            {
                NextButton.SetInteractivity(true);
                PreviousButton.SetInteractivity(true);
                PreviousPoint();
            }
            foreach (AimingPointSphere sphere in spheres)
            {
                sphere.SetAimed(false);
            }
        } catch (Base.RequestFailedException ex) {
            Base.NotificationsModernUI.Instance.ShowNotification("Failed to start object focusing", ex.Message);
            CurrentPointLabel.text = "";
            currentFocusPoint      = -1;
            AimingInProgress       = false;
            if (currentObject is ActionObject3D actionObject3D)
            {
                actionObject3D.Highlight();
            }
            if (ex.Message == "Focusing already started.")   //TODO HACK! find better solution
            {
                FocusObjectDone();
            }
        }
    }
Example #3
0
 private void DisableFocusControls()
 {
     SavePositionButton.GetComponent <Button>().interactable        = false;
     StartObjectFocusingButton.GetComponent <Button>().interactable = false;
     NextButton.GetComponent <Button>().interactable            = false;
     PreviousButton.GetComponent <Button>().interactable        = false;
     FocusObjectDoneButton.GetComponent <Button>().interactable = false;
 }
Example #4
0
    public async Task UpdateMenu()
    {
        CalibrateBtn.gameObject.SetActive(false);


        if (!SceneManager.Instance.SceneStarted)
        {
            UpdatePositionBlockVO.SetActive(false);
            UpdatePositionBlockMesh.SetActive(false);
            Hide();
            return;
        }


        CalibrateBtn.Button.onClick.RemoveAllListeners();
        if (currentObject.IsRobot())
        {
            CalibrateBtn.gameObject.SetActive(true);
            CalibrateBtn.SetDescription("Calibrate robot");
            CalibrateBtn.Button.onClick.AddListener(() => ShowCalibrateRobotDialog());
            if (SceneManager.Instance.GetCamerasNames().Count > 0)
            {
                CalibrateBtn.SetInteractivity(true);
            }
            else
            {
                CalibrateBtn.SetInteractivity(false, "Could not calibrate robot without camera");
            }
        }
        else if (currentObject.IsCamera())
        {
            CalibrateBtn.gameObject.SetActive(true);
            CalibrateBtn.SetDescription("Calibrate camera");
            CalibrateBtn.Button.onClick.AddListener(() => ShowCalibrateCameraDialog());
        }

        if (SceneManager.Instance.IsRobotAndEESelected())
        {
            if (currentObject.ActionObjectMetadata.ObjectModel?.Type == IO.Swagger.Model.ObjectModel.TypeEnum.Mesh &&
                currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints?.Count > 0)
            {
                UpdatePositionBlockVO.SetActive(false);
                UpdatePositionBlockMesh.SetActive(true);
                int idx = 0;
                foreach (AimingPointSphere sphere in spheres)
                {
                    if (sphere != null)
                    {
                        Destroy(sphere.gameObject);
                    }
                }
                spheres.Clear();
                foreach (IO.Swagger.Model.Pose point in currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints)
                {
                    AimingPointSphere sphere = Instantiate(Sphere, currentObject.transform).GetComponent <AimingPointSphere>();
                    sphere.transform.localScale    = new Vector3(0.02f, 0.02f, 0.02f);
                    sphere.transform.localPosition = TransformConvertor.ROSToUnity(DataHelper.PositionToVector3(point.Position));
                    sphere.transform.localRotation = TransformConvertor.ROSToUnity(DataHelper.OrientationToQuaternion(point.Orientation));
                    sphere.Init(idx, $"Aiming point #{idx}");
                    spheres.Add(sphere);
                    ++idx;
                }
                try {
                    List <int> finishedIndexes = await WebsocketManager.Instance.ObjectAimingAddPoint(0, true);

                    foreach (AimingPointSphere sphere in spheres)
                    {
                        sphere.SetAimed(finishedIndexes.Contains(sphere.Index));
                    }
                    if (!automaticPointSelection)
                    {
                        currentFocusPoint = 0;
                    }
                    StartObjectFocusingButton.SetInteractivity(false, "Already started");
                    SavePositionButton.SetInteractivity(true);
                    CancelAimingButton.SetInteractivity(true);
                    await CheckDoneBtn();

                    AimingInProgress = true;
                    if (currentObject is ActionObject3D actionObject3D)
                    {
                        actionObject3D.UnHighlight();
                    }
                    UpdateCurrentPointLabel();
                    if (!automaticPointSelection && currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints.Count > 1)
                    {
                        NextButton.SetInteractivity(true);
                        PreviousButton.SetInteractivity(true);
                        PreviousPoint();
                    }
                } catch (RequestFailedException ex) {
                    StartObjectFocusingButton.SetInteractivity(true);
                    FocusObjectDoneButton.SetInteractivity(false, "No aiming in progress");
                    NextButton.SetInteractivity(false, "No aiming in progress");
                    PreviousButton.SetInteractivity(false, "No aiming in progress");
                    SavePositionButton.SetInteractivity(false, "No aiming in progress");
                    CancelAimingButton.SetInteractivity(false, "No aiming in progress");
                    AimingInProgress = false;
                    if (currentObject is ActionObject3D actionObject3D)
                    {
                        actionObject3D.Highlight();
                    }
                }
            }
            else if (!currentObject.IsRobot() && !currentObject.IsCamera() && currentObject.ActionObjectMetadata.ObjectModel != null)
            {
                UpdatePositionBlockVO.SetActive(true);
                UpdatePositionBlockMesh.SetActive(false);
                ShowModelSwitch.Interactable = SceneManager.Instance.RobotsEEVisible;
                if (ShowModelSwitch.Interactable && ShowModelSwitch.Switch.isOn)
                {
                    ShowModelOnEE();
                }
            }
            else
            {
                UpdatePositionBlockVO.SetActive(false);
                UpdatePositionBlockMesh.SetActive(false);
            }
        }
        else
        {
            UpdatePositionBlockVO.SetActive(false);
            UpdatePositionBlockMesh.SetActive(false);
        }
    }