Node duplicated when 'name' specified in the .launch.py
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 155
- Forks
- 182
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
Issue report
Required Info:
- Operating System:
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal $ uname -a Linux 1_xterm 4.15.0-1009-aws #9-Ubuntu SMP Wed May 16 15:22:54 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux - Installation type, Version or commit hash:
$ apt-cache policy ros-foxy-launch Installed: 0.10.10-1focal.20230306.200955 Candidate: 0.10.10-1focal.20230306.200955 - DDS implementation:
- No idea how to find that. stackoverflow.com#49004420
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
t_launch.py (this causes the issue)
import os
import yaml
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
def generate_launch_description():
launchdemo = Node(
name="pick_place_sample2",
package="get_pose_client",
# executable="test_trajectory",
#executable="test_trajectory2",
executable="pick_place",
output="screen",
parameters=[],
)
nodes_to_start = [launchdemo]
return LaunchDescription(nodes_to_start)
#include <string>
#include "rclcpp/rclcpp.hpp"
class PickPlace : public rclcpp::Node {
public:
PickPlace(std::shared_ptr<rclcpp::Node> move_group_node)
: Node("pick_place") {} // end of constructor
}; // End of Class
int main(int argc, char **argv) {
rclcpp::init(argc, argv);
rclcpp::NodeOptions node_options;
node_options.automatically_declare_parameters_from_overrides(true);
auto move_group_node =
rclcpp::Node::make_shared("move_group_demo", node_options);
rclcpp::executors::SingleThreadedExecutor planner_executor;
std::shared_ptr<PickPlace> planner_node =
std::make_shared<PickPlace>(move_group_node);
planner_executor.add_node(planner_node);
planner_executor.spin();
rclcpp::shutdown();
return 0;
}
Expected behavior
[INFO] [pick_place-1]: process started with pid [25768]
:
(No error/warning from this node)
Actual behavior
Stdout
[INFO] [pick_place-1]: process started with pid [25768]
[pick_place-1] [WARN] [1681532371.573175635] [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.
$ ros2 node list
WARNING: Be aware that are nodes in the graph that share an exact name, this can have unintended side effects.
:
/pick_place_sample2
/pick_place_sample2
:
Additional information
Seems related answers.ros.org#344141.
Possible workaround
As mentioned answers.ros.org#344141, removing name in Node instance seems to stop the issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided t_launch.py with the shown C++ node and compare behavior with and without the Node name argument. Trace launch_ros.actions.Node and the process setup to determine why the named node appears twice; done means the launch produces one /pick_place_sample2 node without the rosout duplicate-name warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100