示例#1
0
    def load_model(self, xdraw_function=None):
        """Load the geometry (meshes) of the robot.

        Args:
            xdraw_function (function, ): The function to draw the
                meshes in the respective CAD environment. Defaults to None.
        """
        path = self.get_model_path()

        # the links loaded as meshes
        m0 = Mesh.from_obj(os.path.join(path, 'base_and_shoulder.obj'))
        m1 = Mesh.from_obj(os.path.join(path, 'upperarm.obj'))
        m2 = Mesh.from_obj(os.path.join(path, 'forearm.obj'))
        m3 = Mesh.from_obj(os.path.join(path, 'wrist1.obj'))
        m4 = Mesh.from_obj(os.path.join(path, 'wrist2.obj'))
        m5 = Mesh.from_obj(os.path.join(path, 'wrist3.obj'))

        # draw the geometry in the respective CAD environment
        if xdraw_function:
            m0 = xdraw_function(m0)
            m1 = xdraw_function(m1)
            m2 = xdraw_function(m2)
            m3 = xdraw_function(m3)
            m4 = xdraw_function(m4)
            m5 = xdraw_function(m5)

        self.model = [m0, m1, m2, m3, m4, m5]
示例#2
0
 def load_model(self):
     """Load the geometry (meshes) of the robot.
     """
     path = self.get_model_path()
     # the joints loaded as meshes
     self.m0 = Mesh.from_obj(os.path.join(path, 'base_and_shoulder.obj'))
     self.m1 = Mesh.from_obj(os.path.join(path, 'upperarm.obj'))
     self.m2 = Mesh.from_obj(os.path.join(path, 'forearm.obj'))
     self.m3 = Mesh.from_obj(os.path.join(path, 'wrist1.obj'))
     self.m4 = Mesh.from_obj(os.path.join(path, 'wrist2.obj'))
     self.m5 = Mesh.from_obj(os.path.join(path, 'wrist3.obj'))
     
     # have a copy of the mesh vertices for later transformation
     self.m0_xyz = self.m0.xyz
     self.m1_xyz = self.m1.xyz
     self.m2_xyz = self.m2.xyz
     self.m3_xyz = self.m3.xyz
     self.m4_xyz = self.m4.xyz
     self.m5_xyz = self.m5.xyz
示例#3
0
# Debugging
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.datastructures.mesh import Mesh

    from compas.visualization.viewers.viewer import Viewer

    from compas.visualization.viewers.core.drawing import draw_points
    from compas.visualization.viewers.core.drawing import draw_lines
    from compas.visualization.viewers.core.drawing import draw_circle

    mesh = Mesh.from_obj(compas.get_data('hypar.obj'))

    for key, attr in mesh.vertices(True):
        attr['is_fixed'] = mesh.vertex_degree(key) == 2

    planarize_mesh_shapeop(mesh,
                           fixed=mesh.vertices_where({'is_fixed': True}),
                           kmax=100)

    # deviations = []

    # for fkey, attr in mesh.faces(True):
    #     points = mesh.face_coordinates(fkey)
    #     base, normal = bestfit_plane_from_points(points)

    #     angles = []
示例#4
0
        A mesh object.

    Notes
    -----
    This function does not care about the directions being unified or not. It
    just reverses whatever direction it finds.

    """
    mesh.halfedge = {key: {} for key in mesh.vertices()}
    for fkey in mesh.faces():
        mesh.face[fkey][:] = mesh.face[fkey][::-1]
        for u, v in mesh.face_halfedges(fkey):
            mesh.halfedge[u][v] = fkey
            if u not in mesh.halfedge[v]:
                mesh.halfedge[v][u] = None


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.datastructures.mesh import Mesh

    mesh = Mesh.from_obj(compas.get_data('faces_big.obj'))

    mesh_unify_cycles(mesh)
示例#5
0
        return [
            vkey for vkey in self.vertices_on_boundary()
            if self.is_boundary_vertex_kink(vkey, threshold_angle)
        ]

    def vertex_centroid(self):
        """Calculate the centroid of the mesh vertices.

		Parameters
		----------

		Returns
		-------
		list
			The coordinates of the centroid of the mesh vertices.
		"""

        return centroid_points(
            [self.vertex_coordinates(vkey) for vkey in self.vertices()])


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    import compas

    mesh = Mesh.from_obj(compas.get('faces.obj'))
示例#6
0
 def load_model(self):
     self.model_loaded = True
     datapath = get_data("robots/ur/tools/measurement_tool.obj")
     self.model = Mesh.from_obj(datapath)
     self.model_xyz = self.model.xyz