Skip to content

count_subscribers / count_publishers do not respect remapping #1174

@mikeferguson

Description

@mikeferguson

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04, Foxy
  • Installation type:
    • From debians
  • Version or commit hash:
    • rclcpp 2.0.0
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

I created a full test node here: https://github.com/mikeferguson/ros2_bugs/blob/master/rclcpp_issues/src/count_subscriber_issue.cpp

If you run the node without remapping:

ros2 run rclcpp_issues count_subscriber_issue 

and then echo it:

$ros2 topic echo test
linear:
  x: 42.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.0
---

You get the expected output:

$ros2 run rclcpp_issues count_subscriber_issue
[INFO] [1591928821.734257323] [count_subscriber_issue]: Num of subscribers: 0
[INFO] [1591928822.734171864] [count_subscriber_issue]: Num of subscribers: 0
[INFO] [1591928831.734110847] [count_subscriber_issue]: Num of subscribers: 1
[INFO] [1591928832.734076414] [count_subscriber_issue]: Num of subscribers: 1
[INFO] [1591928833.734027599] [count_subscriber_issue]: Num of subscribers: 1

However, if you remap and then echo the "remapped_test" topic:

ros2 run rclcpp_issues count_subscriber_issue --ros-args -r test:=remapped_test

The subscriber will still subscribe properly and echo the data, but the num of subscribers remains 0 forever.

Expected behavior

I would expect that the count would still be 1 even when remapped. In theory you'd want to define a string that is your "default topic name" and use that same string for create_publisher and count_subscribers and remapping would happen seamlessly under the hood.

Actual behavior

Things don't work with remapping.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions