ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ros2 launch creates two nodes of same type

asked 2020-02-14 06:11:18 -0500

potentialdiffer gravatar image

Hi, I am experiencing a weird behavior of the ros2 launch command.

Using following example launch file from the robot_localization packge:

from launch import LaunchDescription
from ament_index_python.packages import get_package_share_directory
import launch_ros.actions
import os
import yaml
from launch.substitutions import EnvironmentVariable
import pathlib
import launch.actions
from launch.actions import DeclareLaunchArgument

def generate_launch_description():
    return LaunchDescription([
            parameters=[os.path.join(get_package_share_directory("robot_localization"), 'params', 'ekf.yaml')],

creates following output:

$ ros2 launch robot_localization 
[INFO] [launch]: All log files can be found below /home/xxx/.ros/log/2020-02-14-12-59-00-118313-xxx-22388
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ekf_node-1]: process started with pid [22398]
[ekf_node-1] [WARN] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[ekf_node-1] X acceleration is being measured from IMU; X velocity control input is disabled

Listing running nodes with ros2 node list also shows me two ekf_nodes.

The same happens with ros2 cartographer_ros node.

Any Idea why this is happening? I am able to launch other nodes without any problem.

edit retag flag offensive close merge delete



I have similar issue.

kk2105 gravatar image kk2105  ( 2020-03-19 01:53:38 -0500 )edit

I am experiencing the same issue using Dashing version. Any updates on how to fix it and what version do you use of robot_localization?

DanielRobotics gravatar image DanielRobotics  ( 2020-04-11 07:40:11 -0500 )edit

Can you check if the same node is already running ?
In my case, the launch was happening due to a script which launches ros node automatically after building the code. So when I manually launch the node, it does not run.
After making some modifications to the script, now I am able to run the node manually.

kk2105 gravatar image kk2105  ( 2020-04-12 21:35:27 -0500 )edit

I just checked and the node is not already running before I run my launch file. Can you show the script where you made the modifications to get it running?

DanielRobotics gravatar image DanielRobotics  ( 2020-04-13 03:19:22 -0500 )edit

Did you all figure this out? I don't use ROS2, so I don't have a lot to say here, but I'm wondering if this has been solved.

Tom Moore gravatar image Tom Moore  ( 2020-04-20 03:14:48 -0500 )edit

Hi, sorry for the late reply. I did not solve this issue. However, I also haven't digged in deeper yet, as I am currently trying out different things in ros.

In reply to @kk2105: I did not use any other script to launch the node. I also checked that there are no nodes running at launch.

potentialdiffer gravatar image potentialdiffer  ( 2020-04-20 03:24:47 -0500 )edit

@DanielRobotics Apologies for the delay in response. Unfortunately I will not be able to share the script. However that is just a simple script which launches the node by running ros2 launch

kk2105 gravatar image kk2105  ( 2020-04-20 03:49:50 -0500 )edit

@DanielRobotics@Tom Moore Even I did not dig deeper in finding the root cause. However in ROS2 I believe, there is no separate command which actually kills the running node. So if the same node runs in same system, it overrides the already running one. Is this right @gvdhoorn ?

kk2105 gravatar image kk2105  ( 2020-04-20 03:54:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-30 01:54:06 -0500

ddengster gravatar image

Removing the line that names the node fixed it for me, ie. this line:

edit flag offensive delete link more


Thanks! It also fixes it for me.

DanielRobotics gravatar image DanielRobotics  ( 2020-04-30 02:41:00 -0500 )edit

Though it fixed the problem with the two nodes it seems to cause another error for me. When I remove the naming lines I get a datum error and I receive no information on my /odometry/filtered and /odometry/gps. If I move the naming lines back in I get the duplicate nodes but the datum error is not coming and data is again coming on my /odometry/filtered and /odometry/gps. @Tom Moore do you know why this is happening?

[navsat_transform_node-4] [INFO] [navsat_transform]: Datum (latitude, longitude, altitude) is (-1246152232, -1246031536, -518309968) 
[navsat_transform_node-4] [INFO] [navsat_transform]: Datum UTM coordinate is (-124615232, -1246031536)
DanielRobotics gravatar image DanielRobotics  ( 2020-05-06 04:45:08 -0500 )edit

Check that node naming change did not break your parameter YAML files.

hidmic gravatar image hidmic  ( 2020-05-07 08:59:44 -0500 )edit

Any idea why adding the node name parameter causes this error?

nnmm gravatar image nnmm  ( 2020-11-24 10:07:52 -0500 )edit

Thanks for pointing out this solution, I solved the same problem. But if I remove the node name, why doesn't the node become duplicate? We would appreciate it if you could tell us why.

HyeonJuChoi gravatar image HyeonJuChoi  ( 2022-07-05 01:42:09 -0500 )edit

Mb it's about too late, but anyway. I believe inside your "node" you have two or more nodes with different names of course. When you set name attr in launch it tells ros2 to force renaming of inside node. That way all nodes you create inside one app will be rename with the single name, that you set in launch

DrShiki gravatar image DrShiki  ( 2023-07-21 03:23:09 -0500 )edit

Question Tools



Asked: 2020-02-14 06:11:18 -0500

Seen: 2,391 times

Last updated: Feb 14 '20