private void SelectEndEffector(object selectedObject) { if (selectedObject == null) { return; } RobotEE endEffector = (RobotEE)selectedObject; SceneManager.Instance.SelectRobotAndEE(endEffector); Notifications.Instance.ShowToastMessage($"Selected EE {endEffector.GetName()} on robot {SceneManager.Instance.SelectedRobot.GetName()}" + (SceneManager.Instance.SelectedRobot.MultiArm() ? $" (arm {SceneManager.Instance.SelectedArmId})" : "")); }
private RobotEE CreateEndEffector(string armId, string eeId) { RobotEE ee = Instantiate(SceneManager.Instance.RobotEEPrefab, EEOrigin.transform).GetComponent <RobotEE>(); ee.InitEE(this, armId, eeId); ee.gameObject.SetActive(false); if (!EndEffectors.ContainsKey(armId)) { EndEffectors.Add(armId, new List <RobotEE>()); } EndEffectors[armId].Add(ee); return(ee); }
public async Task LoadEndEffectors() { GameManager.Instance.ShowLoadingScreen("Loading end effectors of robot " + Data.Name); List <string> endEffectors = await WebsocketManager.Instance.GetEndEffectors(Data.Id); foreach (string eeId in endEffectors) { RobotEE ee = Instantiate(SceneManager.Instance.RobotEEPrefab, EEOrigin.transform).GetComponent <RobotEE>(); ee.InitEE(this, eeId); ee.gameObject.SetActive(false); EndEffectors.Add(ee); } GameManager.Instance.HideLoadingScreen(); }
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; } }