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

[ROS 2] multiple publishers redeclare the same parameters #57

Open
brawner opened this issue Apr 27, 2020 · 3 comments
Open

[ROS 2] multiple publishers redeclare the same parameters #57

brawner opened this issue Apr 27, 2020 · 3 comments

Comments

@brawner
Copy link

brawner commented Apr 27, 2020

Strange issue that I only found with the CompressedPublisher, but it appears that its parameters are declared twice (or at least it does for me).

Compiling ros2, image_transport and image_transport_plugins from source, I just have an rclcpp node with an image_transport publisher (ubuntu bionic). Upon starting the node, the compressed_publisher library fails to load and throws an exception:

Failed to load plugin image_transport/compressed_pub, error string: parameter 'format' has already been declared

That also means that the reference that's set the first time around becomes invalidated when publish() is eventually called. I.e., I tried putting an if(node->has_parameter("format")) around the declare_parameter line and subscribing to the compressed topic results in the error:

Unknown compression type '', valid options are 'jpeg' and 'png'

Related to #52.
@lukaszmitka, @mjcarroll

@lukaszmitka
Copy link
Contributor

Could you provide more details, so that we can reproduce the issue?
Which ROS version are you using, is it Dashing or Eloquent?
What is the minimal code that causes the problem, could you provide essential .cpp and CMakeLists.txt?

@brawner
Copy link
Author

brawner commented Apr 28, 2020

ROS version: ros2 master

To reproduce the exception, you just need to create two publishers or reassign the first publisher (my case).

#include "rclcpp/rclcpp.hpp"
#include "image_transport/image_transport.h"

int main() {
  rclcpp::init(0, nullptr);
  auto node = rclcpp::Node("image_transporter");
  auto publisher1 = image_transport::create_publisher(&node, "topic1");
  // Throws in compressed_publisher
  auto publisher2 = image_transport::create_publisher(&node, "topic2");
  publisher1.shutdown();
  publisher2.shutdown();
  // Also throws
  auto publisher3 = image_transport::create_publisher(&node, "topic3");
}

Running this compiled binary will cause an exception to be thrown.

@brawner brawner changed the title [ROS 2] compressed publisher declares its parameters twice [ROS 2] multiple publishers redeclare the same parameters May 1, 2020
@lukaszmitka
Copy link
Contributor

The problem was the publisher declaring parameters in node scope instead of topic scope. The fix above makes publisher to declare set of parameters: format, jpeg_quality and png_level for each topic.

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