-
Notifications
You must be signed in to change notification settings - Fork 482
Implement functions to get publisher and subcription informations like QoS policies from topic name #960
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
Conversation
|
This commit is for #943. |
| topic_name, | ||
| rcl_node_get_name(rcl_node_handle), | ||
| rcl_node_get_namespace(rcl_node_handle), | ||
| false); // false = not a service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What specifically did you mean should be done in the rcl layer? This whole function?
Is rclcpp::expand_topic_or_service_name() getting the fully qualified name of topic_name, and there's an equivalent in rcl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What specifically did you mean should be done in the rcl layer? This whole function?
Yes.
Is rclcpp::expand_topic_or_service_name() getting the fully qualified name of topic_name, and there's an equivalent in rcl?
Is getting a name and converting it to a "fully qualified name" (actually, it's just expanding, remappings are missing).
In rcl, there is a function that does the expand, and another that does the remapping. That combination is repeated in many place in the codebase. I think it would be good to combine the whole expand and remap logic in one function (a is_service flag will be needed).
Most rcl functions, like create_publisher, accept a topic name that's then expanded and remapped.
The only exception I know is rcl_count_publishers, which requires a fully qualified name.
The rclcpp counterpart doesn't requires a fully qualified name, but does the expansion (and, AFAIS the remapping part is missing). I wonder if both the expansion and remapping should be done in rcl, which would improve code reusage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if both the expansion and remapping should be done in
rcl, which would improve code reusage.
Yeah, my first thought was that it's surprising that there's a expand_topic_or_service_name()
in rclcpp. I thought it was going to be at most just a thin wrapper around something in rcl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that "rclcpp::expand_topic_or_service_name()" should not at rclcpp layer.
rclcpp::expand_topic_or_service_name() not only expand the name, but to check if the name is valid and then throw exception of rclcpp.
If not calling "rclcpp::expand_topic_or_service_name()" at rclcpp layer, I think rcl should check name at each interfaces.
and then rclcpp check the returned value from rcl to throw rclcpp itself exception.
Maybe need a new issue to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to answer @ivanpauno's question
I wonder if this should be done in rcl layer.
Yeah, I think so, but it's outside the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, the changes are broader that just this new functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following my comment in the conversation about the line just above, I think we need to decide if it is needed or not, and if it is needed then we should probably do it in rcl if we can, but I agree we could do it in a follow up. However, I would like to have a decision on what we should do before continuing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a couple of things going on here.
rclcpp::expand_topic_or_service_name() does topic name expansion and validation, and does not do remapping.
rclpy.expand_topic_name.expand_topic_name() does topic name expansion, does not do validation (the caller is supposed to do it manually), and also does not do remapping.
(My understanding of remapping here is that the returned/output topic name is the remapped version of the input topic name.)
The follow-up should be to implement in rcl a function like rcl_get_expanded_and_remapped_topic_name() (and it also does validation). This function supposedly should be agnostic to the no_mangle parameter as well.
|
Thanks for your comments. |
|
Hi @Barry-Xu-2018, can you add me as a collaborator to https://github.com/Barry-Xu-2018/rclcpp? |
| topic_name, | ||
| rcl_node_get_name(rcl_node_handle), | ||
| rcl_node_get_namespace(rcl_node_handle), | ||
| false); // false = not a service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What specifically did you mean should be done in the rcl layer? This whole function?
Is rclcpp::expand_topic_or_service_name() getting the fully qualified name of topic_name, and there's an equivalent in rcl?
| topic_name, | ||
| rcl_node_get_name(rcl_node_handle), | ||
| rcl_node_get_namespace(rcl_node_handle), | ||
| false); // false = not a service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What specifically did you mean should be done in the rcl layer? This whole function?
Yes.
Is rclcpp::expand_topic_or_service_name() getting the fully qualified name of topic_name, and there's an equivalent in rcl?
Is getting a name and converting it to a "fully qualified name" (actually, it's just expanding, remappings are missing).
In rcl, there is a function that does the expand, and another that does the remapping. That combination is repeated in many place in the codebase. I think it would be good to combine the whole expand and remap logic in one function (a is_service flag will be needed).
Most rcl functions, like create_publisher, accept a topic name that's then expanded and remapped.
The only exception I know is rcl_count_publishers, which requires a fully qualified name.
The rclcpp counterpart doesn't requires a fully qualified name, but does the expansion (and, AFAIS the remapping part is missing). I wonder if both the expansion and remapping should be done in rcl, which would improve code reusage.
OK. I added you. |
|
I have updated codes based on your comments. |
fujitatomoya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
08cce5d to
c9e03c8
Compare
|
@mm318 @ivanpauno @fujitatomoya Sorry. Next I am going to take Chinese New Year holiday. During holiday, maybe I cannot response your comments. I will be back on Feb 1st. |
I should be able to address comments since I'm a collaborator. Have a great holidays! |
Thank you :) |
| topic_name, | ||
| rcl_node_get_name(rcl_node_handle), | ||
| rcl_node_get_namespace(rcl_node_handle), | ||
| false); // false = not a service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, the changes are broader that just this new functions.
| std::vector<rclcpp::TopicEndpointInfo> topic_info_list; | ||
|
|
||
| auto rcl_node_handle = node_base->get_rcl_node_handle(); | ||
| auto fqdn = rclcpp::expand_topic_or_service_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, how does expand_topic_or_service_name() work without a no_mangle parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, one thing is mangling, i.e. generate a valid middleware name (e.g. DDS) from the ROS name.
Another thing is expansion, i.e. get full names from relative names ('topic' -> '/namespace/topic/') and full names from private names ('~/topic' -> '/namespace/node_name/topic/').
Remapping should be always done after expansion, but it's missing here (can be added later, as it's a preexisting problem in get_publisher_count too).
We're everywhere always doing remapping and expansion, including when we do no_mangle=true (or when this qos setting is set to true). IMO, always doing remapping and expansion is ok, though is arguable. Considering that, expand_topic_or_service_name doesn't need to know about no_mangle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to get a holistic summary of how we think no_mangle should be used with each of these functions, and then make sure the implementation matches. I feel like there have been several such conversations and potentially different solutions in each case. Also I haven't heard a compelling story for why one way or the other.
I would prefer to see clarity on this point before moving forward, even if that means we need to follow up after this pr and fix other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing is expansion, i.e. get full names from relative names ('topic' -> '/namespace/topic/') and full names from private names ('~/topic' -> '/namespace/node_name/topic/').
I meant to confirm if the expansion algorithm will work for a middleware topic names well? For example rt/topic -> rt/namespace/topic. (And I guess rt/~/topic is an invalid topic name regardless of the value of no_mangle.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that this is indeed the latter case: if no_mangle==true, then the input into this get_info_by_topic() function and subsequently the expand_topic_or_service_name() function is to be treated as a middleware topic name.
I don't have arguments in favor of applying remapping and expansion when using
no_mangle=true.
In the latter case, I think that expanding the input may not be desired, but I could be wrong.
Then it sounds like no_mangle==true does imply that the input topic_name parameter will need to be fully qualified? (Though we've been removing statements about that from the docstrings.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivanpauno summarized our discussion here:
Basically we want all of the graph query functions (including this one) to do both expansion (foo becomes /node_ns/foo) and remapping, by default. And then we want them all to have an option to skip both expansion and remapping.
Also, any functions that return topic or type names should be able to avoid de-mangling of those names.
Currently this implementation does expansion but not remapping (as far as I can tell), and it has an option no_mangle to make the query assume the input topic should be considered as is, without any additional prefixes or other mangling. It does not, however, have a no_demangle, which some of the other functions do have.
This no_mangle option does not prevent the topic name expansion here, which is a problem in my opinion, what do you think @ivanpauno?
As I see it we need to do these things to get this merged:
- add remapping of the input topic name to this function
- avoid expansion and remapping when
no_mangleis specified
Later we should make a set of pull requests which add a no_demangle option to these query functions. This will affect all the layers unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also make sure the rclpy version of this matches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically we want all of the graph query functions (including this one) to do both expansion (foo becomes /node_ns/foo) and remapping, by default. And then we want them all to have an option to skip both expansion and remapping.
I completly agree with this.
I think it should be done in rcl, repeating the code in rclcpp and rclpy doesn't make much sense.
Also, any functions that return topic or type names should be able to avoid de-mangling of those names.
Currently, the topic types are being demangled or not based on no_mangle argument.
Considering the use cases mentioned in the issue, I think that's fine.
We could have a better name, like use_ros_conventions, default to true:
truemeans both input and output are ros names.falsemeans both input and output are dds names (input shouldn't be expanded/remapped/mangled, output shouldn't be demangled).
This no_mangle option does not prevent the topic name expansion here, which is a problem in my opinion, what do you think @ivanpauno?
Yeah, as we talked, I think it's a problem.
We can left this as-is for now, and then correct all the places where we have this error together (publisher/subscription creation is applying remapping and expansion when ros_conventions qos is false , publisher/subscription count is not doing remapping, etc). I don't feel strongly about which path to take.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be done in rcl, repeating the code in rclcpp and rclpy doesn't make much sense.
In principle yes, but actually I think the sub-nodes feature in rclcpp prevent this for now. It needs to be more carefully considered I think. I would postpone that to another pull request.
Currently, the topic types are being demangled or not based on no_mangle argument.
Considering the use cases mentioned in the issue, I think that's fine.
We could have a better name, like use_ros_conventions, default to true: ...
I think having just one option can be ok, though it does make the odd cases impossible, because there's no way to manually do mangling/demangling.
If we want to go the route of having one option for both behaviors, then we need to change the no_mangle name, as it doesn't cover the existing behavior correctly, imo.
We can left this as-is for now, and then correct all the places where we have this error together (publisher/subscription creation is applying remapping and expansion when ros_conventions qos is false , publisher/subscription count is not doing remapping, etc). I don't feel strongly about which path to take.
I don't think the two points I highlighted (add remapping and avoid expansion/remapping when no_mangle is true) are very difficult so I'd prefer those to be done now. Everything else can be done in follow up.
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
Signed-off-by: Miaofei <[email protected]>
c911445 to
bc1b891
Compare
Signed-off-by: Miaofei <[email protected]>
|
CI run here. |
|
Hi @ivanpauno, any advice on how to fix the Windows CI failure in EDIT: Or is the recommendation to not have EDIT2: Oh, the error was actually only in |
|
@mm318 I've read a bit, and this seems to be a problem when a member variable of an exported class is template defined in another library:
Considering that we already have a test that compiles and access those member variables without problems, I would just ignore the warning with a pragma. I don't think that would be an issue. @wjwwood opinions? |
Signed-off-by: Miaofei <[email protected]>
|
In my opinion, this is ready for a CI re-run, @ivanpauno. |
wjwwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is probably for the best, though it is a lot of boilerplate (welcome to C++ :p).
|
I think that the boilerplate is fine, but the windows warning seems to be non-sense. Ignoring it with a pragma would be fine too. |
|
New CI round: ros2/rclpy#454 (comment) |
I'm not sure that's true, but we're not doing that so it's fine. |
|
Merged! Thanks @Barry-Xu-2018 and @mm318 for pushing this! |
Signed-off-by: Barry Xu [email protected]