Enabling proper URI resolution for World URDF parsing#497
Conversation
There was a problem hiding this comment.
Does it make sense to just delete this dead code and the above comment?
There was a problem hiding this comment.
Yes, I should actually do a second pass through the code and delete a bunch of old things that aren't being used anymore.
|
The relative to absolute resolution looks good to me. There's also a fair amount of code cleanup in here. 👍 |
There was a problem hiding this comment.
It seems it's reversed.
} // namespace urdf_parsing
} // namespace utils
} // namesapce dart|
Could we add a test to show it doesn't work without this fix? |
|
I've added a test which fails prior to the changes of this pull request, and I've removed the code that is no longer being used. |
|
Thanks! Looks good to me. 👍 |
Enabling proper URI resolution for World URDF parsing
|
Thank you Grey! :) |
|
i just pulled down master and i am getting a compilation error : parsePose not found (line 182 urdf_world_parser.cpp). i saw the declaration was deleted as part of the update here - can this reference be deleted as well? |
|
Are the headers for urdf different between Windows and Linux? If you put the declaration back in, does that allow it to work? If so, we may as well just keep the declaration; maybe it was originally there to accommodate Windows. |
|
putting it back in allowed it to compile, but i am now getting an error with the file loading - the "uri.mScheme.get_value_or("file") " check on line 79 of LocalResourceRetriever.cpp is getting back "D" which is causing it to fail to load the file. i noticed that that files and paths are being built in DART with forward slashes - is this new? windows doesn't like those, relic from the DOS days. |
|
should i make this an issue? |
|
If the URI methods aren't working in Windows, then it's definitely worth creating an issue. I was under the impression that Windows accepted forward slashes as equivalent to backslashes, but perhaps that's not the case. One possible solution might be to use preprocessor directives in the |
|
Windows does support both types of slashes, with one obscure exception:
I suspect that the problem is related to the drive letter, not the forward slashes. For example, the windows path My preference would be to require the |
|
This definitely seems like a tricky situation. For the sake of URI correctness, I would be more inclined to require having One option might be to have a function like which would check for a I think this would give us a way to avoid manually prepending |
|
Quick question: This only affects absolute paths on windows, right? How many of these are there in the codebase vs. relative paths? Could we just change them to resolve? Really, I think that requiring URI strings for resources (absolute or relative) is a very good candidate for a breaking API change on the next major rev due to the vastly improved versatility and standardization of URI formatting. I would recommend making the minimal change necessary here to deal with non-URI paths with the intent to deprecate it all later. I might even go so far as to add a printed warning to the workaround, alerting users that that the path should be changed to a file URI. |
|
A possible solution could be to modify whatever is generating the macro DART_DATA_PATH and possibly DART_ROOT_PATH in config.h (the cmake generated file) to hold the appropriate configuration (adding the " file://" to the macro def for windows builds). this is the only place these absolute paths are referenced, as far as i know (can't find any other - everything else uses these macros). so if, as i understand it (please correct me if i am wrong), we need to change the format of the absolute paths for windows, maybe we can at least do so here. to be honest, i'd prefer some kind of function that returned a string of the path prefixes (build and data)that could at the very least then be overridden if necessary, to a macro. i never really liked the idea of putting a path prefix in a macro - it seems too heavy handed for something like this. would this be possible (i.e. building a function in config.h that would return the data or build path as strings instead of having the macros)? |
I do feel that macros tend to be rather gross, but they do have some value to offer, for lack of a better macro system in C++. I think in the particular case of the
I definitely agree that this should be done 👍 . But I don't think it solves the larger problem of having users who might want to specify an absolute path on Windows using strings. I don't want casual users to have to understand the nuances of URIs in order to use files in DART. For that matter, I myself don't want to have to think about the nuances of URIs when dealing with files in DART. My proposal would be:
So this way, the user does not need to worry about the details of a Uri and does not need to check whether a string for a filename is correctly using the |
|
This links up with the issue that JS reported earlier in #488. |
|
@mxgrey: I think that's a pretty reasonable way to go about it. As someone who is often transparently switching to over-the-network and in-memory stream resources and moving between OSes, I'm exactly on the other side of the fence where I really don't want to have to see/touch raw file paths in my code. Static converter functions to a clear URI type seem like a safe way to encapsulate both of these use cases. |
I realized that the urdf package in the DART prerequisite installer was old one, which has missing |
|
@jslee02 the urdf issue is addressed with this change. Thanks! On the issue of paths, and as an extension of @mxgrey 's great ideas, could a system be implemented that had dart look at a single location for an xml file that would hold uri strings keyed by namespace/project/resource name/whatever? so instead of passing around filenames or uri's, we'd pass around default or user-defined string constants like "skelFile" in the code, which would then be used, along with whatever qualifiers were deemed necessary, as a key to look up the uri in the xml file. i think this would be a better method of accessing files/resources than hardcoding paths/uri's - only 1 uri would ever be coded into dart, and in the xml tied to that uri all other resource locations could be specified by the user. changes could be made without recompilation, and platform specific configurations could be specified easily. |
|
We could introduce a custom URI schema for built in models. For example, dart://cube.skel could refer to cube.skel in the appropriate directory. Thoughts? On Fri, Oct 2, 2015 at 2:49 PM John Turner notifications@github.com wrote:
|
|
I think the idea of a I think this would also address @jturner65 's complaints about our use of macros for locating files that get shipped with DART. This raises two big questions in my mind:
One idea that comes to mind for (2) is we could have an |
|
The versioning system you described sounds very similar to the `model://`
URI and manifest file system used by Gazebo. It might be worth looking at
their documentation/implementation for inspiration.
|
I'm currently working on revising |
|
|
Here are four examples: (1), (2) are clear. So if we prepend |
|
Right, we definitely want (3) and not (4). The original motivation for this was to robustly handle the way Windows paths begin with |
|
OK, now I get the idea of I revised
So I wonder we still need |
|
I'm a bit concerned about the changes you're proposing to Moreover, as you said before, colons are allowed to be in path names, but what you've proposed will only catch the particular way that Windows uses colons to specify drives. |
I basically agree with that. But then how
With the absolute path restriction, it can be easily handled by regarding all the strings after |
|
I think I would prefer having Does anyone have a strong reason for wanting to keep |
|
We should definitely have separate However, this may not actually be necessary. These paths are resolved relative to the URI of the source file, so the schema should be inherited accordingly. |
|
Strong agreement w/ @mkoval here, |
|
If we separate them out into two functions, I think |
|
I'm about to implement bool Uri::fromPath(const std::string& _path)
{
// TODO(JS): We might want to check validity of _path.
static const std::string fileScheme("file://");
if (_path.compare(0, fileScheme.length(), fileScheme) != 0)
{
#ifdef _WIN32
return fromString(fileScheme + "/" + _path);
#else
return fromString(fileScheme + _path);
#endif
}
return fromString(_path);
}Here we assume that |
|
PR #517 (for DART 5.1) is created that resolves issues of file URI.
|
|
this looks great! |
The changes that were made to allow for correct URI resolution had an unintended side effect of breaking the relative path resolution for URDF files that represent an entire World (as opposed to the standard use of a URDF file, which is to represent an individual robot).
This pull request fixes this issue and allows World URDF files to correctly resolve relative paths.