Esempio n. 1
0
    public async void StartObjectFocusing()
    {
        if (RobotsList.Dropdown.dropdownItems.Count == 0 || EndEffectorList.Dropdown.dropdownItems.Count == 0)
        {
            Base.NotificationsModernUI.Instance.ShowNotification("Failed to update object position", "No robot or end effector available");
            return;
        }
        try {
            await WebsocketManager.Instance.StartObjectFocusing(CurrentObject.Data.Id,
                                                                (string)RobotsList.GetValue(),
                                                                (string)EndEffectorList.GetValue());

            currentFocusPoint = 0;
            UpdateCurrentPointLabel();
            GetComponent <SimpleSideMenu>().handleToggleStateOnPressed = false;
            GetComponent <SimpleSideMenu>().overlayCloseOnPressed      = false;
            FocusObjectDoneButton.interactable = true;
            if (CurrentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints.Count > 1)
            {
                NextButton.interactable     = true;
                PreviousButton.interactable = true;
            }
        } catch (Base.RequestFailedException ex) {
            Base.NotificationsModernUI.Instance.ShowNotification("Failed to start object focusing", ex.Message);
            CurrentPointLabel.text = "";
            currentFocusPoint      = -1;
            if (ex.Message == "Focusing already started.")   //TODO HACK! find better solution
            {
                FocusObjectDone();
            }
        }
    }
Esempio n. 2
0
    private void UpdateModelOnEE()
    {
        if (model == null)
        {
            return;
        }
        string robotName = (string)RobotsList.GetValue(), eeId = (string)EndEffectorList.GetValue();

        if (string.IsNullOrEmpty(robotName) || string.IsNullOrEmpty(eeId))
        {
            throw new RequestFailedException("Robot or end effector not selected!");
        }

        try {
            string  robotId = SceneManager.Instance.RobotNameToId(robotName);
            RobotEE ee      = SceneManager.Instance.GetRobot(robotId).GetEE(eeId);
            model.transform.parent = ee.gameObject.transform;

            switch ((PivotEnum)Enum.Parse(typeof(PivotEnum), (string)PivotList.GetValue()))
            {
            case PivotEnum.Top:
                model.transform.localPosition = new Vector3(0, model.transform.localScale.y / 2, 0);
                break;

            case PivotEnum.Bottom:
                model.transform.localPosition = new Vector3(0, -model.transform.localScale.y / 2, 0);
                break;

            case PivotEnum.Middle:
                model.transform.localPosition = new Vector3(0, 0, 0);
                break;
            }
            model.transform.localRotation = new Quaternion(0, 0, 0, 1);
        } catch (ItemNotFoundException ex) {
            Debug.LogError(ex);
            Notifications.Instance.ShowNotification("End-effector position unknown", "Robot did not send position of selected end effector");
            ShowModelSwitch.Switch.isOn = false;
        }
    }
Esempio n. 3
0
 public async void UpdateObjectPosition()
 {
     if (RobotsList.Dropdown.dropdownItems.Count == 0 || EndEffectorList.Dropdown.dropdownItems.Count == 0)
     {
         Base.NotificationsModernUI.Instance.ShowNotification("Failed to update object position", "No robot or end effector available");
         return;
     }
     PivotEnum pivot = (PivotEnum)Enum.Parse(typeof(PivotEnum), (string)PivotList.GetValue());
     IRobot    robot = SceneManager.Instance.GetRobotByName((string)RobotsList.GetValue());
     await WebsocketManager.Instance.UpdateActionObjectPoseUsingRobot(CurrentObject.Data.Id,
                                                                      robot.GetId(), (string)EndEffectorList.GetValue(), pivot);
 }
Esempio n. 4
0
    public async void AddOrientation()
    {
        Debug.Assert(CurrentActionPoint != null);


        string name = NameInput.text;

        try {
            if (ManualMode)
            {
                Orientation orientation = OrientationManualEdit.GetOrientation();
                await WebsocketManager.Instance.AddActionPointOrientation(CurrentActionPoint.Data.Id, orientation, name);
            }
            else     //using robot

            {
                string robotId = SceneManager.Instance.RobotNameToId((string)RobotsList.GetValue());
                await WebsocketManager.Instance.AddActionPointOrientationUsingRobot(CurrentActionPoint.Data.Id, robotId, (string)EndEffectorList.GetValue(), name);
            }
            Close(); //close add menu
            Notifications.Instance.ShowToastMessage("Orientation added successfully");
        } catch (ItemNotFoundException ex) {
            Notifications.Instance.ShowNotification("Failed to add new orientation", ex.Message);
        } catch (RequestFailedException ex) {
            Notifications.Instance.ShowNotification("Failed to add new orientation", ex.Message);
        }
    }
Esempio n. 5
0
 public async void MoveHereRobot()
 {
     try {
         if (isOrientationDetail)
         {
             string robotId = SceneManager.Instance.RobotNameToId((string)RobotsList.GetValue());
             await WebsocketManager.Instance.MoveToActionPointOrientation(robotId, (string)EndEffectorList.GetValue(), (decimal)SpeedSlider.value, orientation.Id);
         }
         else
         {
             await WebsocketManager.Instance.MoveToActionPointJoints(joints.RobotId, (decimal)SpeedSlider.value, joints.Id);
         }
     } catch (ItemNotFoundException ex) {
         Notifications.Instance.ShowNotification("Failed to move robot", ex.Message);
     } catch (RequestFailedException ex) {
         Notifications.Instance.ShowNotification("Failed to move robot", ex.Message);
     }
 }
Esempio n. 6
0
    /// <summary>
    /// Shows confirmation dialog for updating orientation/joints using robot
    /// </summary>
    public void ShowUpdateUsingRobotDialog()
    {
        string title       = isOrientationDetail ? "Update orientation" : "Update joints";
        string description = "Do you want to update ";

        if (isOrientationDetail)
        {
            description += "orientation using robot: " + (string)RobotsList.GetValue() + " and end effector: " + (string)EndEffectorList.GetValue() + "?";
        }
        else
        {
            description += "joints using robot: " + RobotName.text + "?";
        }
        ConfirmationDialog.Open(title,
                                description,
                                () => UpdateUsingRobot(),
                                () => ConfirmationDialog.Close());
    }
Esempio n. 7
0
    public async void UpdateUsingRobot()
    {
        if (isOrientationDetail)
        {
            try {
                string robotId = SceneManager.Instance.RobotNameToId((string)RobotsList.GetValue());
                await WebsocketManager.Instance.UpdateActionPointOrientationUsingRobot(robotId, (string)EndEffectorList.GetValue(), orientation.Id);

                Notifications.Instance.ShowToastMessage("Orientation updated successfully");
            } catch (ItemNotFoundException ex) {
                Debug.LogError(ex);
                Notifications.Instance.ShowNotification("Failed update orientation", ex.Message);
            } catch (RequestFailedException ex) {
                Notifications.Instance.ShowNotification("Failed to update orientation", ex.Message);
            }
        }
        else //joints
        {
            try {
                await WebsocketManager.Instance.UpdateActionPointJointsUsingRobot(joints.Id);

                Notifications.Instance.ShowToastMessage("Joints updated successfully");
            } catch (RequestFailedException ex) {
                Notifications.Instance.ShowNotification("Failed to update joints", ex.Message);
            }
        }
        ConfirmationDialog.Close();
        UpdateMenu();
    }