Exemplo n.º 1
0
        public virtual void InitActionObject(IO.Swagger.Model.SceneObject sceneObject, Vector3 position, Quaternion orientation, ActionObjectMetadata actionObjectMetadata, IO.Swagger.Model.CollisionModels customCollisionModels = null, bool loadResuources = true)
        {
            Data.Id              = sceneObject.Id;
            Data.Type            = sceneObject.Type;
            name                 = sceneObject.Name; // show actual object name in unity hierarchy
            ActionObjectMetadata = actionObjectMetadata;
            if (actionObjectMetadata.HasPose)
            {
                SetScenePosition(position);
                SetSceneOrientation(orientation);
            }
            CreateModel(customCollisionModels);
            enabled      = true;
            SelectorItem = SelectorMenu.Instance.CreateSelectorItem(this);
            if (VRModeManager.Instance.VRModeON)
            {
                SetVisibility(PlayerPrefsHelper.LoadFloat("AOVisibilityVR", 1f));
            }
            else
            {
                SetVisibility(PlayerPrefsHelper.LoadFloat("AOVisibilityAR", 0f));
            }

            if (PlayerPrefsHelper.LoadBool($"ActionObject/{GetId()}/blocklisted", false))
            {
                Enable(false, true, false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="metadata"></param>
 /// <param name="callback">Function to be called if adding action object was successful</param>
 public void InitFromMetadata(Base.ActionObjectMetadata metadata, System.Action callback = null)
 {
     InitDialog(metadata);
     actionParameters = Base.Parameter.InitParameters(parametersMetadata.Values.ToList(), DynamicContent, OnChangeParameterHandler, DynamicContentLayout, CanvasRoot, false, false, null);
     nameInput.SetValue(Base.SceneManager.Instance.GetFreeAOName(metadata.Type));
     this.callback = callback;
 }
Exemplo n.º 3
0
 public virtual void InitActionObject(string id, string type, Vector3 position, Quaternion orientation, string uuid, ActionObjectMetadata actionObjectMetadata, IO.Swagger.Model.CollisionModels customCollisionModels = null, bool loadResuources = true)
 {
     Data.Id   = id;
     Data.Type = type;
     SetScenePosition(position);
     SetSceneOrientation(orientation);
     Data.Id = uuid;
     ActionObjectMetadata = actionObjectMetadata;
     CreateModel(customCollisionModels);
     enabled    = true;
     visibility = PlayerPrefsHelper.LoadFloat(SceneManager.Instance.SceneMeta.Id + "/ActionObject/" + id + "/visibility", 1);
     SetVisibility(visibility);
 }
Exemplo n.º 4
0
 public override void InitActionObject(string id, string type, Vector3 position, Quaternion orientation, string uuid, ActionObjectMetadata actionObjectMetadata, IO.Swagger.Model.CollisionModels customCollisionModels = null)
 {
     base.InitActionObject(id, type, position, orientation, uuid, actionObjectMetadata);
     SceneManager.Instance.OnUrdfReady += OnUrdfDownloaded;
     Data.Id   = id;
     Data.Type = type;
     SetScenePosition(position);
     SetSceneOrientation(orientation);
     Data.Id = uuid;
     ActionObjectMetadata = actionObjectMetadata;
     CreateModel(customCollisionModels);
     enabled = true;
     SetVisibility(visibility);
 }
Exemplo n.º 5
0
    public void InitDialog(ActionObjectMetadata metadata)
    {
        actionObjectMetadata = metadata;

        parametersMetadata = new Dictionary <string, ParameterMetadata>();
        foreach (IO.Swagger.Model.ParameterMeta meta in metadata.Settings)
        {
            parametersMetadata.Add(meta.Name, new ParameterMetadata(meta));
        }

        foreach (Transform t in DynamicContent.transform)
        {
            Destroy(t.gameObject);
        }
        nameInput.SetLabel("Name", "Name of the action object");
        nameInput.SetType("string");
    }
Exemplo n.º 6
0
        public async override void InitActionObject(IO.Swagger.Model.SceneObject sceneObject, Vector3 position, Quaternion orientation, ActionObjectMetadata actionObjectMetadata, IO.Swagger.Model.CollisionModels customCollisionModels = null, bool loadResources = true)
        {
            base.InitActionObject(sceneObject, position, orientation, actionObjectMetadata);

            // if there should be an urdf robot model
            if (ActionsManager.Instance.RobotsMeta.TryGetValue(sceneObject.Type, out RobotMeta robotMeta))
            {
                RobotMeta = robotMeta;
                if (!string.IsNullOrEmpty(robotMeta.UrdfPackageFilename))
                {
                    // Get the robot model, if it returns null, the robot will be loading itself
                    RobotModel = UrdfManager.Instance.GetRobotModelInstance(robotMeta.Type, robotMeta.UrdfPackageFilename);

                    if (RobotModel != null)
                    {
                        RobotModelLoaded();
                    }
                    else
                    {
                        // Robot is not loaded yet, let's wait for it to be loaded
                        UrdfManager.Instance.OnRobotUrdfModelLoaded += OnRobotModelLoaded;
                        modelLoading = true;
                    }
                }
            }

            ResourcesLoaded = false;
        }
Exemplo n.º 7
0
 public virtual void InitActionObject(string id, string type, Vector3 position, Quaternion orientation, string uuid, ActionObjectMetadata actionObjectMetadata)
 {
     visibility = PlayerPrefsHelper.LoadFloat(Scene.Instance.Data.Id + "/ActionObject/" + id + "/visibility", 1);
 }
Exemplo n.º 8
0
 public virtual void InitActionObject(string id, string type, Vector3 position, Quaternion orientation, string uuid, ActionObjectMetadata actionObjectMetadata, IO.Swagger.Model.CollisionModels customCollisionModels = null)
 {
     visibility = PlayerPrefsHelper.LoadFloat(SceneManager.Instance.Scene.Id + "/ActionObject/" + id + "/visibility", 1);
 }
Exemplo n.º 9
0
        public async override void InitActionObject(string id, string type, Vector3 position, Quaternion orientation, string uuid, ActionObjectMetadata actionObjectMetadata, IO.Swagger.Model.CollisionModels customCollisionModels = null, bool loadResources = true)
        {
            base.InitActionObject(id, type, position, orientation, uuid, actionObjectMetadata);
            //UrdfManager.Instance.OnUrdfReady += OnUrdfDownloaded;

            // if there should be an urdf robot model
            if (ActionsManager.Instance.RobotsMeta.TryGetValue(type, out RobotMeta robotMeta) && !string.IsNullOrEmpty(robotMeta.UrdfPackageFilename))
            {
                // check if robot model exists
                if (UrdfManager.Instance.CheckIfRobotModelExists(type))
                {
                    // check if newer robot model exists on the server
                    if (UrdfManager.Instance.CheckIfNewerRobotModelExists(robotMeta.UrdfPackageFilename, type))
                    {
                        // TODO destroy the old robot version
                        UrdfManager.Instance.RemoveOldModels(type);

                        // download newer version of the urdf
                        UrdfManager.Instance.OnRobotUrdfModelLoaded += OnRobotModelLoaded;
                        StartCoroutine(UrdfManager.Instance.DownloadUrdfPackage(robotMeta.UrdfPackageFilename, robotMeta.Type));
                    }
                    else
                    {
                        // get the robot model
                        RobotModel = UrdfManager.Instance.GetRobotModelInstance(type);
                        if (RobotModel != null)
                        {
                            RobotModelLoaded();
                        }
                        else
                        {
                            Debug.LogError("Fatal error, robot model should be present and loaded, but it is not. Report bug.");
                        }
                    }
                }
                // robot model is not loaded at all, check if urdf is downloaded locally and import it, otherwise download it
                else
                {
                    // check if newer robot model exists on the server.. if it is not downloaded at all, it will return true
                    if (UrdfManager.Instance.CheckIfNewerRobotModelExists(robotMeta.UrdfPackageFilename, type))
                    {
                        UrdfManager.Instance.OnRobotUrdfModelLoaded += OnRobotModelLoaded;
                        StartCoroutine(UrdfManager.Instance.DownloadUrdfPackage(robotMeta.UrdfPackageFilename, robotMeta.Type));
                    }
                    else     // the robot zip is downloaded, thus start direct build
                    {
                        UrdfManager.Instance.OnRobotUrdfModelLoaded += OnRobotModelLoaded;
                        UrdfManager.Instance.BuildRobotModelFromUrdf(type);
                    }
                }
            }
            //LoadResources = loadResources;
            ResourcesLoaded = false;
        }