Unity-Technologies / URDF-Importer

URDF importer
Apache License 2.0
212 stars 70 forks source link

Unable to import URDF files with OBJ meshes at runtime. #140

Open 707346129 opened 2 years ago

707346129 commented 2 years ago

I can import URDF files with OBJ meshes through Unity GUI, but when I tried to import them at runtime with the UrdfRobotExtensions.CreateRuntime() method, I would meet errors like "Unable to create mesh collider for the mesh: package://textured_objs/original-7.obj". I checked the code at URDF-Importer-0.5.0/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs:93 and find that it probably only supports STL meshes. Is it possible to import URDF files with OBJ meshes at runtime?

hyounesy commented 2 years ago

[Internal Ticket#: AIRO-1212]

peifeng-unity commented 2 years ago

Hi @707346129, thanks for letting us know. Just wish to double-check whether you are trying to import URDF files in Unity Editor play mode or in a standalone executable? If it is in Unity Editor play mode, you could use the UrdfRobotExtensions.Create() method to import, which supports OBJ meshes. For the standalone executable, currently, it doesn't support importing OBJ meshes, but we could add this feature. Please let us know.

CXY-Likescoding commented 2 years ago

I can import URDF files with OBJ meshes through Unity GUI, but when I tried to import them at runtime with the UrdfRobotExtensions.CreateRuntime() method, I would meet errors like "Unable to create mesh collider for the mesh: package://textured_objs/original-7.obj". I checked the code at URDF-Importer-0.5.0/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs:93 and find that it probably only supports STL meshes. Is it possible to import URDF files with OBJ meshes at runtime?

I've solved this problem by modifying the "URDF-Importer-0.5.0/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs". You can replace the line "Debug.LogError("Unable to create mesh collider for the mesh: " + mesh.filename);" with "meshObject = MeshImporter.Load(meshFilePath);" and add a line "using UnityMeshImporter;" on the top of this script. Then your code will run correctly. By the way, "MeshImporter.Load(meshFilePath);" is a function to load mesh files defined in "URDF-Importer-0.5.0/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/MeshImporter.cs". Hope this can help you~

github-actions[bot] commented 2 years ago

This issue has been marked stale because it has been open for 14 days with no activity. Please remove the stale label or comment on this issue, or the issue will be automatically closed in the next 14 days.

github-actions[bot] commented 2 years ago

This issue has been marked stale for 14 days and will now be closed. If this issue is still valid, please ping a maintainer.