def append()

in mujoco_worldgen/objs/obj.py [0:0]


    def append(self, obj, placement_name="top", placement_xy=None):
        '''
        Append an object to our tree.
            placement_name - name of the placement to append to
            placement_xy - ratio position of (x, y), in between 0 and 1
                this allows specification even when sizes may be unknown
                e.g. placement_xy=(0.5, 0.5) puts obj in the center
        If placement_name does not exactly match a placement, we will glob the
            end of its name and pick randomly from matched placement names.
            E.g. "shelf/shelf3" has four interior placements inner_0 to _3,
                appending to "inner" will randomly select one of those.
            Note: selection happens at generation time, so nothing is done
                during the append.
        Note: this does not check that everything fits. During the compile step
            we generate sizes and parameters, and then we can actually verify.
        '''
        assert obj.__class__.__name__ != "Material", "Material should be added with set_material."
        if not self.placeable:
            print("Don't append content to %s. It's not a valid parent." % self.__module__)
            exit(-1)
        if placement_name not in self.children:
            self.children[placement_name] = []
        if placement_xy is not None:
            assert (len(placement_xy) == 2 and
                    1. >= placement_xy[0] >= 0. and
                    1. >= placement_xy[1] >= 0.), \
                "invalid placement_xy: {}".format(placement_xy)
        self.children[placement_name].append((obj, placement_xy))
        return self