Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkgs/node_helpers/node_helpers/urdfs/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
_CHILD_TAG = "child"
_NAME_KEY = "name"
_LINK_KEY = "link"
_JOINT_KEY = "joint"
_MIMIC_TAG = "mimic"


Expand Down Expand Up @@ -138,6 +139,6 @@ def prepend_namespace(urdf_str: str, namespace: str) -> str:
elif node.tag == _MIMIC_TAG:
node.set(
"joint",
NAMESPACE_FMT.format(namespace=namespace, name=node.get(_NAME_KEY)),
NAMESPACE_FMT.format(namespace=namespace, name=node.get(_JOINT_KEY)),
)
return ElementTree.tostring(urdf, encoding="unicode")
12 changes: 12 additions & 0 deletions pkgs/node_helpers/node_helpers_test/unit/urdfs/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@ def test_prepend_namespace() -> None:
)
)
assert len(expected_changes) == len(actual_changes)


def test_mimics_are_prepended() -> None:
"""Validate that 'mimic' style joints are prepended with the namespace as well."""

urdf_text: str = GENERIC_URDF.read_text()
namespace = "cool_namespace"

mimic_joint = "clamp1-joint"
assert f"{namespace}.{mimic_joint}" not in urdf_text
modified = urdf_helpers.prepend_namespace(urdf_text, namespace=namespace)
assert modified.count(f'mimic joint="{namespace}.{mimic_joint}"') == 1