Beispiel #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);
        }
    }
Beispiel #2
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;
 }
Beispiel #3
0
    private async Task CheckDoneBtn()
    {
        try {
            await WebsocketManager.Instance.ObjectAimingDone(true);

            FocusObjectDoneButton.SetInteractivity(true);
        } catch (RequestFailedException ex) {
            FocusObjectDoneButton.SetInteractivity(false, ex.Message);
        }
    }
Beispiel #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);
        }
    }