Skip to content

Commit 8cd4829

Browse files
authored
Merge pull request #9 from compas-dev/no_support_package
Allow no support package in LocalPackageMeshLoader
2 parents ef645f7 + 345f4e3 commit 8cd4829

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Changed
1313

1414
* Fixed bug in `RobotModelObject` caused by non-existent `compas_rhino.rs`. Replaced with `import rhinoscriptsyntax as rs`.
15+
* Allow no `support_package` in `LocalPackageMeshLoader`
1516

1617
### Removed
1718

src/compas_robots/resources/basic.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,20 @@ class LocalPackageMeshLoader(AbstractMeshLoader):
156156
----------
157157
path : str
158158
Path where the package is stored locally.
159-
support_package : str
159+
support_package : str, optional
160160
Name of the support package containing URDF, Meshes
161-
and additional assets, e.g. 'abb_irb4400_support'
161+
and additional assets, e.g. 'abb_irb4400_support'.
162+
Default is None.
162163
"""
163164

164-
def __init__(self, path, support_package):
165+
def __init__(self, path, support_package=None):
165166
super(LocalPackageMeshLoader, self).__init__()
166167
self.path = path
167168
self.support_package = support_package
168-
self.schema_prefix = "package://" + self.support_package + "/"
169+
if not support_package:
170+
self.schema_prefix = "package://"
171+
else:
172+
self.schema_prefix = "package://" + self.support_package + "/"
169173

170174
def build_path(self, *path_parts):
171175
"""Returns the building path.
@@ -179,7 +183,10 @@ def build_path(self, *path_parts):
179183
-------
180184
str
181185
"""
182-
return os.path.join(self.path, self.support_package, *path_parts)
186+
if not self.support_package:
187+
return os.path.join(self.path, *path_parts)
188+
else:
189+
return os.path.join(self.path, self.support_package, *path_parts)
183190

184191
def load_urdf(self, file):
185192
"""Load a URDF file from local storage.

tests/test_resources.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
from compas_robots.resources import LocalPackageMeshLoader
4+
5+
6+
def test_build_path():
7+
loader_with_support_package = LocalPackageMeshLoader("meshes", "ur_description")
8+
assert os.path.join("meshes", "ur_description", "urdf", "some.urdf") == loader_with_support_package.build_path(
9+
"urdf", "some.urdf"
10+
)
11+
12+
loader_without_support_package = LocalPackageMeshLoader("meshes")
13+
assert os.path.join("meshes", "urdf", "some.urdf") == loader_without_support_package.build_path("urdf", "some.urdf")

0 commit comments

Comments
 (0)