Ask Your Question

ROS2 Resolve topic names rclcpp

asked 2021-02-12 09:44:17 -0500

vinny gravatar image

updated 2021-02-17 11:31:28 -0500

In ros1 cpp I was able to resolve a string containing the topic name to the actual topic name that accounts for remappings using the following block:

  // Determine topic name (including remapping)
  std::string mag_topic_name = "/imu/mag";
  mag_topic_name = ros::names::resolve(mag_topic_name);

Is there a similar way I can do this in rclcpp ROS2? I tried digging through the documentations, but could not find something.

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-11-21 21:12:27 -0500

KenYN gravatar image

I've been looking for this today, and there is a function in Galactic Rolling:

RCLCPP_PUBLIC std::string resolve_topic_name(const std::string & name, bool only_expand = false) const override;

See this pull request. I've copied the code over to my own node.

The only_expand parameter, if true, just adds on the namespace. If false, it also applies remapping, which is probably the option you want.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-02-12 09:44:17 -0500

Seen: 170 times

Last updated: Nov 21 '21