-
Notifications
You must be signed in to change notification settings - Fork 412
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
Node::get_effective_namespace returns invalid namespace if sub-namespace is empty #1656
Comments
i think that question is that's why it generates exception
i guess current behavior makes sense to me. but it would be nice to add test on this case. CC: @ivanpauno @wjwwood what do you think ❓ |
…ce is empty ros2/rclcpp#1656 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Yep I know, but this rclcpp/rclcpp/include/rclcpp/node.hpp Lines 1204 to 1226 in 0659d82
reads to me as the effective namespace used for creating any entities (e.g., if it is a sub_node with the sub_namespace, if it is not just its original namespace), while get_namespace will only give you the original namespace should you be a sub_node (usefully if sub_nodes and nodes communicate on some entities with one another). Especially since it is part of any node's interface it should not return invalid namespace, but rather throw an exception itself it is not intended to be called on a normal node. In this case, to avoid boiler plate code in user code, we either adapt the function or provide a new interface for this. Hence for me calling |
Also for a reference you may refer to rclcpp/rclcpp/src/rclcpp/node.cpp Lines 193 to 196 in 0659d82
Which is part of rclcpp/rclcpp/src/rclcpp/node.cpp Lines 143 to 146 in 0659d82
the normal nodes interface and creates an invalid effective_namespace_. |
@devrite thanks for the explanation, i see that by itself as effective namespace, it should not include |
@fujitatomoya Your welcome. Took me quite some time to identify the issue, as I was originally faced by it when trying to patch Edit: As you already stated, it does not fail now. Missed that first. |
@fujitatomoya Could you add a call to |
Reproducible Samplehttps://github.com/fujitatomoya/ros2_test_prover/blob/master/prover_rclcpp/src/rclcpp_1656.cpp root@134f29e8f25f:~/ros2_ws/colcon_ws# ros2 run prover_rclcpp rclcpp_1656
[INFO] [1620346207.926351517] [ns.my_node]: Parent Node's effective name: /ns/
[INFO] [1620346207.926427278] [ns.my_node]: Child Node's effective name: /ns/sub_ns
|
@devrite i think you can add above test case around rclcpp/rclcpp/test/rclcpp/test_node.cpp Line 164 in 0659d82
|
Oh thanks, was not sure where I would add it. |
@wjwwood Hi if there is no conclusion yet, I would just change MR to use the old behaviour (no empty sub-namespace) but fix the problem for now. If we want to implement the new behaviour later (empty sub-ns allowed), we can open a new issue for that? |
Fix ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Adds regression test for ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Adds regression test for ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Fix ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Adds regression test for ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Fix ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
Adds regression test for ros2#1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
* Create valid effective namespace when sub-namespace is empty Fix #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> * Add regression test for effective namespace and empty sub-namespace Adds regression test for #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at>
* Create valid effective namespace when sub-namespace is empty Fix #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> * Add regression test for effective namespace and empty sub-namespace Adds regression test for #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> (cherry picked from commit 3cddb4e)
* Create valid effective namespace when sub-namespace is empty Fix #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> * Add regression test for effective namespace and empty sub-namespace Adds regression test for #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> (cherry picked from commit 3cddb4e)
) * Create valid effective namespace when sub-namespace is empty Fix #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> * Add regression test for effective namespace and empty sub-namespace Adds regression test for #1656. Signed-off-by: Markus Hofstaetter <markus.hofstaetter@ait.ac.at> (cherry picked from commit 3cddb4e) Co-authored-by: M. Hofstätter <markus.hofstaetter@gmx.net>
Hi everyone
I tested this on foxy but as you can see from:
rclcpp/rclcpp/src/rclcpp/node.cpp
Lines 81 to 95 in 1fc2d58
it returns an namespace with a slash at the end in both cases.
rclcpp::expand_topic_or_service_name
will then throw an exception it represents an invalid namespace format (e.g., '/' at the end are not allowed).Is this still the case? Or rclcpp behaving wrong in this case. But since we usually specify namespaces without slashes almost everywhere I can recall using it I think even if it were permitted we should return the namespace without the slash.
BR, Markus
The text was updated successfully, but these errors were encountered: