Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't remap topic name and set hint at the same time; #237

Open
bbferka opened this issue Mar 17, 2022 · 1 comment
Open

Can't remap topic name and set hint at the same time; #237

bbferka opened this issue Mar 17, 2022 · 1 comment

Comments

@bbferka
Copy link

bbferka commented Mar 17, 2022

OS: Ubuntu 20.04
ROS: Galactic
Verions: 2.3.0-3 installed from Debian

I am trying to create a generic ROS2 node that subscribes to an image topic of a user's choice (through remapping of a topic name) and a user can in addition set the transport hint. Pretty straight forward, this is how image_saver from the image_view package used to work on ROS1

node->declare_parameter("transport", "raw");
std::string transport = node->get_parameter("transport").get_value<std::string>();     
image_sub_ = image_transport::create_subscription(
            &(*node), "image", std::bind(&MyClass::imageCallback, this, std::placeholders::_1), transport);

I run my node with ros2 run my_package my_node --ros-args -r image:=/my_image_topic/image_raw -p transport:=compressed but the output of ros2 node info my_node shows:

/my_node
  Subscribers:
    /image/compressed: sensor_msgs/msg/CompressedImage

If I don't set the parameter from the command line the remapping of the topic name works and I get:

/my_node
  Subscribers:
    /my_image_topic/image_raw: sensor_msgs/msg/Image

I have also tried doing this using TransportHints and creating the subscriber with it_.subscribe("image", 10, &MyClass::imageCallback, this, &hints); , and the overwriting the image_transport parameter; The first problem here is that this parameter from TransportHints is never declared, so I had to declare it from my node in order to overwrite it; But then the behavior is still the same; We can either remap the topic name or change the hint but not both at the same time;

I also tried this out with the image_saver node from image_view package on ROS2 and could not get that one to run either;

I suspect that this might be a bug somewhere in the code when resolving names of topics and parameters; My current workaround is to set both the topic name and the hint from parameters;

@gbiggs
Copy link
Contributor

gbiggs commented May 5, 2022

Please ask this question on ROS Answers. Be sure to provide your complete code and the complete steps that you followed so that others can try to reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants