Skip to content

Commit ee53d27

Browse files
authored
Fix bug with mimic joint namespacing implementation (#10)
1 parent 8603d60 commit ee53d27

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkgs/node_helpers/node_helpers/urdfs/loading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
_CHILD_TAG = "child"
1212
_NAME_KEY = "name"
1313
_LINK_KEY = "link"
14+
_JOINT_KEY = "joint"
1415
_MIMIC_TAG = "mimic"
1516

1617

@@ -138,6 +139,6 @@ def prepend_namespace(urdf_str: str, namespace: str) -> str:
138139
elif node.tag == _MIMIC_TAG:
139140
node.set(
140141
"joint",
141-
NAMESPACE_FMT.format(namespace=namespace, name=node.get(_NAME_KEY)),
142+
NAMESPACE_FMT.format(namespace=namespace, name=node.get(_JOINT_KEY)),
142143
)
143144
return ElementTree.tostring(urdf, encoding="unicode")

pkgs/node_helpers/node_helpers_test/unit/urdfs/test_loading.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,15 @@ def test_prepend_namespace() -> None:
118118
)
119119
)
120120
assert len(expected_changes) == len(actual_changes)
121+
122+
123+
def test_mimics_are_prepended() -> None:
124+
"""Validate that 'mimic' style joints are prepended with the namespace as well."""
125+
126+
urdf_text: str = GENERIC_URDF.read_text()
127+
namespace = "cool_namespace"
128+
129+
mimic_joint = "clamp1-joint"
130+
assert f"{namespace}.{mimic_joint}" not in urdf_text
131+
modified = urdf_helpers.prepend_namespace(urdf_text, namespace=namespace)
132+
assert modified.count(f'mimic joint="{namespace}.{mimic_joint}"') == 1

0 commit comments

Comments
 (0)