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

Support non-absolute topic names. #57

Merged
merged 4 commits into from
Oct 3, 2017
Merged

Conversation

clalancette
Copy link
Contributor

If the user passes "/topic_name" to the ros2 echo
command, it works properly. If they pass "topic_name"
to the ros2 echo command, it fails to match. This
change just allows us to deal with non-absolute topic
names.

This should fix #54 . I ran the tests against the ros2cli package locally,
with no errors. No CI since this is python code and it won't tell us very much.

Signed-off-by: Chris Lalancette clalancette@gmail.com

If the user passes "/topic_name" to the ros2 echo
command, it works properly.  If they pass "topic_name"
to the ros2 echo command, it fails to match.  This
change just allows us to deal with non-absolute topic
names.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette clalancette added the in progress Actively being worked on (Kanban column) label Sep 27, 2017
@wjwwood
Copy link
Member

wjwwood commented Sep 27, 2017

Why not use https://github.com/ros2/rclpy/blob/0fbf30c4a9ffe9b4edb77c4888d07a61ed921ef9/rclpy/rclpy/expand_topic_name.py#L18?

@wjwwood
Copy link
Member

wjwwood commented Sep 27, 2017

I think it would be better, since it would respect namespaces as well.

@clalancette
Copy link
Contributor Author

Only because I didn't know about it :). Thanks, I'll give that a try.

This will handle namespaces as well.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
@clalancette clalancette added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Sep 27, 2017
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm

However, you might be interested in validating it as well, see:

https://github.com/ros2/rclpy/blob/0fbf30c4a9ffe9b4edb77c4888d07a61ed921ef9/rclpy/rclpy/expand_topic_name.py#L22-L25

It will be validated when you try to create a publisher or subscriber, so that might be sufficient, but you could potentially catch it sooner if you validate it yourself.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
@clalancette
Copy link
Contributor Author

I added in the validation as @wjwwood suggested. I'm also running a CI job, just on Linux, to make sure there aren't any lingering linting/pep8 errors: Build Status. Assuming that is green, I'm going to go ahead and merge this.

Copy link
Member

@mikaelarguedas mikaelarguedas left a comment

Choose a reason for hiding this comment

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

lgtm, one nitpick comment not preventing from merging

@@ -97,8 +99,10 @@ def represent_ordereddict(dumper, data):
def subscriber(node, topic_name, message_type, callback):
if message_type is None:
topic_names_and_types = get_topic_names_and_types(node=node)
expanded_name = expand_topic_name(topic_name, node.get_name(), node.get_namespace())
validate_full_topic_name(expanded_name, is_service=False)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: False being the default you shouldn't need to have to pass the is_service keyword

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Will fix that before merging.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
@clalancette
Copy link
Contributor Author

CI is green, I fixed the small problem, and it's approved. Merging.

@clalancette clalancette merged commit ce77579 into master Oct 3, 2017
@clalancette clalancette deleted the leading-slash-topic-name branch October 3, 2017 20:57
@@ -97,8 +99,10 @@ def represent_ordereddict(dumper, data):
def subscriber(node, topic_name, message_type, callback):
if message_type is None:
topic_names_and_types = get_topic_names_and_types(node=node)
expanded_name = expand_topic_name(topic_name, node.get_name(), node.get_namespace())
validate_full_topic_name(expanded_name)
Copy link
Member

Choose a reason for hiding this comment

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

This function might raise an InvalidTopicNameException which I assume results in printing a stacktrace which is not a good user experience. The possible exceptions should be catched and a "nicer" error message (without a stacktrace) should be printed instead.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, when I made that suggestion I meant you could raise it here, catch it and do something nicer. If you just want the traceback, then that will happen when you try to create a pub or sub with the topic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, OK. I'll open a new PR with something nicer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#58

esteve pushed a commit to esteve/ros2cli that referenced this pull request Dec 16, 2022
* Added support for command line launch arguments

Updated to support passing in command line arguments in the same format used by roslaunch (i.e., arg_name:=value). This supports zero or more arguments added after one or more launch files passed on the command line.

* Updates to parsing/handling of command line args

* Addressed review comments

Fixed linter errors, updated copyrights, updated sphinx documentation, used different form of print.

* pep257 fixup

* use single quotes

* Addressing comments from review

Using single quotes instead of double quotes, fixed mistaken copyright year, allow the launch arg value to contain the arg separator, cleaned up main

* Updated to support --args format

* Fixing additional style errors

Removed unnecessary code, fixed style/linting problems.

* while passing the linter as is the extra indentation makes it a bit easier to read
esteve pushed a commit to esteve/ros2cli that referenced this pull request Dec 16, 2022
* Add substitution for finding package share directory

Expose FindPackageShare as 'find-pkg-share' and FindPackagePrefix as 'find-pkg-prefix'.

This turns

    <include file="$(find-pkg foo)/share/foo/launch/foo.launch.xml">

into

    <include file="$(find-pkg-share foo)/launch/foo.launch.xml">

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Refactor to use abstract class

FindPackage is now an abstract class that requires subclasses to implement a 'find' method.
FindPackagePrefix is the subclass that finds the package prefix.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update error message and describe() method

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review Waiting for review (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ros2 topic echo cannot determine type for a non FQN topic
4 participants