module documentation

Turning names from ROS2 into browse names.

A message field or a parameter segment such as child_frame_id is browsed as ChildFrameId, which follows the opensmi naming rule. The raw ROS2 name stays as the DisplayName. A name that does not convert is refused, never fixed silently.

Function browse_name Return the browse name for a ROS2 name: split on _, capitalise each part, join.
Function browse_names Return the browse name of each ROS2 name among siblings, keyed by the ROS2 name.
Function pascal_case Return name parts capitalised and joined, which is how opensmi derives a browse name from a field name.
Function suggested_name Return the name that follows the rule and is closest to name, or None if there is none.
Constant _CONVERTIBLE Undocumented
Constant _NOT_NAME_CHARACTERS Undocumented
@cache
def browse_name(ros2_name: str) -> str:

Return the browse name for a ROS2 name: split on _, capitalise each part, join.

child_frame_id gives ChildFrameId and FollowPath stays as it is. Use ros2_name itself as the DisplayName.

Raises
BindingNameErrorWhen the name has a character other than letters, digits and _, an empty part, or does not give a valid browse name (it starts with a digit, or is None, True or False). The message suggests a name where one can be derived.
def browse_names(ros2_names: Iterable[str], renamed: Mapping[str, str] | None = None) -> dict[str, str]:

Return the browse name of each ROS2 name among siblings, keyed by the ROS2 name.

A name in renamed takes its new name as it is, which already follows the rule.

Raises
BindingNameErrorWhen one name does not convert, see browse_name.
DuplicateVariableNameErrorWhen two names give one browse name, such as x_1 and x1. The error names both ROS2 names; the author fixes it with the rename option of the Binding.
def pascal_case(parts: Iterable[str]) -> str:

Return name parts capitalised and joined, which is how opensmi derives a browse name from a field name.

def suggested_name(name: str) -> str | None:

Return the name that follows the rule and is closest to name, or None if there is none.

_CONVERTIBLE =

Undocumented

Value
re.compile(r'[A-Za-z0-9]+(_[A-Za-z0-9]+)*')
_NOT_NAME_CHARACTERS =

Undocumented

Value
re.compile(r'[^A-Za-z0-9]+')