Repository navigation
Description
Bug report
Required Info:
-
Operating System:
- Ubuntu 18.04
-
Installation type:
- source
-
Version or commit hash:
- c6788e4
master latest after "Publish logs to Rosout (Publish logs to Rosout #350)"
- c6788e4
-
DDS implementation:
- Default - FastRTPS
-
Client library (if applicable):
- rclcpp
Steps to reproduce issue
Install navigation2
ros2 launch nav2_bringup nav2_bringup_1st_launch.py map:=<path/to/map>
Expected behavior
Should launch fine without issue.
Actual behavior
Exception occurs, and crashes amcl node:
ros2 launch nav2_bringup nav2_bringup_1st_launch.py map:=/home/mkhansen/ros2_dev/navigation2_ws/src/navigation2/nav2_system_tests/maps/map_circular.yaml
[INFO] [launch]: process[amcl-1]: started with pid [14806]
[INFO] [amcl]: Initializing AMCL
[INFO] [amcl]: Sensor model type is: "likelihood_field"
[INFO] [amcl]: Robot motion model is differential
terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
what(): failed to initialize rcl node: Logger already initialized for node., at /home/mkhansen/ros2_dev/ros2_ws/src/ros2/rcl/rcl/src/rcl/logging_rosout.c:156
[ERROR] [launch]: process[amcl-1] process has died [pid 14806, exit code -6, cmd '/home/mkhansen/ros2_dev/navigation2_ws/install/nav2_amcl/lib/nav2_amcl/amcl __node:=amcl'].
Additional information
SO, the launch file by default has this for the amcl portion:
launch_ros.actions.Node(
package='nav2_amcl',
node_executable='amcl',
node_name='amcl',
output='screen'),
parameters=[{ 'use_sim_time': use_sim_time}]),
When I comment out these 2 lines, setting the node_name and parameters, it works fine, but use_sim_time isn't set (which is needed).
launch_ros.actions.Node(
package='nav2_amcl',
node_executable='amcl',
# node_name='amcl',
output='screen'),
# parameters=[{ 'use_sim_time': use_sim_time}]),
I suspect the issue has something to do with the node_name field, but I don't know exactly what the issue is because I use nearly the same syntax for map_server in the same launch file and it works fine:
launch_ros.actions.Node(
package='nav2_map_server',
node_executable='map_server',
node_name='map_server',
output='screen',
parameters=[{ 'use_sim_time': use_sim_time}, { 'yaml_filename': map_yaml_file }]),
The only difference there being the use of a yaml file for a second parameter in the list.
This only recently stopped working (last week), and it coincided with #350, and the message was added in that PR, so it has to be related. I'm just not sure what the PR added and why having the node name and parameters makes it fail. I see the failure occurs here:
logging_rosout.c:156
Please help to understand why I'm hitting this error.
Activity
mkhansenbot commentedon Jan 23, 2019
Adding @crdelsey
sloretz commentedon Jan 23, 2019
@mkhansen-intel does the error happen with a different node name like
amclfooorfooamcl?mkhansenbot commentedon Jan 23, 2019
Good idea, but I just tried it and it didn't make a difference except in the logger output on the screen:
mkhansenbot commentedon Jan 24, 2019
OK here's more info.
I isolated the failure down to this line in amcl:
tfl_.reset(new tf2_ros::TransformListener(*tf_));The gdb backtrace of the error is this:
Line 19 is where it calls into the TransformListener constructor. I still don't understand why that is causing an exception to be thrown. Is the bug in TransformListener? Maybe I should have filed the bug in Geometry2 instead?
Let me know how I should proceed.
sloretz commentedon Jan 24, 2019
@crdelsey In that example the nodes can be given different names by prefixing the rule with original name
./loggerfailure foo:__node:=abc bar:__node:=cbamkhansenbot commentedon Jan 24, 2019
Why does the logger now need to throw that exception? What harm is it causing to have two nodes with the same logger? If the only downside is that they both will log using the same name and therefore you won't know what output was from which node, then it seems like a warning "Duplicate logger for node abc" is all that is needed. Am I missing something?
sloretz commentedon Jan 24, 2019
I agree two nodes sharing a logger would be fine as a warning. Elsewhere, nodes with the same name create parameter services with the same name. This makes setting different parameters on them a problem.
mkhansenbot commentedon Jan 28, 2019
So @crdelsey has a work-around for this which we can live with. I still think this exception should be a warning instead. Please let me know whether that change will be made so we can revert the work-around at a future date.
sloretz commentedon Jan 28, 2019
I can reproduce this exception with
but not with
I don't yet know why this is the case.
sloretz commentedon Jan 28, 2019
tfl_.reset(new tf2_ros::TransformListener(*tf_));throws because this constructor creates a hidden node. Both change their names according to the__node.Another way to work around the issue is to use another
__noderule to tell the transform listener to keep it's name.But I assume in this case
amclwould rather reuse the same node with the transform listener rather than create a new one.sloretz commentedon Jan 28, 2019
__node:=is causing trouble when code creates other nodes in the background. For example,TransformListenercreates a node, and this code in navigation2 creates a node. Launch doesn't know there are multiple nodes in the process so it has no way of knowing it should use a__nodename rule with a node name prefix (amcl:__node:=amcl).Here are a few options. @ros2/team mind looking at the options and giving feedback?
rosoutwhen the node which created the publisher is shut downrcl_logging_rosout_init_publisher_for_nodeWarns that a node with the same name existsrcl_node_initwarns and then continues creating a node if the logger returnsRCL_RET_ALREADY_INITrcl_logging_rosout_fini_publisher_for_nodeonly fini's publisher if the passed innodematchesentry.node__noderenaming multiple nodes again, resulting in this crashuse_global_arguments = falseuse_global_argumentsanonymousflag to nodes that causes it to create a unique name and ignore__noderules.__nodeconsumable, first node to launch takes the rule for itself__ns,__log_level__parameters, etc__nodewith a node name prefixold_name:__node:=new_namehidmic commentedon Jan 29, 2019
@sloretz so, given that those hidden nodes seem to work only as proxies/wrappers to ROS interfaces, I'd say (5) is a reasonable path forward, though a less obscure exception would be nice i.e. letting you know there're other non-anonymous nodes in the process and thus you can't just use
__node:=...w/o a prefix. Just my 2 cents.BTW what would happen if e.g. two
TransformListenerare instantiated? Would that result in name clashing as well, even if no__noderemapping is being used?sloretz commentedon Jan 29, 2019
Yup, two TransformListener alone crashes since they create nodes with the same name
jacobperron commentedon Jan 29, 2019
I agree that (5) seems like the right thing to do (and then do the TODO to resolve this particular ticket).
I may have been under the wrong assumption, but I thought fully qualified node names should be unique. If so, then I believe an error (rather than a warning) is correct in the reported case.
Karsten1987 commentedon Feb 6, 2019
So we currently run into this issue as well on rosbag2.
https://ci.ros2.org/job/ci_linux/6127/testReport/junit/(root)/projectroot/test_record/
in contrast to this issue here, i believe we don't spawn multiple nodes with the same time simultaneously but sequentially in the same process.I actually found that we do have nodes with the same node name. So I can second that this is the cause for this problem.
nburek commentedon Feb 6, 2019
A little background, for the rosout logging functionality in ROS2 we create a publisher instance on every node and the logger that is associated with that node sends logs out on the rosout topic publisher specifically for that node. We did it this way to avoid randomly picking a single node in the process and sending all logs out via a publisher on that node. Additionally, the only thing linking a node logger in rclcpp/rclpy to the logger in the rcl layer is a string name that is set to the node's name. This is why we maintain the hashmap so that we can map log messages on a node logger to the publisher for that node.
It was also my understanding at the time that while nothing explicitly prevented two nodes with the same name it wasn't recommended.
In light of all that, I added the exception that explicitly prevents a second node with the same name registering a logger because it then becomes unclear what the behavior of the system becomes. There isn't a way to map log messages coming from the OOP node loggers to the correct node publisher instance given only the node name. Additionally, as @sloretz points out, if we just warn and reuse the same logger for both node instances then when the node with the publisher gets destroyed it would stop the other instance from publishing to rosout. Additionally, I didn't feel it was the right choice that any node could secretly impact traffic going over another node instance's publishers under the hood.
All these things could be fixed by adding slightly more complexity in the logger or accepting some of the pitfalls of the workarounds, but I'd like to know what the long term story is for supporting multiple nodes with the same name inside the same process before committing to a solution.
nburek commentedon Feb 7, 2019
Fix to make this a warning message for now #384, as discussed here: #350
jacobperron commentedon Feb 20, 2019
@mkhansen-intel I believe this issue has been resolved by #384. If not, you can comment here and I can reopen the issue,