def _generate_gel_trimesh()

in tacto/renderer.py [0:0]


    def _generate_gel_trimesh(self):

        # Load config
        g = self.conf.sensor.gel
        origin = g.origin

        X0, Y0, Z0 = origin[0], origin[1], origin[2]
        W, H = g.width, g.height

        if hasattr(g, "mesh") and g.mesh is not None:
            gel_trimesh = trimesh.load(g.mesh)

            # scale up for clearer indentation
            matrix = np.eye(4)
            matrix[[0, 1, 2], [0, 1, 2]] = 1.02
            gel_trimesh = gel_trimesh.apply_transform(matrix)

        elif not g.curvature:
            # Flat gel surface
            gel_trimesh = trimesh.Trimesh(
                vertices=[
                    [X0, Y0 + W / 2, Z0 + H / 2],
                    [X0, Y0 + W / 2, Z0 - H / 2],
                    [X0, Y0 - W / 2, Z0 - H / 2],
                    [X0, Y0 - W / 2, Z0 + H / 2],
                ],
                faces=[[0, 1, 2], [2, 3, 0]],
            )
        else:
            # Curved gel surface
            N = g.countW
            M = int(N * H / W)
            R = g.R
            zrange = g.curvatureMax

            y = np.linspace(Y0 - W / 2, Y0 + W / 2, N)
            z = np.linspace(Z0 - H / 2, Z0 + H / 2, M)
            yy, zz = np.meshgrid(y, z)

            h = R - np.maximum(0, R ** 2 - (yy - Y0) ** 2 - (zz - Z0) ** 2) ** 0.5
            xx = X0 - zrange * h / h.max()

            gel_trimesh = self._generate_trimesh_from_depth(xx)

        return gel_trimesh