-
Notifications
You must be signed in to change notification settings - Fork 163
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
Dynamically remap topic names #1072
Comments
IMO this is good feature so that user can reconnect the topic to the different resource at runtime. |
We do have a small section about dynamic remapping in the design document at http://design.ros2.org/articles/static_remapping.html#static-versus-dynamic-remapping . I can't exactly remember now, but I think at the time we didn't implement it to keep the scope small. @sloretz maybe you can comment here? Regardless, I do think it is a fine feature to have. If we are going to do it, I'd much prefer to have it at the I'm not totally convinced that we want to expose a service to allow this remapping to happen. A service is just one way that a user might want to make this change, and services are expensive in terms of discovery. I could imagine a user changing this via a parameter, a service, a topic, or even in reaction to an external event. So my suggestion here is to start off just by defining the API, and worrying about a service or something like that as a totally separate step. |
Currently, remapping is established either through global arguments (from argc/argv) or through local arguments (node options) and takes value when creating the resource. In Let's center on publishers in this conversation but take into account other resources. One approach could be as follows: The interface to create a publisher could be very similar to
In this function, to avoid changes in rmw, we could replace the current one by one with the remapped name:
What do you think? Something that worries me is what happens with a subscriber who has received messages that still need to be processed or a client who is waiting for a response. If we destroy the subscriber or the client, messages and responses may be lost. Add a dynamic remap to the nodeTo extend
Many functions that takes A good aspect is that it opens the option of having more dynamic arguments, beyond remapping resources. |
@fmrico thanks for sharing idea.
just checking, so once the topic is remapped, the existing publisher will no longer exist? that will be replaced with new topic name? right?
if we want it to be processed or continue, this feature user application should be able to know that there is no publishers anymore since it is remapped?
totally agree, currently node has each dedicated service or parameter to manage the specific configuration or options. |
Just as a FYI: Someone asked for this functionality on the Robotics stack exchange.
I proposed as a solution to install a auto post_set_parameter_callback =
[this](const std::vector<rclcpp::Parameter> & parameters) {
for (const auto & param : parameters) {
if (param.get_name() == "topic_name") {
std::string new_topic = this->get_parameter("topic_name").as_string();
// Delete current subscriber
// Create new subscriber
}
}
}
post_set_parameters_callback_handle_ = this->add_post_set_parameters_callback(post_set_parameter_callback); I did not test this, but I assume it works. |
This issue is probably relevant as well: |
it should work but i would use |
I was rather thinking about the use case where you'd remap either the publisher, or the subscriber, but not both. E.g. robot moves from 'warehouse_1' to 'warehouse_2' and hence needs to remap its listeners to the publishers of 'warehouse_2' instead of those of 'warehouse_1'. But indeed, |
Feature request
Dynamically remap topic names.
Feature description
Currently, topic remapping can only be done when a node is started, and, as far as I understand, it takes effect when the publishers/subscribers are created. Later, it is not possible to change the topic name.
Remapping topics once the publisher/subscriber is created would be useful. It would even be interesting if each node had a service to do this so that there could be requests for external remapping.
This functionality makes it possible to analyze a running computing graph and fix disconnections between topics without stopping and restarting the nodes with new remappings.
I am interested in working on this, but I need guidance.
Implementation considerations
Doing this at the client library level (rclcpp, for example) could be relatively simple, but in rcl it would be more general.
A service interface should be created in rcl_interfaces.
The text was updated successfully, but these errors were encountered: