public async void AddOrientation(string name, string robotName) { Debug.Assert(CurrentActionPoint != null); IRobot robot; try { robot = SceneManager.Instance.GetRobotByName(robotName); } catch (ItemNotFoundException ex) { Notifications.Instance.ShowNotification("Failed to add orientation", "Could not found robot called: " + robotName); Debug.LogError(ex); return; } if (CurrentActionPoint.OrientationNameExist(name) || CurrentActionPoint.JointsNameExist(name)) { Notifications.Instance.ShowNotification("Failed to add orientation", "There already exists orientation or joints with name " + name); return; } IO.Swagger.Model.Orientation orientation = new IO.Swagger.Model.Orientation(); if (CurrentActionPoint.Parent != null) { orientation = DataHelper.QuaternionToOrientation(TransformConvertor.UnityToROS(Quaternion.Inverse(CurrentActionPoint.Parent.GetTransform().rotation))); } preselectedOrientation = name; bool successOrientation = await Base.GameManager.Instance.AddActionPointOrientation(CurrentActionPoint, orientation, name); bool successJoints = await Base.GameManager.Instance.AddActionPointJoints(CurrentActionPoint, name, robot.GetId()); if (successOrientation && successJoints) { inputDialog.Close(); } else { preselectedOrientation = null; } }
public static Quaternion OrientationToQuaternion(IO.Swagger.Model.Orientation orientation) => new Quaternion((float)orientation.X, (float)orientation.Y, (float)orientation.Z, (float)orientation.W);
public void SetOrientation(IO.Swagger.Model.Orientation orientation) { transform.localRotation = TransformConvertor.ROSToUnity(DataHelper.OrientationToQuaternion(orientation)); }