def waitForSync()

in src/pyrobot/utils/planning_scene_interface.py [0:0]


    def waitForSync(self, max_time=2.0):
        """
        Clears and syncs the planning scene
        """
        sync = False
        t = rospy.Time.now()
        while not sync:
            sync = True
            # delete objects that should be gone
            for name in self._collision:
                if name in self._removed.keys():
                    # should be removed, is not
                    rospy.logwarn("ObjectManager: %s not removed yet", name)
                    self.removeCollisionObject(name, False)
                    sync = False
            for name in self._attached:
                if name in self._attached_removed.keys():
                    # should be removed, is not
                    rospy.logwarn(
                        "ObjectManager: Attached object name: %s not removed yet", name
                    )
                    self.removeAttachedObject(name, False)
                    sync = False
            # add missing objects
            for name in self._objects.keys():
                if name not in self._collision + self._attached:
                    rospy.logwarn("ObjectManager: %s not added yet", name)
                    self.sendUpdate(self._objects[name], None, False)
                    sync = False
            for name in self._attached_objects.keys():
                if name not in self._attached:
                    rospy.logwarn("ObjectManager: %s not attached yet", name)
                    self.sendUpdate(None, self._attached_objects[name], False)
                    sync = False
            # timeout
            if rospy.Time.now() - t > rospy.Duration(max_time):
                rospy.logerr("ObjectManager: sync timed out.")
                break
            rospy.logdebug("ObjectManager: waiting for sync.")
            rospy.sleep(0.1)