Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non standard msg modules #735

Merged
merged 3 commits into from
Jun 9, 2022
Merged
Changes from all commits
Commits
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
30 changes: 28 additions & 2 deletions rosbridge_library/src/rosbridge_library/internal/ros_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,20 @@ def _get_msg_class(typestring):

Throws various exceptions if loading the msg class fails"""
global _loaded_msgs, _msgs_lock
return _get_class(typestring, "msg", _loaded_msgs, _msgs_lock)
try:
# The type string starts with the package and ends with the
# class and contains module subnames in between. For
# compatibility with ROS1 style types, we fall back to use a
# standard "msg" subname.
splits = [x for x in typestring.split("/") if x]
if len(splits) > 2:
subname = ".".join(splits[1:-1])
else:
subname = "msg"

return _get_class(typestring, subname, _loaded_msgs, _msgs_lock)
except (InvalidModuleException, InvalidClassException):
return _get_class(typestring, "msg", _loaded_msgs, _msgs_lock)


def _get_srv_class(typestring):
Expand All @@ -117,7 +130,20 @@ def _get_srv_class(typestring):

Throws various exceptions if loading the srv class fails"""
global _loaded_srvs, _srvs_lock
return _get_class(typestring, "srv", _loaded_srvs, _srvs_lock)
try:
# The type string starts with the package and ends with the
# class and contains module subnames in between. For
# compatibility with ROS1 style types, we fall back to use a
# standard "srv" subname.
splits = [x for x in typestring.split("/") if x]
if len(splits) > 2:
subname = ".".join(splits[1:-1])
else:
subname = "srv"

return _get_class(typestring, subname, _loaded_srvs, _srvs_lock)
except (InvalidModuleException, InvalidClassException):
return _get_class(typestring, "srv", _loaded_srvs, _srvs_lock)


def _get_class(typestring, subname, cache, lock):
Expand Down