示例#1
0
        /// <summary>
        /// Removes a ROS Actor. Is useful so objects can disconnect from the ROSBridge if they are not active and do not need to be to connected again.
        /// </summary>
        /// <param name="rosObject"></param>
        public void RemoveROSActor(ROSObject rosObject)
        {
            //Debug.Log("[ROSBridge] Removing ROS Actor");
            //IF not added yet but on "todo list"
            if (m_ROSObjectsToAdd.Contains(rosObject))
            {
                m_ROSObjectsToAdd.Remove(rosObject);
            }

            if (!m_ROSInitialized)
            {
                return;
            }

            if (!m_ROSObjects.Contains(rosObject))
            {
                return;
            }

            var subscribers = rosObject.GetComponents <ROSBridgeSubscriber>();
            var publishers  = rosObject.GetComponents <ROSBridgePublisher>();
            var services    = rosObject.GetComponents <ROSBridgeService>();

            foreach (var sub in subscribers)
            {
                m_ROS.RemoveSubscriber(sub.GetType());
            }

            foreach (var pub in publishers)
            {
                m_ROS.RemovePublisher(pub.GetType());
            }

            foreach (var serv in services)
            {
                m_ROS.RemoveServiceResponse(serv.GetType());
            }

            m_ROSObjects.Remove(rosObject);
        }
示例#2
0
 /// <summary>
 /// Adds a ROS Actor aka. Publisher, Subscriber, Service to the ROSBridge.
 /// Components will be checked and announced as soon as connection is established
 /// </summary>
 /// <param name="rosObject"></param>
 public void AddROSActor(ROSObject rosObject)
 {
     // add the rosobjects to "TODO list" so we can add them later
     m_ROSObjectsToAdd.Add(rosObject);
     return;
 }