-
-
Notifications
You must be signed in to change notification settings - Fork 104
Allow specifying package locations manually #356
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
base: ros2
Are you sure you want to change the base?
Conversation
|
A possible alternative would be permit users to specify somehow a function that resolves package references in place of the default implementation, in this way one could either provide an hardcoded mapping (as in this PR) or use some logic to find package paths based on environment variables (as done for example in https://github.com/ami-iit/resolve-robotics-uri-py . |
|
I went with this solution as it is the most simple, and when using xacro from python a more complex resolution logic can always be implemented when forming the mapping dict. But yes, also a function could be passed in place of the dict. |
|
Just a note that with the bazel implementation, I added a The way that this works for bazel is that the buildsystem copies (or symlinks) all of the dependencies of the build to a common temp directory, and then sets the That was a quick way to get a similar behavior without getting the bazel semantics tied up in the xacro implementation. Could something similar be done here? |
|
I believe this here is a bit different, and more flexible. In my case the goal was to be able to use xacro models contained in pure python packages (which were created bit repackaging ROS1 packages). With this I am able to install these packages from pip, find their location with importlib and inform xacro on where to find each package's root folder. Having all of this I can simply xacro-compile models installed from pip without having to rearrange my workspace. |
|
Sorry for not responding yet. I agree to @traversaro that defining a resolver function is the most elegant way to handle |
|
Hello, so you mean it could be done passing an argument to process_doc like in this PR, but passing a resolver function instead of a dict? Do you think it should completely override the current resolve behavior or use the current behavior as a fallback? Because I could just change slightly this PR, replacing the dict with a callable and falling back to the normal behavior if the resolver functions returns None (equivalent to the case of the dict not having the a key for package). |
|
Instead of explicitly passing a function, one should just overwrite a default resolve function. |
Following the work on using xacro without ROS I implemented a little change to allow using the find directive without ROS dependencies.
This allows to call xacro.process_doc() with a dict that associates package names to package paths. This is then used by the $(find ...) directive. If this argument is not specified all remains as before.
I find this to be quite useful when using multi-file xacro definitions when not using ROS.
I feel it would be a nice addition.