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

parse middle_module from message type in ros2topic #278

Closed
wants to merge 2 commits into from

Conversation

davidhodo
Copy link

Attempts to solve issue #277. The middle module name is parsed from the message type rather than being hardcoded as .msg. I have tested it with a few message types generated from .msg and from .idl but not exhaustively. Is there a case where the message_type split could result in more than 3 strings?

support either .msg or .idl packages

Signed-off-by: David Hodo <[email protected]>
@jacobperron
Copy link
Member

It's undecided if we'll allow message types with more than three parts. There's an open proposal that there could be more than three: ros2/design#220
Until it is decided, I don't think we need to worry about supporting that use-case.

@davidhodo
Copy link
Author

Ok. I updated the request to default to 'msg' if the type only contains two parts. Can this be merged or is it a wontfix in light of the planned new features listed in #223 mentioned by Dirk in #277?

package_name, *message_name = message_type.split('/')
if not package_name or not message_name or not all(message_name):
package_name, middle_module, message_name = message_type.split('/')
if not middle_module:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't seem to make any sense. In which case would not middle_module be True?

raise ValueError()
except ValueError:
raise RuntimeError('The passed message type is invalid')

# TODO(sloretz) node API to get topic types should indicate if action or msg
middle_module = 'msg'
if topic_name.endswith('/_action/feedback'):
middle_module = 'action'

module = importlib.import_module(package_name + '.' + middle_module)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should just support any number of parts, e.g. '.'.join([package_name] + message_name[:-1]).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not generally make sense to unify this logic and have it in a central place? I know of at least one more other location where we duplicate the same logic:
https://github.com/ros2/ros2cli/blob/master/ros2service/ros2service/verb/call.py#L61-L72

Copy link
Member

@jacobperron jacobperron Jun 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. There's a TODO at the top of this function. I'm not sure what package it should belong in (or if a new package needs to be created).

@jacobperron jacobperron self-requested a review June 20, 2019 17:19
@nuclearsandwich
Copy link
Member

@davidhodo will you be able to address the feedback on this PR?

@nuclearsandwich nuclearsandwich added the in progress Actively being worked on (Kanban column) label Aug 8, 2019
@davidhodo
Copy link
Author

Yes. Sorry for the long delay. I will try to get it done this week.

@nuclearsandwich
Copy link
Member

@davidhodo are you still interested in updating this PR?

@jacobperron
Copy link
Member

I think this PR is obsolete by #415.

I'll check if #277 is resolved by #415 and if not, we should probably target a PR against https://github.com/ros2/rosidl_runtime_py.

@jacobperron jacobperron closed this Dec 5, 2019
@jacobperron
Copy link
Member

If we want this fix for Dashing, then I suggest re-opening this PR and changing the base branch to dashing. Trying to backport #415 and it's dependencies is much more work.

@davidhodo
Copy link
Author

Sorry. I am still interested, but have been swamped and haven't been able to get back to it. I'll rebase on Dashing and re-open as soon as I get some time.

esteve pushed a commit to esteve/ros2cli that referenced this pull request Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Actively being worked on (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants