Skip to content
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

Add resolve_filepath for url scheme such that package://, model:// #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iory
Copy link

@iory iory commented Mar 5, 2019

This PR supports URL scheme such that package://, model://.
With this PR, we can load urdf contains following XML tag.

<mesh filename="package://fetch_description/meshes/base_link_collision.STL" />

@mmatl
Copy link
Owner

mmatl commented Apr 5, 2019

So sorry for the delayed reply, just saw this! Nice PR, I'll test it and merge it soon.

Best,
Matt

@sthoduka
Copy link

btw, I've tested this (at least for package:// URLs) and it works fine. Thanks @iory!

@mcevoyandy
Copy link

mcevoyandy commented Oct 29, 2020

Hi @mmatl I also wanted this functionality so was looking into why this was failing... there's a few issues I found, but it seems the tests won't pass even on master? the _to_xml function in urdf.py ends up looking for the meshes in the wrong place?

Copy link

@mcevoyandy mcevoyandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iory nice addition! It works well for viewing a normal URDF, but breaks the relative structure... with the two changes I suggested I can view both, but the tests still fail because of bad dae files. I'm not sure if @mmatl can address that or not. I definitely will keep using this repo and this PR so it would be good to see it merged!

@@ -199,6 +218,7 @@ def get_filename(base_path, file_path, makedirs=False):
The resolved filepath -- just the normal ``file_path`` if it was an
absolute path, otherwise that path joined to ``base_path``.
"""
file_path = resolve_filepath(base_path, file_path)
fn = file_path
if not os.path.isabs(file_path):
fn = os.path.join(base_path, file_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when given a relative path, this gives the wrong path. resolve_filepath returns base_path + file_path, then this if makes fn = base_path + base_path + file_path. Should this be os.path.join(os.getcwd(), file_path) instead?

if os.path.exists(resolved_filepath):
return resolved_filepath
dirname = os.path.dirname(dirname)
return False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the tests, this will return false, then in get_filename, os.path.isabs fails because it's trying to evaluate False

@@ -199,6 +218,7 @@ def get_filename(base_path, file_path, makedirs=False):
The resolved filepath -- just the normal ``file_path`` if it was an
absolute path, otherwise that path joined to ``base_path``.
"""
file_path = resolve_filepath(base_path, file_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with comment above, I think you need a check to see if resolve_filepath returns False

@@ -199,6 +218,7 @@ def get_filename(base_path, file_path, makedirs=False):
The resolved filepath -- just the normal ``file_path`` if it was an
absolute path, otherwise that path joined to ``base_path``.
"""
file_path = resolve_filepath(base_path, file_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
file_path = resolve_filepath(base_path, file_path)
resolved_file_path = resolve_filepath(base_path, file_path)
if resolved_file_path != False:
file_path = resolved_file_path

@@ -199,6 +218,7 @@ def get_filename(base_path, file_path, makedirs=False):
The resolved filepath -- just the normal ``file_path`` if it was an
absolute path, otherwise that path joined to ``base_path``.
"""
file_path = resolve_filepath(base_path, file_path)
fn = file_path
if not os.path.isabs(file_path):
fn = os.path.join(base_path, file_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn = os.path.join(base_path, file_path)
fn = os.path.join(os.getcwd(), file_path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants