Пример #1
0
    def on_transfer(self, req):
        old_path = [s for s in req.old_path.split("/") if s]
        new_path = [s for s in req.new_path.split("/") if s]

        success = False
        if req.mode == req.MODE_OBJECT:
            moved_obj = MapManager.remove_object(old_path)
            if moved_obj is not None:
                success = MapManager.add_object(new_path, moved_obj)
            else:
                success = False
        elif req.mode == req.MODE_CONTAINER:
            rospy.logerr("container transfer not implemented")
        elif req.mode == req.MODE_CONTAINER_OBJECTS:
            old_ct = MapManager.get_container(old_path)
            new_ct = MapManager.get_container(new_path)

            if old_ct and new_ct:
                new_ct.Elements += old_ct.Elements
                old_ct.Elements = []
                success = True

        rospy.loginfo(
            "TRANSFER (from={} to={}): {}".format(req.old_path, req.new_path, success)
        )
        return static_map.srv.MapTransferResponse(success)
Пример #2
0
    def on_set(self, req):
        rospy.loginfo("SET:" + str(req.path))
        path = [s for s in req.path.split("/") if s]
        obj = self._object_from_msg(req.object)

        res_obj = None
        success = False
        if req.mode == req.MODE_ADD:
            success = MapManager.add_object(path, obj)
        elif req.mode == req.MODE_REMOVE:
            res_obj = MapManager.remove_object(path)

        if success or res_obj:
            MapManager.Dirty = True
        return static_map.srv.MapSetObjectResponse(
            success, self._create_object_msg(res_obj)
        )