Esempio n. 1
0
        /// <summary>
        /// Interprets the received list and spawns / destroys instances of robots
        /// </summary>
        /// <param name="runningInstances">Instances of robots that should be synchronized with the scene</param>
        private void ReceiveMessage(RunningInstance[] runningInstances)
        {
#if DEBUG
            Debug.Log($"Recevied {runningInstances.Length} filtered instances");
#endif
            foreach (var instance in runningInstances)
            {
                if (!currentSceneDicionary.ContainsKey(instance.inst.inst_id))
                {
                    //object does not exist. Create it.
                    UrdfSyncher syncher = new UrdfSyncher(SceneContainerObject, transform.GetComponent <RosConnector>(), instance.comp.pretty_name, RobotContainerPrefab);
                    currentSceneDicionary[instance.inst.inst_id] = syncher;
                }

                currentSceneDicionary[instance.inst.inst_id].SynchUrdf(instance.inst.urdf_dyn);
            }

            //Destroy components that are not present anymore
            for (int i = currentSceneDicionary.Values.Count - 1; i >= 0; i--)
            {
                var currentInstance = currentSceneDicionary.Values.ElementAt(i);
                var currentKey      = currentSceneDicionary.Keys.ElementAt(i);
                if (!runningInstances.Any(x => x.inst.inst_id == currentKey))
                {
                    currentInstance.Destroy();
                    currentSceneDicionary.Remove(currentKey);
                }
            }

            AttachablesManager.Instance.ReapplyMaterials();
        }
Esempio n. 2
0
 public void Awake()
 {
     if (UIHandler != null)
     {
         RosSharp.Output.SetHandlers(UIHandler.ShowText, UIHandler.ShowError);
     }
     UrdfSyncher.InitializeUrdfSyncher();
 }