ros2 / ros2/rclcpp

expand_topic_or_service_name should use get_effective_namespace()

Open
#985 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

backlog enhancement help wanted
Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

Feature request

Feature description

sub_node concept is not being correctly used in some packages that use the function expand_topic_or_service_name(). They use it with get_namespace() to create publishers, instead of get_effective_namespace(). Probably many people do not know the existence of this method or the concept of subnode. For example, Here. If this node is a sub_node (created with create_sub_node(), then the effect of the subnode does not take effect. For:

    color_subnode_ = create_sub_node("rgb");
    image_transport::ImageTransport color_it(color_subnode_);
    pub_color_ = color_it.advertiseCamera("image", 1);

The effect is:

$ ros2 topic list
/camera_info
/image
/image/compressed
/image/compressedDepth
/image/theora

Instead of adding "/rgb" in front of each topic name.

Maybe expand_topic_or_service_name() should receive the rclcpp::Node, and internally, it could call get_effective_namespace().

I can work on it, but I would like to know if you think it's the right solution.

Implementation considerations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading expand_topic_or_service_name() and get_effective_namespace(), then compare their use in image_transport/src/camera_publisher.cpp. Determine the appropriate API change so a publisher created from a create_sub_node("rgb") context prefixes topic names with /rgb, and verify the affected callers preserve that namespace behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.