Skip to content

Question about re-implement the example #5

@Alan-Heoooh

Description

@Alan-Heoooh

Hi, thanks for your nice work! It occurs when I try to convert robot urdf to primitive shapes.

However, I encountered some error when trying to convert assets/franka/fp3_franka_hand.urdf in to primitive shapes while there is no issue when converting assets/panda/panda.urdf.

The total logs are:

root@564c859c416d:/foam# python3 scripts/generate_sphere_urdf.py assets/franka/fp3_franka_hand.urdf
Link::Mesh: fp3_link0::meshes/robot_arms/fp3/collision/link0.stl
  Target Spheres: 2
Link::Mesh: fp3_link1::meshes/robot_arms/fp3/collision/link1.stl
  Target Spheres: 2
Link::Mesh: fp3_link2::meshes/robot_arms/fp3/collision/link2.stl
  Target Spheres: 3
Link::Mesh: fp3_link3::meshes/robot_arms/fp3/collision/link3.stl
  Target Spheres: 2
Link::Mesh: fp3_link4::meshes/robot_arms/fp3/collision/link4.stl
  Target Spheres: 2
Link::Mesh: fp3_link5::meshes/robot_arms/fp3/collision/link5.stl
  Target Spheres: 4
Link::Mesh: fp3_link6::meshes/robot_arms/fp3/collision/link6.stl
  Target Spheres: 1
Link::Mesh: fp3_link7::meshes/robot_arms/fp3/collision/link7.stl
  Target Spheres: 2
Link::Mesh: fp3_hand::meshes/robot_ee/franka_hand_black/collision/hand.stl
  Target Spheres: 5
fp3_leftfinger::primitive0 2.9298946584416763 2
fp3_leftfinger::primitive1 9.835754193364114 6
fp3_leftfinger::primitive2 4.972383560077092 3
fp3_leftfinger::primitive3 2.7754195946584588 1
fp3_rightfinger::primitive0 2.9298946584416763 2
fp3_rightfinger::primitive1 9.835754193364114 6
fp3_rightfinger::primitive2 4.972383560077092 3
fp3_rightfinger::primitive3 2.7754195946584588 1
Traceback (most recent call last):
  File "/foam/foam/__init__.py", line 58, in spherize_mesh
    spheres = compute_spheres(loaded_mesh, **spherization_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/external/__init__.py", line 225, in compute_spheres
    return compute_spheres_helper(mesh, command, method)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/external/__init__.py", line 63, in compute_spheres_helper
    raise RuntimeError("Failed to create spheres for mesh. Mesh is probably invalid.")
RuntimeError: Failed to create spheres for mesh. Mesh is probably invalid.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/foam/foam/__init__.py", line 63, in spherize_mesh
    spheres = compute_spheres(loaded_mesh, **spherization_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/external/__init__.py", line 225, in compute_spheres
    return compute_spheres_helper(mesh, command, method)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/external/__init__.py", line 63, in compute_spheres_helper
    raise RuntimeError("Failed to create spheres for mesh. Mesh is probably invalid.")
RuntimeError: Failed to create spheres for mesh. Mesh is probably invalid.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/foam/scripts/generate_sphere_urdf.py", line 143, in <module>
    Fire(main)
  File "/usr/local/lib/python3.12/dist-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/scripts/generate_sphere_urdf.py", line 134, in main
    primitive.name: sh.get_spherization(primitive.name, depth, branch, cache = False)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/__init__.py", line 227, in get_spherization
    spherization = self.ps.get(name)
                   ^^^^^^^^^^^^^^^^^
  File "/foam/foam/__init__.py", line 101, in get
    return self.waiting[name].result()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/__init__.py", line 66, in spherize_mesh
    raise RuntimeError("Failed to process loaded_mesh.")
RuntimeError: Failed to process loaded_mesh.
Exception ignored in: <function SpherizationDatabase.__del__ at 0x774f0fe73560>
Traceback (most recent call last):
  File "/foam/foam/__init__.py", line 127, in __del__
NameError: name 'open' is not defined

Also for assets/stretch/stretch.urdf, it seems there are some missing mesh files. Log:

root@564c859c416d:/foam# python3 scripts/generate_sphere_urdf.py assets/stretch/stretch.urdf   
Traceback (most recent call last):
  File "/foam/scripts/generate_sphere_urdf.py", line 143, in <module>
    Fire(main)
  File "/usr/local/lib/python3.12/dist-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/scripts/generate_sphere_urdf.py", line 44, in main
    meshes = get_urdf_meshes(urdf, shrinkage)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/utility/__init__.py", line 178, in get_urdf_meshes
    meshes.append(URDFMesh(f"{name}::{filename}", load_mesh_file(urdf_dir / filename), xyz, rpy, scale))
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foam/foam/utility/__init__.py", line 64, in load_mesh_file
    raise e
  File "/foam/foam/utility/__init__.py", line 57, in load_mesh_file
    mesh = as_mesh(load_mesh(mesh_filepath, process = False)) # type: ignore
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/trimesh/exchange/load.py", line 195, in load_mesh
    ) = _parse_file_args(file_obj=file_obj, file_type=file_type, resolver=resolver)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/trimesh/exchange/load.py", line 612, in _parse_file_args
    raise ValueError(f"string is not a file: {file_obj}")
ValueError: string is not a file: /foam/assets/stretch/meshes/link_gripper.STL

Do you have any ideas how I can fix these issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions