How to subscribe to multiple image topics using image_transport

asked 2019-06-03 05:14:39 -0600

lucas2009 gravatar image

updated 2019-06-03 21:40:52 -0600


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:

edit retag flag offensive close merge delete


Are you sure this error is being caused by the code above? It seems to be referring to service servers, not subscribers.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-06-03 12:01:49 -0600 )edit

Yes. If the size of topics is set to 1, everything works fine.

lucas2009 gravatar image lucas2009  ( 2019-06-03 12:13:41 -0600 )edit

Can you give me a specific example of the topics you're subscribing to? I suspect that may help.

stevemacenski gravatar image stevemacenski  ( 2019-06-03 16:19:31 -0600 )edit

FYI, a github repo reproducing the error is updated. Thx. code

lucas2009 gravatar image lucas2009  ( 2019-06-03 21:43:14 -0600 )edit