-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse file://
mesh prefix from mesh filepath
#206
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/
)