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

Use of -r/--remap flags where appropriate. #159

Merged
merged 1 commit into from
Sep 3, 2019

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Aug 29, 2019

Precisely what the title says.

Connected to ros2/rcl#491.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

A comment out of the scope of this PR. LGTM!

@@ -53,7 +53,7 @@ TransformListener::TransformListener(tf2::BufferCore & buffer, bool spin_thread)
sstream << "transform_listener_impl_" << std::hex << reinterpret_cast<size_t>(this);
rclcpp::NodeOptions options;
// but specify its name in .arguments to override any __node passed on the command line
Copy link
Member

Choose a reason for hiding this comment

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

The change looks good, but I don't like the original motivation of this.

The node name uniqueness problem shouldn't be solved by generating a random name and overriding the command passed in the command line.
If someone wants to launch multiple TransformListener, they should carefully remap the node name.
I'm not sure if that's possible, because TransformListener isn't exactly a node. But in the case it's not possible, I think that problem should be solved instead of doing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I won't weigh into the correctness of the workaround, just to keep this scoped. I'll defer to @rotu and @gonzodepedro, author and reviewer of #129 respectively, for that.

@rotu
Copy link
Contributor

rotu commented Sep 2, 2019

@ivanpauno
The motivation of this is that the sub-node inherits the global node name override (e.g. by setting the node name argument on a launch_ros Node action), which causes it to match the parent node.

How would remapping solve the problem of TransformListener’s name colliding with its parent node’s name? How would it help a parent node with multiple TransformListeners?

Yes this is an ugly hack and I feel dirty for it. I welcome a better solution.

@rotu
Copy link
Contributor

rotu commented Sep 2, 2019

Here’s the offending launch code:
https://github.com/ros2/launch_ros/blob/cb911b9af331c0b17e2c3b0dec375fa95a190548/launch_ros/launch_ros/actions/node.py#L348

The __node argument needs to be more narrowly targeted to the actual primary node in a process and then this hack can go away.

@ivanpauno
Copy link
Member

@ivanpauno
The motivation of this is that the sub-node inherits the global node name override (e.g. by setting the node name argument on a launch_ros Node action), which causes it to match the parent node.

How would remapping solve the problem of TransformListener’s name colliding with its parent node’s name? How would it help a parent node with multiple TransformListeners?

Yes this is an ugly hack and I feel dirty for it. I welcome a better solution.

Ok, now I understand the problem better.
Remapping rules can be targeted to specific nodes, see https://index.ros.org/doc/ros2/Tutorials/Node-arguments/#passing-remapping-arguments-to-specific-nodes.
launch_ros.action.Node doesn't do the task very well. At some point we should support a MultiNodeExecutable action in launch_ros, see ros2/launch#114.

For the moment, it can be worked around in the launch file using arguments parameter in the constructor of ExecuteProcess or Node. I don't like much the idea of using a random name.

@rotu
Copy link
Contributor

rotu commented Sep 3, 2019

Remapping rules can be targeted to specific nodes, see https://index.ros.org/doc/ros2/Tutorials/Node-arguments/#passing-remapping-arguments-to-specific-nodes.

Yes, but ideally the node of a TransformListener should be an implementation detail that the caller doesn't need to worry about. If the parent node has to both create a TransformListener object and reach inside to rename its nodes apart, that is terrible OOP design. Ideally, there should be no need for a subnode, or there should be no requirement for node name uniqueness, or you should be able to pass a flag to rclcpp that says "I don't care about the name of this node - make it unique for me".

For the moment, it can be worked around in the launch file using arguments parameter in the constructor of ExecuteProcess or Node. I don't like much the idea of using a random name.

Randomized names seem the lesser evil compared to moving the names of TransformListeners' subnodes to a launch file and manually giving them unique names - a detail that should be completely handled by the node itself.

@hidmic
Copy link
Contributor Author

hidmic commented Sep 3, 2019

@rotu @ivanpauno I'd think this deserves a separate issue. I see valid arguments on both sides, and this is a completely unrelated PR that will hopefully soon be merged.

@hidmic hidmic merged commit a59b754 into ros2 Sep 3, 2019
@delete-merged-branch delete-merged-branch bot deleted the hidmic/use-cli-remap-flags branch September 3, 2019 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants