How to subscribe to multiple image topics using image_transport
Hi,
I would like to subscribe multiple images using image_transport. Here is my code snapshot:
std::vecotr<std::string> topics = {"topicA", "topicB"};
mage_transport::ImageTransport it_(nh);
std::vector<image_transport::Subscriber> subs_;
for(size_t i = 0; i < topics.size(); i++) {
subs_.push_back(it_->subscribe(topics[i], 1, &Process::ImageCallback, this));
}
When launching the node, I got the error: Tried to advertise a service that is already advertised in this node
Any suggestion is much appreciated. Thank you.
-----Update 20190604-------- This is a simplified code repo that reproduces the error: https://github.com/panda9095/example.
Are you sure this error is being caused by the code above? It seems to be referring to service servers, not subscribers.
Yes. If the size of topics is set to 1, everything works fine.
Can you give me a specific example of the topics you're subscribing to? I suspect that may help.
FYI, a github repo reproducing the error is updated. Thx. code