MPlib icon indicating copy to clipboard operation
MPlib copied to clipboard

ValueError: Could not load resource ……/link0.obj.convex.stl

Open LittlePotatoChip opened this issue 11 months ago • 5 comments

I tried to make a demo using my own codes,following the documetiation:

from mplib import Planner …… planner = Planner( urdf="/home/potato/workplace/IsaacGym_Preview_4_Package/isaacgym/assets/urdf/franka_description/robots/franka_panda.urdf", move_group="panda_hand", # srdf=None, # new_package_keyword="", use_convex=False, link_names=["panda_link0", "panda_link1", "panda_link2", "panda_link3", "panda_link4", "panda_link5", "panda_link6", "panda_link7", "panda_link8","panda_hand"], joint_names=["panda_joint1", "panda_joint2", "panda_joint3", "panda_joint4", "panda_joint5", "panda_joint6", "panda_joint7"], joint_vel_limits=None, joint_acc_limits=None, objects=[], verbose=False, ) …… status, q_goals = planner.IK( …… ) ‘ it printed errors: Traceback (most recent call last): File "/home/potato/workplace/test_sapien/get start/xbox_demo.py", line 171, in planner = Planner( ^^^^^^^^ File "/home/potato/miniforge3/envs/maniskill/lib/python3.11/site-packages/mplib/planner.py", line 65, in init self.robot = ArticulatedModel( ^^^^^^^^^^^^^^^^^ ValueError: Could not load resource /home/potato/workplace/IsaacGym_Preview_4_Package/isaacgym/assets/urdf/franka_description/robots/franka_description/meshes/collision/link0.obj.convex.stl Unable to open file "/home/potato/workplace/IsaacGym_Preview_4_Package/isaacgym/assets/urdf/franka_description/robots/franka_description/meshes/collision/link0.obj.convex.stl". Hint: the mesh directory may be wrong. ` I don't have "link0.obj.convex.stl",but I have link0.obj and link0.stl.And there is no things like "link0.obj.convex.stl" in the franka_panda.urdf(urdf file is from isaac gym)

LittlePotatoChip avatar Jan 05 '25 02:01 LittlePotatoChip

@LittlePotatoChip Same problem here. Have you solved it?

luccachiang avatar Jan 24 '25 03:01 luccachiang

@LittlePotatoChip Same problem here. Have you solved it?

no, I have switched to other tools,I find it's not necessary for my work

LittlePotatoChip avatar Jan 24 '25 10:01 LittlePotatoChip

What version are you guys using? There might have been a convex bug before iirc. Can you please try the nightly wheels here?

Lexseal avatar Jan 24 '25 15:01 Lexseal

@Lexseal Thanks for your prompt response. I'm using the 0.1.1 version since Maniskill only supports this version at the moment. I managed to use the following code to generate a convex.stl file from a stl file. Is it correct? Also, since I did not find the document for version 0.1.1, why must a convex hull be used? Could you please explain or refer me to some explanation links?

import numpy as np
import scipy.spatial
from stl import mesh

def generate_convex_stl(input_stl_path, output_stl_path):
    original_mesh = mesh.Mesh.from_file(input_stl_path)
    
    vertices = np.unique(original_mesh.vectors.reshape(-1, 3), axis=0)
    
    hull = scipy.spatial.ConvexHull(vertices)
    
    convex_vertices = vertices[hull.vertices]
    convex_triangles = hull.simplices
    convex_mesh = mesh.Mesh(np.zeros(len(convex_triangles), dtype=mesh.Mesh.dtype))
    for i, simplex in enumerate(convex_triangles):
        convex_mesh.vectors[i] = convex_vertices[simplex]
    
    convex_mesh.save(output_stl_path)
    print(f"Convex hull saved to {output_stl_path}")

def batch_convex_hull_generation(input_directory, output_directory):

    import os
    
    os.makedirs(output_directory, exist_ok=True)
    
    for filename in os.listdir(input_directory):
        if filename.lower().endswith('.stl'):
            input_path = os.path.join(input_directory, filename)
            output_path = os.path.join(output_directory, f'{filename}.convex.stl')
            generate_convex_stl(input_path, output_path)

luccachiang avatar Jan 24 '25 22:01 luccachiang

convex hull should work if your geometry is more or less convex to begin with. at worst your collision detection will be a little preemptive

Lexseal avatar Jan 25 '25 02:01 Lexseal