resolve-robotics-uri-py 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ name: CI Workflow
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ schedule:
7
+ # * is a special character in YAML so you have to quote this string
8
+ # Execute a "nightly" build at 2 AM UTC
9
+ - cron: '0 2 * * *'
10
+
11
+ jobs:
12
+ build-with-conda-dependencies:
13
+ name: '[conda:${{ matrix.os }}]'
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ build_type: [Release]
19
+ os: [ubuntu-22.04, macos-latest, windows-2019]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+
24
+ - name: Print used environment (no conda) [Conda]
25
+ shell: bash
26
+ run: |
27
+ env
28
+
29
+ - uses: mamba-org/setup-micromamba@v1
30
+ with:
31
+ environment-file: ci_env.yml
32
+
33
+ - name: Install the package
34
+ shell: bash -l {0}
35
+ run: python -m pip install --no-deps .
36
+
37
+ - name: Import the package
38
+ shell: bash -l {0}
39
+ run: python -c "import resolve_robotics_uri_py"
40
+
41
+ - name: Run the Python tests
42
+ shell: bash -l {0}
43
+ run: pytest
44
+
45
+ # This test requires the conda-forge::icub-models,
46
+ # robotology::ergocub-software and
47
+ # robostack-staging::ros-humble-moveit-resources-panda-description
48
+ # conda packages, that are installed in ci_env.yml environment
49
+ - name: Check command line helper
50
+ shell: bash -l {0}
51
+ run: |
52
+ resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf
53
+ resolve-robotics-uri-py package://ergoCub/robots/ergoCubSN000/model.urdf
54
+ resolve-robotics-uri-py package://moveit_resources_panda_description/urdf/panda.urdf
55
+ ! resolve-robotics-uri-py package://this/file/does/not/exist
@@ -0,0 +1,36 @@
1
+ name: Publish Python package to PyPI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build-n-publish:
7
+ name: Build and publish Python package to PyPI
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - name: Set up Python
13
+ uses: actions/setup-python@v4
14
+ with:
15
+ python-version: "3.x"
16
+
17
+ - name: Install pypa/build
18
+ run: >-
19
+ python -m
20
+ pip install
21
+ build
22
+ --user
23
+ - name: Build a binary wheel and a source tarball
24
+ run: >-
25
+ python -m
26
+ build
27
+ --sdist
28
+ --wheel
29
+ --outdir dist/
30
+ .
31
+
32
+ - name: Publish distribution 📦 to PyPI
33
+ if: startsWith(github.ref, 'refs/tags')
34
+ uses: pypa/gh-action-pypi-publish@release/v1
35
+ with:
36
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,160 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Silvio Traversaro
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: resolve-robotics-uri-py
3
+ Version: 0.1.0
4
+ Summary: Pure python package to solve ROS-style package:// and Gazebo-style model:// URIs in absolute paths.
5
+ Home-page: https://github.com/ami-iit/resolve-robotics-uri-py
6
+ Author: Silvio Traversaro
7
+ Author-email: silvio.traversaro@iit.it
8
+ License: BSD
9
+ Project-URL: Changelog, https://github.com/ami-iit/resolve-robotics-uri-py/releases
10
+ Project-URL: Source, https://github.com/ami-iit/resolve-robotics-uri-py
11
+ Project-URL: Tracker, https://github.com/ami-iit/resolve-robotics-uri-py/issues
12
+ Platform: any
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: BSD License
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Topic :: Software Development
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ Provides-Extra: style
29
+ Provides-Extra: testing
30
+ Provides-Extra: all
31
+ License-File: LICENSE
32
+
33
+ # resolve-robotics-uri-py
34
+
35
+ Pure Python package (that only depends on Python stdlib) to resolve a package:// (ROS-style) or model:// (Gazebo-style) URI to an absolute filename.
36
+
37
+ ## Installation
38
+
39
+ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install resolve-robotics-uri-py.
40
+
41
+ ```bash
42
+ python -m pip install resolve-robotics-uri-py
43
+ ```
44
+
45
+ ## Usage in Python
46
+
47
+ Add `import resolve_robotics_uri_py` to your Python file, then take inspiration from the following examples.
48
+
49
+ If you want to get the location of the `iCubGazeboV2_7` iCub model installed from [`icub-models`](https://github.com/robotology/icub-models):
50
+
51
+ ~~~python
52
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://iCub/robots/iCubGazeboV2_7/model.urdf")
53
+ ~~~
54
+
55
+ If you want to get the location of the `ergoCubSN00` model installed from [`ergocub-software`](https://github.com/icub-tech-iit/ergocub-software):
56
+
57
+ ~~~python
58
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://ergoCub/robots/ergoCubSN000/model.urdf")
59
+ ~~~
60
+
61
+ If you want to get the location of the `panda` model installed by [`moveit_resources_panda_description`](https://index.ros.org/p/moveit_resources_panda_description/):
62
+
63
+ ~~~python
64
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://moveit_resources_panda_description/urdf/panda.urdf")
65
+ ~~~
66
+
67
+
68
+ ## Command Line usage
69
+
70
+ `resolve_robotics_uri_py` also install a command line tool called `resolve-robotics-uri-py` for use in scripts, that can be used as:
71
+
72
+ ~~~
73
+ resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf
74
+ ~~~
75
+
76
+ For example, on bash this can be used to easily convert the a urdf specified via `package://` to an sdf (assuming you have Gazebo installed), using the [backtick operator](https://www.redhat.com/sysadmin/backtick-operator-vs-parens):
77
+ ~~~
78
+ gz sdf -p `resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf`
79
+ ~~~
80
+
81
+ ## Contributing
82
+
83
+ Pull requests are welcome. For major changes, please open an issue first
84
+ to discuss what you would like to change.
85
+
86
+ Please make sure to update tests as appropriate.
87
+
88
+ ## License
89
+
90
+ [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html)
@@ -0,0 +1,58 @@
1
+ # resolve-robotics-uri-py
2
+
3
+ Pure Python package (that only depends on Python stdlib) to resolve a package:// (ROS-style) or model:// (Gazebo-style) URI to an absolute filename.
4
+
5
+ ## Installation
6
+
7
+ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install resolve-robotics-uri-py.
8
+
9
+ ```bash
10
+ python -m pip install resolve-robotics-uri-py
11
+ ```
12
+
13
+ ## Usage in Python
14
+
15
+ Add `import resolve_robotics_uri_py` to your Python file, then take inspiration from the following examples.
16
+
17
+ If you want to get the location of the `iCubGazeboV2_7` iCub model installed from [`icub-models`](https://github.com/robotology/icub-models):
18
+
19
+ ~~~python
20
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://iCub/robots/iCubGazeboV2_7/model.urdf")
21
+ ~~~
22
+
23
+ If you want to get the location of the `ergoCubSN00` model installed from [`ergocub-software`](https://github.com/icub-tech-iit/ergocub-software):
24
+
25
+ ~~~python
26
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://ergoCub/robots/ergoCubSN000/model.urdf")
27
+ ~~~
28
+
29
+ If you want to get the location of the `panda` model installed by [`moveit_resources_panda_description`](https://index.ros.org/p/moveit_resources_panda_description/):
30
+
31
+ ~~~python
32
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://moveit_resources_panda_description/urdf/panda.urdf")
33
+ ~~~
34
+
35
+
36
+ ## Command Line usage
37
+
38
+ `resolve_robotics_uri_py` also install a command line tool called `resolve-robotics-uri-py` for use in scripts, that can be used as:
39
+
40
+ ~~~
41
+ resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf
42
+ ~~~
43
+
44
+ For example, on bash this can be used to easily convert the a urdf specified via `package://` to an sdf (assuming you have Gazebo installed), using the [backtick operator](https://www.redhat.com/sysadmin/backtick-operator-vs-parens):
45
+ ~~~
46
+ gz sdf -p `resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf`
47
+ ~~~
48
+
49
+ ## Contributing
50
+
51
+ Pull requests are welcome. For major changes, please open an issue first
52
+ to discuss what you would like to change.
53
+
54
+ Please make sure to update tests as appropriate.
55
+
56
+ ## License
57
+
58
+ [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html)
@@ -0,0 +1,13 @@
1
+ name: testenv
2
+ channels:
3
+ - conda-forge
4
+ - robotology
5
+ - robostack-staging
6
+ dependencies:
7
+ - python
8
+ - pip
9
+ - pytest
10
+ # packages that ship URDFs used to test
11
+ - icub-models
12
+ - ergocub-software
13
+ - ros-humble-moveit-resources-panda-description
@@ -0,0 +1,17 @@
1
+ [build-system]
2
+ build-backend = "setuptools.build_meta"
3
+ requires = [
4
+ "wheel",
5
+ "setuptools>=45",
6
+ "setuptools_scm[toml]>=6.2",
7
+ ]
8
+
9
+ [tool.setuptools_scm]
10
+ local_scheme = "dirty-tag"
11
+
12
+ [tool.black]
13
+ line-length = 88
14
+
15
+ [tool.isort]
16
+ profile = "black"
17
+ multi_line_output = 3
@@ -0,0 +1,63 @@
1
+ [metadata]
2
+ name = resolve-robotics-uri-py
3
+ description = Pure python package to solve ROS-style package:// and Gazebo-style model:// URIs in absolute paths.
4
+ long_description = file: README.md
5
+ long_description_content_type = text/markdown
6
+ author = Silvio Traversaro
7
+ author_email = silvio.traversaro@iit.it
8
+ license = BSD
9
+ license_files = LICENSE
10
+ platforms = any
11
+ url = https://github.com/ami-iit/resolve-robotics-uri-py
12
+ project_urls =
13
+ Changelog = https://github.com/ami-iit/resolve-robotics-uri-py/releases
14
+ Source = https://github.com/ami-iit/resolve-robotics-uri-py
15
+ Tracker = https://github.com/ami-iit/resolve-robotics-uri-py/issues
16
+ keywords =
17
+ classifiers =
18
+ Development Status :: 4 - Beta
19
+ Intended Audience :: Developers
20
+ License :: OSI Approved :: BSD License
21
+ Operating System :: POSIX :: Linux
22
+ Operating System :: MacOS
23
+ Operating System :: Microsoft
24
+ Programming Language :: Python :: 3.8
25
+ Programming Language :: Python :: 3.9
26
+ Programming Language :: Python :: 3.10
27
+ Programming Language :: Python :: 3.11
28
+ Programming Language :: Python :: 3 :: Only
29
+ Programming Language :: Python :: Implementation :: CPython
30
+ Topic :: Software Development
31
+
32
+ [options]
33
+ zip_safe = False
34
+ packages = find:
35
+ package_dir =
36
+ =src
37
+ python_requires = >=3.8
38
+ install_requires =
39
+
40
+ [options.packages.find]
41
+ where = src
42
+
43
+ [options.entry_points]
44
+ console_scripts =
45
+ resolve-robotics-uri-py = resolve_robotics_uri_py.resolve_robotics_uri_py:main
46
+
47
+ [options.extras_require]
48
+ style =
49
+ black
50
+ isort
51
+ testing =
52
+ all =
53
+ %(style)s
54
+ %(testing)s
55
+
56
+ [tool:pytest]
57
+ addopts = -rsxX -v --strict-markers
58
+ testpaths = tests
59
+
60
+ [egg_info]
61
+ tag_build =
62
+ tag_date = 0
63
+
@@ -0,0 +1,3 @@
1
+ import setuptools
2
+
3
+ setuptools.setup()
@@ -0,0 +1 @@
1
+ from .resolve_robotics_uri_py import resolve_robotics_uri
@@ -0,0 +1,81 @@
1
+ import argparse
2
+ import os
3
+ import pathlib
4
+ import sys
5
+ from typing import List
6
+ import warnings
7
+
8
+ # Function inspired from https://github.com/ami-iit/robot-log-visualizer/pull/51
9
+ def get_search_paths_from_envs(env_list):
10
+ return [
11
+ pathlib.Path(f) if (env != "AMENT_PREFIX_PATH") else pathlib.Path(f) / "share"
12
+ for env in env_list if os.getenv(env) is not None
13
+ for f in os.getenv(env).split(os.pathsep)
14
+ ]
15
+
16
+ def pathlist_list_to_string(path_list):
17
+ return ' '.join(str(path) for path in path_list)
18
+
19
+ def resolve_robotics_uri(uri: str) -> pathlib.Path:
20
+ # List of environment variables to consider, see:
21
+ # * https://github.com/robotology/idyntree/issues/291
22
+ # * https://github.com/gazebosim/sdformat/issues/1234
23
+ # AMENT_PREFIX_PATH is the only "special" as we need to add
24
+ # "share" after each value, see https://github.com/stack-of-tasks/pinocchio/issues/1520
25
+ # This list specify the origin of each env variable:
26
+ # * GAZEBO_MODEL_PATH: Used in Gazebo Classic
27
+ # * ROS_PACKAGE_PATH: Used in ROS1
28
+ # * AMENT_PREFIX_PATH: Used in ROS2
29
+ # * SDF_PATH: Used in sdformat
30
+ # * IGN_GAZEBO_RESOURCE_PATH: Used in Ignition Gazebo <= 7
31
+ # * GZ_SIM_RESOURCE_PATH: Used in Gazebo Sim >= 7
32
+ env_list = ["GAZEBO_MODEL_PATH", "ROS_PACKAGE_PATH", "AMENT_PREFIX_PATH", "SDF_PATH", "IGN_GAZEBO_RESOURCE_PATH", "GZ_SIM_RESOURCE_PATH"]
33
+
34
+ # Preliminary step: if there is no scheme, we just consider this a path and we return it as it is
35
+ if "://" not in uri:
36
+ return pathlib.Path(uri)
37
+
38
+ # Get scheme from URI
39
+ from urllib.parse import urlparse
40
+ parsed_uri = urlparse(uri)
41
+
42
+ # We only support at the moment:
43
+ # file:// scheme: to pass a file path directly
44
+ # package:// : ROS-style package URI
45
+ # model:// : SDF-style model URI
46
+ if parsed_uri.scheme not in ["file", "package", "model"]:
47
+ raise FileNotFoundError(f"Passed URI \"{uri}\" use non-supported scheme {parsed_uri.scheme}")
48
+
49
+ model_filenames = []
50
+
51
+ if parsed_uri.scheme == "file":
52
+ model_filenames.append(uri.replace("file:/", ""))
53
+
54
+ if parsed_uri.scheme == "package" or parsed_uri.scheme == "model":
55
+ uri_path = uri.replace(f"{parsed_uri.scheme}://","")
56
+ for folder in get_search_paths_from_envs(env_list):
57
+ candidate_file_name = folder / pathlib.Path(uri_path)
58
+ if (candidate_file_name.is_file()):
59
+ if candidate_file_name not in model_filenames:
60
+ model_filenames.append(candidate_file_name)
61
+
62
+ if model_filenames:
63
+ if (len(model_filenames) > 1):
64
+ warnings.warn(f"resolve-robotics-uri-py: Multiple files ({pathlist_list_to_string(model_filenames)}) found for uri \"{uri}\", returning the first one.")
65
+ return pathlib.Path(model_filenames[0])
66
+
67
+ # If no file was found raise error
68
+ raise FileNotFoundError(f"resolve-robotics-uri-py: No file corresponding to uri \"{uri}\" found")
69
+
70
+ def main():
71
+ parser = argparse.ArgumentParser(description="Utility resolve a robotics URI (file://, model://, package://) to an absolute filename.")
72
+ parser.add_argument("uri", metavar="uri", type=str, help="URI to resolve")
73
+
74
+ args = parser.parse_args()
75
+ result = resolve_robotics_uri(args.uri)
76
+
77
+ print(result)
78
+ sys.exit(0)
79
+
80
+ if __name__ == "__main__":
81
+ main()
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.1
2
+ Name: resolve-robotics-uri-py
3
+ Version: 0.1.0
4
+ Summary: Pure python package to solve ROS-style package:// and Gazebo-style model:// URIs in absolute paths.
5
+ Home-page: https://github.com/ami-iit/resolve-robotics-uri-py
6
+ Author: Silvio Traversaro
7
+ Author-email: silvio.traversaro@iit.it
8
+ License: BSD
9
+ Project-URL: Changelog, https://github.com/ami-iit/resolve-robotics-uri-py/releases
10
+ Project-URL: Source, https://github.com/ami-iit/resolve-robotics-uri-py
11
+ Project-URL: Tracker, https://github.com/ami-iit/resolve-robotics-uri-py/issues
12
+ Platform: any
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: BSD License
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Topic :: Software Development
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ Provides-Extra: style
29
+ Provides-Extra: testing
30
+ Provides-Extra: all
31
+ License-File: LICENSE
32
+
33
+ # resolve-robotics-uri-py
34
+
35
+ Pure Python package (that only depends on Python stdlib) to resolve a package:// (ROS-style) or model:// (Gazebo-style) URI to an absolute filename.
36
+
37
+ ## Installation
38
+
39
+ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install resolve-robotics-uri-py.
40
+
41
+ ```bash
42
+ python -m pip install resolve-robotics-uri-py
43
+ ```
44
+
45
+ ## Usage in Python
46
+
47
+ Add `import resolve_robotics_uri_py` to your Python file, then take inspiration from the following examples.
48
+
49
+ If you want to get the location of the `iCubGazeboV2_7` iCub model installed from [`icub-models`](https://github.com/robotology/icub-models):
50
+
51
+ ~~~python
52
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://iCub/robots/iCubGazeboV2_7/model.urdf")
53
+ ~~~
54
+
55
+ If you want to get the location of the `ergoCubSN00` model installed from [`ergocub-software`](https://github.com/icub-tech-iit/ergocub-software):
56
+
57
+ ~~~python
58
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://ergoCub/robots/ergoCubSN000/model.urdf")
59
+ ~~~
60
+
61
+ If you want to get the location of the `panda` model installed by [`moveit_resources_panda_description`](https://index.ros.org/p/moveit_resources_panda_description/):
62
+
63
+ ~~~python
64
+ absolute_path = resolve_robotics_uri_py.resolve_robotics_uri("package://moveit_resources_panda_description/urdf/panda.urdf")
65
+ ~~~
66
+
67
+
68
+ ## Command Line usage
69
+
70
+ `resolve_robotics_uri_py` also install a command line tool called `resolve-robotics-uri-py` for use in scripts, that can be used as:
71
+
72
+ ~~~
73
+ resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf
74
+ ~~~
75
+
76
+ For example, on bash this can be used to easily convert the a urdf specified via `package://` to an sdf (assuming you have Gazebo installed), using the [backtick operator](https://www.redhat.com/sysadmin/backtick-operator-vs-parens):
77
+ ~~~
78
+ gz sdf -p `resolve-robotics-uri-py package://iCub/robots/iCubGazeboV2_7/model.urdf`
79
+ ~~~
80
+
81
+ ## Contributing
82
+
83
+ Pull requests are welcome. For major changes, please open an issue first
84
+ to discuss what you would like to change.
85
+
86
+ Please make sure to update tests as appropriate.
87
+
88
+ ## License
89
+
90
+ [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html)
@@ -0,0 +1,19 @@
1
+ .gitignore
2
+ LICENSE
3
+ README.md
4
+ ci_env.yml
5
+ pyproject.toml
6
+ setup.cfg
7
+ setup.py
8
+ .github/workflows/ci.yml
9
+ .github/workflows/publish-to-pypi.yml
10
+ src/resolve_robotics_uri_py/__init__.py
11
+ src/resolve_robotics_uri_py/resolve_robotics_uri_py.py
12
+ src/resolve_robotics_uri_py.egg-info/PKG-INFO
13
+ src/resolve_robotics_uri_py.egg-info/SOURCES.txt
14
+ src/resolve_robotics_uri_py.egg-info/dependency_links.txt
15
+ src/resolve_robotics_uri_py.egg-info/entry_points.txt
16
+ src/resolve_robotics_uri_py.egg-info/not-zip-safe
17
+ src/resolve_robotics_uri_py.egg-info/requires.txt
18
+ src/resolve_robotics_uri_py.egg-info/top_level.txt
19
+ test/test_resolve_robotics_uri_py.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ resolve-robotics-uri-py = resolve_robotics_uri_py.resolve_robotics_uri_py:main
@@ -0,0 +1,10 @@
1
+
2
+ [all]
3
+ black
4
+ isort
5
+
6
+ [style]
7
+ black
8
+ isort
9
+
10
+ [testing]
@@ -0,0 +1,6 @@
1
+ import resolve_robotics_uri_py
2
+ import pytest
3
+
4
+ def test_non_existing_file():
5
+ with pytest.raises(FileNotFoundError):
6
+ resolve_robotics_uri_py.resolve_robotics_uri("package://this/package/and/file/does/not.exist")