diff --git a/phobos/ci/base_model.py b/phobos/ci/base_model.py index ef9574af..0d78114b 100644 --- a/phobos/ci/base_model.py +++ b/phobos/ci/base_model.py @@ -571,13 +571,7 @@ def process(self): config = misc.merge_default(self.joints[jointname], _default) joint.name = misc.edit_name_string(joint.name, **config.get("name_editing", {})) if "$name_editing" in self.joints: - if self.joints["$name_editing"].get("joint_equals_link_name", False): - for joint in self.robot.joints: - self.robot.rename(targettype="joint", target=joint.name, replacements={ - joint.name: joint.child if not joint.child.upper().endswith("_LINK") else joint.child[:-5] - }) - else: - self.robot.rename("joints", self.robot.joints, **self.joints.get("$name_editing", {})) + self.robot.rename("joints", self.robot.joints, **self.joints.get("$name_editing", {})) # as we mess manually with some names, we need to make sure the tree maps are up to date self.robot.regenerate_tree_maps() diff --git a/phobos/core/robot.py b/phobos/core/robot.py index 115d03fe..82ca2134 100755 --- a/phobos/core/robot.py +++ b/phobos/core/robot.py @@ -1850,7 +1850,7 @@ def rename_all(self, prefix=None, suffix=None, replacements=None, do_not_double= self.rename(targettype, getattr(self, targettype), prefix=prefix, suffix=suffix, replacements=replacements, do_not_double=do_not_double) - def rename(self, targettype, target, prefix=None, suffix=None, replacements=None, do_not_double=True): + def rename(self, targettype, target, prefix=None, suffix=None, replacements=None, do_not_double=True, joint_equals_link_name=False): """ Renames the target with the given args Note: Override this in subclasses and call super at the beginning @@ -1866,7 +1866,8 @@ def rename(self, targettype, target, prefix=None, suffix=None, replacements=None if type(target) is list: for t in target: renamed_entities.update(self.rename(targettype, t, prefix=prefix, suffix=suffix, - replacements=replacements, do_not_double=do_not_double)) + replacements=replacements, do_not_double=do_not_double, + joint_equals_link_name=joint_equals_link_name)) return renamed_entities elif type(target) is not str: target = str(target) @@ -1878,10 +1879,14 @@ def rename(self, targettype, target, prefix=None, suffix=None, replacements=None if suffix is not None and target.endswith(suffix): suffix = None - if not prefix and not suffix and replacements == {}: + if not prefix and not suffix and replacements == {} and not joint_equals_link_name: return renamed_entities - new_name = edit_name_string(target, prefix=prefix, suffix=suffix, replacements=replacements) + if targettype.startswith("joint") and joint_equals_link_name: + joint = self.get_joint(target) + new_name = joint.child if not joint.child.upper().endswith("_LINK") else joint.child[:-5] + else: + new_name = edit_name_string(target, prefix=prefix, suffix=suffix, replacements=replacements) renamed_entities.update(self._rename(targettype, target, new_name)) if targettype in ['link', "links"]: