Skip to content

Commit 8dfabff

Browse files
Copilotchase6305
andauthored
Add naming-semantics tests for URDF assembly; fix name_case propagation bug (#203)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chase6305 <61959467+chase6305@users.noreply.github.com>
1 parent 9f58058 commit 8dfabff

2 files changed

Lines changed: 408 additions & 0 deletions

File tree

embodichain/toolkits/urdf_assembly/component.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,44 @@ def __init__(
130130
mode,
131131
)
132132

133+
@property
134+
def name_case(self) -> dict[str, str]:
135+
"""Get the current name case policy.
136+
137+
Returns:
138+
dict[str, str]: A mapping of ``"joint"`` / ``"link"`` to their
139+
case modes.
140+
"""
141+
return self._name_case
142+
143+
@name_case.setter
144+
def name_case(self, new_name_case: dict[str, str]) -> None:
145+
"""Replace the name case policy.
146+
147+
Invalid entries are silently ignored (logged as warnings) to stay
148+
consistent with the constructor behaviour. This intentionally differs
149+
from :class:`URDFAssemblyManager`, which raises ``ValueError`` for
150+
bad inputs, because this low-level manager is designed to be lenient
151+
so it can be used in contexts where the caller cannot easily validate
152+
inputs upfront.
153+
154+
Args:
155+
new_name_case (dict[str, str]): Mapping of ``"joint"`` / ``"link"``
156+
to ``"upper"``, ``"lower"``, or ``"none"``.
157+
"""
158+
updated: dict[str, str] = {}
159+
for key, mode in new_name_case.items():
160+
if key in {"joint", "link"} and mode in {"upper", "lower", "none"}:
161+
updated[key] = mode
162+
else:
163+
self.logger.warning(
164+
"Ignoring invalid name_case entry %r=%r (allowed keys: 'joint', 'link'; "
165+
"allowed modes: 'upper', 'lower', 'none')",
166+
key,
167+
mode,
168+
)
169+
self._name_case.update(updated)
170+
133171
def _apply_case(self, kind: str, name: str | None) -> str | None:
134172
"""Normalize a name according to the configured case policy.
135173

0 commit comments

Comments
 (0)