rod 0.3.2.dev4__tar.gz → 0.3.2.dev5__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.
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/PKG-INFO +1 -1
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/sdf.py +23 -24
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod.egg-info/PKG-INFO +1 -1
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/tests/test_urdf_exporter.py +1 -1
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/tests/test_urdf_parsing.py +1 -5
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/.github/workflows/ci_cd.yml +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/.github/workflows/style.yml +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/.gitignore +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/LICENSE +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/README.md +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/pyproject.toml +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/setup.cfg +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/setup.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/builder/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/builder/primitive_builder.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/builder/primitives.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/kinematics/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/kinematics/kinematic_tree.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/kinematics/tree_transforms.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/logging.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/pretty_printer.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/collision.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/common.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/element.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/geometry.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/joint.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/link.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/material.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/model.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/physics.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/scene.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/visual.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/sdf/world.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/tree/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/tree/directed_tree.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/tree/tree_elements.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/urdf/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/urdf/exporter.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/utils/__init__.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/utils/frame_convention.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/utils/gazebo.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/utils/resolve_frames.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod/utils/resolve_uris.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod.egg-info/SOURCES.txt +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod.egg-info/dependency_links.txt +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod.egg-info/not-zip-safe +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod.egg-info/requires.txt +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/src/rod.egg-info/top_level.txt +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/tests/test_meshbuilder.py +0 -0
- {rod-0.3.2.dev4 → rod-0.3.2.dev5}/tests/utils_models.py +0 -0
|
@@ -54,7 +54,7 @@ class Sdf(Element):
|
|
|
54
54
|
|
|
55
55
|
Args:
|
|
56
56
|
sdf: The SDF resource to load.
|
|
57
|
-
is_urdf:
|
|
57
|
+
is_urdf: Force the SDF resource to be treated as URDF if the automatic detection fails.
|
|
58
58
|
|
|
59
59
|
Returns:
|
|
60
60
|
The parsed SDF file.
|
|
@@ -66,29 +66,28 @@ class Sdf(Element):
|
|
|
66
66
|
except ValueError:
|
|
67
67
|
MAX_PATH = os.pathconf("/", "PC_PATH_MAX")
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
# If is_urdf is None and the input resource is a file path, we try to guess
|
|
71
|
-
# the is_urdf flag checking the file extension.
|
|
72
|
-
|
|
73
|
-
# Check first if it's a Path object
|
|
74
|
-
if isinstance(sdf, pathlib.Path):
|
|
75
|
-
sdf_string = sdf.read_text()
|
|
76
|
-
is_urdf = is_urdf if is_urdf is not None else sdf.suffix == ".urdf"
|
|
77
|
-
|
|
78
|
-
# Then, check if it's a string with a path
|
|
79
|
-
elif (
|
|
80
|
-
isinstance(sdf, str)
|
|
81
|
-
and len(sdf) <= MAX_PATH
|
|
82
|
-
and pathlib.Path(sdf).is_file()
|
|
83
|
-
):
|
|
84
|
-
sdf_string = pathlib.Path(sdf).read_text(encoding="utf-8")
|
|
85
|
-
is_urdf = (
|
|
86
|
-
is_urdf if is_urdf is not None else pathlib.Path(sdf).suffix == ".urdf"
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
# Finally, it must be a SDF/URDF string
|
|
90
|
-
else:
|
|
69
|
+
if is_urdf is not None:
|
|
91
70
|
sdf_string = sdf
|
|
71
|
+
else:
|
|
72
|
+
match sdf:
|
|
73
|
+
# Case 1: It's a Path object
|
|
74
|
+
case pathlib.Path():
|
|
75
|
+
sdf_string = sdf.read_text()
|
|
76
|
+
is_urdf = sdf.suffix == ".urdf"
|
|
77
|
+
|
|
78
|
+
# Case 2: It's a string with a path
|
|
79
|
+
case str() if len(sdf) <= MAX_PATH and pathlib.Path(sdf).is_file():
|
|
80
|
+
sdf_string = pathlib.Path(sdf).read_text(encoding="utf-8")
|
|
81
|
+
is_urdf = pathlib.Path(sdf).suffix == ".urdf"
|
|
82
|
+
|
|
83
|
+
# Case 3: It's an SDF/URDF string
|
|
84
|
+
case str():
|
|
85
|
+
sdf_string = sdf
|
|
86
|
+
is_urdf = "<robot>" in sdf_string
|
|
87
|
+
|
|
88
|
+
# Case 4: Raise an error for unsupported types
|
|
89
|
+
case _:
|
|
90
|
+
raise TypeError(f"Unsupported type for 'sdf': {type(sdf)}")
|
|
92
91
|
|
|
93
92
|
# Convert SDF to URDF if needed (it requires system executables)
|
|
94
93
|
if is_urdf:
|
|
@@ -101,7 +100,7 @@ class Sdf(Element):
|
|
|
101
100
|
try:
|
|
102
101
|
xml_dict = xmltodict.parse(xml_input=sdf_string)
|
|
103
102
|
except Exception as exc:
|
|
104
|
-
raise
|
|
103
|
+
raise RuntimeError("Failed to parse 'sdf' argument") from exc
|
|
105
104
|
|
|
106
105
|
# Look for the top-level <sdf> element
|
|
107
106
|
try:
|
|
@@ -26,7 +26,7 @@ def test_urdf_exporter(robot: Robot) -> None:
|
|
|
26
26
|
original_urdf_path = ModelFactory.get_model_description(robot=robot)
|
|
27
27
|
|
|
28
28
|
# Load the URDF (it gets converted to SDF internally).
|
|
29
|
-
sdf = rod.Sdf.load(sdf=original_urdf_path
|
|
29
|
+
sdf = rod.Sdf.load(sdf=original_urdf_path)
|
|
30
30
|
|
|
31
31
|
# Export the URDF from the in-memory SDF-based description.
|
|
32
32
|
exported_urdf_string = rod.urdf.exporter.UrdfExporter().to_urdf_string(sdf=sdf)
|
|
@@ -35,10 +35,6 @@ def test_urdf_parsing(robot: Robot) -> None:
|
|
|
35
35
|
with pytest.raises(RuntimeError):
|
|
36
36
|
_ = rod.Sdf.load(sdf=urdf_path.read_text(), is_urdf=False)
|
|
37
37
|
|
|
38
|
-
# Check that it fails if is_urdf=False and the resource is an urdf string
|
|
39
|
-
with pytest.raises(RuntimeError):
|
|
40
|
-
_ = rod.Sdf.load(sdf=urdf_path.read_text(), is_urdf=None)
|
|
41
|
-
|
|
42
38
|
# The following instead should succeed
|
|
43
39
|
_ = rod.Sdf.load(sdf=urdf_path, is_urdf=None)
|
|
44
40
|
_ = rod.Sdf.load(sdf=urdf_path, is_urdf=True)
|
|
@@ -47,7 +43,7 @@ def test_urdf_parsing(robot: Robot) -> None:
|
|
|
47
43
|
_ = rod.Sdf.load(sdf=urdf_path.read_text(), is_urdf=True)
|
|
48
44
|
|
|
49
45
|
# Load once again the urdf
|
|
50
|
-
rod_sdf = rod.Sdf.load(sdf=urdf_path
|
|
46
|
+
rod_sdf = rod.Sdf.load(sdf=urdf_path)
|
|
51
47
|
|
|
52
48
|
# There should be only one model
|
|
53
49
|
assert len(rod_sdf.models()) == 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|