-
Notifications
You must be signed in to change notification settings - Fork 120
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
Comments
Could you provide more details, so that we can reproduce the issue? |
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. |
The problem was the publisher declaring parameters in node scope instead of topic scope. The fix above makes publisher to declare set of parameters: |
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:
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 anif(node->has_parameter("format"))
around the declare_parameter line and subscribing to the compressed topic results in the error:Related to #52.
@lukaszmitka, @mjcarroll
The text was updated successfully, but these errors were encountered: