ros-tooling/topic_tools

transform is broken with relative topics in namespaces

bmartin427 opened this issue · 6 comments

Description

The transform tool fails to properly resolve the names of topics specified as relative to a non-root namespace.

Expected Behavior

Tool runs, subscribes to /my_namespace/chatter and emits /my_namespace/xformed.

Actual Behavior

Tool stalls with:

WARNING: topic [/my_namespacechatter] does not appear to be published yet

To Reproduce

  1. ros2 run demo_nodes_cpp talker --ros-args -r __ns:=/my_namespace
  2. ros2 run topic_tools transform chatter xformed std_msgs/String "std_msgs.msg.String(data=m.data[-1])" --import std_msgs --wait-for-start --ros-args -r __ns:=/my_namespace

System (please complete the following information)

  • OS: Ubuntu Jammy
  • ROS 2 Distro: Iron

Additional context

Update: it seems that relay_field also has this same problem.

Does it work if you do ros2 run topic_tools transform /chatter #... instead?

It works if I use /my_namespace/chatter as the input topic, or /chatter works if I move the talker out of the namespace, yes.

Thanks for confirming. We're using rclcpp::GenericSubscription for all topic_tools nodes instead of the usual rclcpp::Subscription, so there might be an issue there.

It looks to me like these lines won't work correctly if the namespace doesn't end in '/':
https://github.com/ros-tooling/topic_tools/blob/iron/topic_tools/topic_tools/transform.py#L75-L77

Appending '/' to the __ns:= remapping causes other unrelated explosions though.

Oops sorry, I completely missed that transform is one of the Python nodes.

I thought that topic name resolution was something that's usually left to the client library implementation.