Parse file:// mesh prefix from mesh filepath#206
Conversation
|
The file URI scheme doesn't allow for relative paths. See explanations here. Relative paths should be expressed without the |
|
I've encountered this issue when working with an URDF with a workaround for gazebo in ROS 2. Unrelated, but apparently there is an issue when spawning a robot using gazebo_ros in ROS 2, specifically with mesh filenames using the The URDF I mention can be found here |
|
I see, therefore, I believe we should support the |
| if meshfile.count('package'): | ||
| idx0 = meshfile.find('package://') | ||
| meshfile = meshfile[idx0 + len('package://'):] | ||
| elif meshfile.count('file'): | ||
| idx0 = meshfile.find('file://') | ||
| meshfile = meshfile[idx0 + len('file://'):] | ||
| if not os.path.isabs(meshfile): | ||
| # Use the path relative to the output file | ||
| meshfile = os.path.normpath(os.path.relpath(os.path.join(path, meshfile), outputDirectory)) |
There was a problem hiding this comment.
That would seem clearer and cleaner to me:
| if meshfile.count('package'): | |
| idx0 = meshfile.find('package://') | |
| meshfile = meshfile[idx0 + len('package://'):] | |
| elif meshfile.count('file'): | |
| idx0 = meshfile.find('file://') | |
| meshfile = meshfile[idx0 + len('file://'):] | |
| if not os.path.isabs(meshfile): | |
| # Use the path relative to the output file | |
| meshfile = os.path.normpath(os.path.relpath(os.path.join(path, meshfile), outputDirectory)) | |
| if meshfile.startswith('package://'): | |
| idx0 = meshfile.find('package://') | |
| meshfile = meshfile[idx0 + len('package://'):] # package relative path | |
| elif meshfile.startswith('file:///'): | |
| idx0 = meshfile.find('file:///') | |
| meshfile = meshfile[idx0 + len('file://'):] # we keep the last slash for absolute path | |
| elif not os.path.isabs(meshfile): | |
| # Use the path relative to the output file | |
| meshfile = os.path.normpath(os.path.relpath(os.path.join(path, meshfile), outputDirectory)) |
Address changes mentioned in this issue.
file://required by rViz from mesh filepaths/)