def initialize(self):
        """ Adds a box terrain to the simulation, sets parameters based on the cfg.
        # """
        from isaacgym import terrain_utils

        # texture_files = ['ice_texture.jpg', 'pebble_stone_texture_nature.jpg', 'particle_board_paint_aged.jpg', 'texture_stone_stone_texture_0.jpg', 'texture_wood_brown_1033760.jpg', 'brick_texture.jpg']

        # texture_paths = [
        #     f'{os.path.dirname(os.path.dirname(os.path.realpath(__file__)))}/../../../resources/textures/{texture_file}'
        #     for texture_file in texture_files]
        # textures = [self.env.gym.create_texture_from_file(self.env.sim, texture_path) for texture_path in texture_paths]
        env = self.env.envs[0]

        self.env.terrain_actors = np.full((self.env.cfg.terrain.num_rows, self.env.cfg.terrain.num_cols), None)

        for i in range(self.env.cfg.terrain.num_rows):
            for j in range(self.env.cfg.terrain.num_cols):
                terrain_px = i * self.env.terrain.cfg.env_width + self.env.terrain.cfg.env_width / 2
                terrain_py = j * self.env.terrain.cfg.env_length + self.env.terrain.cfg.env_length / 2

                border_px = int(self.env.cfg.terrain.border_size / self.env.cfg.terrain.horizontal_scale)
                start_px = border_px + i * self.env.terrain.cfg.width_per_env_pixels
                end_px = border_px + (i + 1) * self.env.terrain.cfg.width_per_env_pixels
                start_py = border_px + j * self.env.terrain.cfg.length_per_env_pixels
                end_py = border_px + (j + 1) * self.env.terrain.cfg.length_per_env_pixels
                heightfield_segment_raw = np.array(self.height_samples[start_px:end_px + 1, start_py:end_py + 1].cpu(), dtype=np.float16)
                horizontal_scale = self.env.cfg.terrain.horizontal_scale  # / self.env.cfg.terrain.num_rows
                vertical_scale = self.env.cfg.terrain.vertical_scale  # / self.env.cfg.terrain.num_cols

                # roughness = self.env.terrain_cell_roughnesses[i, j]
                # # heightfield_segment_raw = heightfield_segment_raw + np.random.rand(*heightfield_segment_raw.shape) * float(roughness) * 200
                # lin_x = np.linspace(0, self.env.cfg.terrain.terrain_length * 3, heightfield_segment_raw.shape[1], endpoint=False)
                # lin_y = np.linspace(0, self.env.cfg.terrain.terrain_width * 3, heightfield_segment_raw.shape[0], endpoint=False)
                # x, y = np.meshgrid(lin_x, lin_y)
                # heightfield_segment_raw = heightfield_segment_raw + perlin(x, y, seed=2) * float(roughness) / self.env.cfg.terrain.vertical_scale

                tm_params = gymapi.TriangleMeshParams()
                vertices, triangles = terrain_utils.convert_heightfield_to_trimesh(heightfield_segment_raw,
                                                                                   horizontal_scale,
                                                                                   vertical_scale,
                                                                                   self.env.cfg.terrain.slope_treshold)
                tm_params.nb_vertices = vertices.shape[0]
                tm_params.nb_triangles = triangles.shape[0]

                tm_params.transform.p.x = i * self.env.terrain.cfg.env_width
                tm_params.transform.p.y = j * self.env.terrain.cfg.env_length
                tm_params.transform.p.z = self.terrain_cell_heights[i, j]

                min_friction, max_friction = self.env.cfg.domain_rand.terrain_ground_friction_range
                tm_params.static_friction = self.terrain_cell_frictions[i, j]
                tm_params.dynamic_friction = self.terrain_cell_frictions[i, j]

                tm_params.restitution = self.terrain_cell_restitutions[i, j]
                if min_friction != max_friction:
                    tm_params.segmentation_id = int(
                        (tm_params.static_friction - min_friction) / (max_friction - min_friction) * 255)
                else:
                    tm_params.segmentation_id = 0
                self.env.gym.add_triangle_mesh(self.env.sim, vertices.flatten(order='C'),
                                           triangles.flatten(order='C'), tm_params)
                
        lengthwise_density = int(self.env.cfg.terrain.terrain_length / self.env.cfg.terrain.horizontal_scale)
        widthwise_density = int(self.env.cfg.terrain.terrain_width / self.env.cfg.terrain.horizontal_scale)
        self.friction_samples = torch.tensor(self.terrain_cell_frictions).view(self.env.cfg.terrain.num_rows,
                                                                               self.env.cfg.terrain.num_cols).repeat_interleave(
            lengthwise_density, dim=0).repeat_interleave(widthwise_density, dim=1).to(self.env.device)
        self.roughness_samples = torch.tensor(self.terrain_cell_roughnesses).view(self.env.cfg.terrain.num_rows,
                                                                                  self.env.cfg.terrain.num_cols).repeat_interleave(
            lengthwise_density, dim=0).repeat_interleave(widthwise_density, dim=1).to(self.env.device)
        self.restitution_samples = torch.tensor(self.terrain_cell_restitutions).view(self.env.cfg.terrain.num_rows,
                                                                                     self.env.cfg.terrain.num_cols).repeat_interleave(
            lengthwise_density, dim=0).repeat_interleave(widthwise_density, dim=1).to(self.env.device)
 Adds a box terrain to the simulation, sets parameters based on the cfg.
        # 
globe_walking/go1_gym/terrains/tm_box_terrain.py