ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

roscpp clear topics node

asked 2020-04-23 09:24:22 -0600

wilson1994 gravatar image


I'm using image_transport to publish images, and depending on the format, it will publish it to different topics.

So to give a simplified example:

  • if format == grayscale, then I want to publish my images on /image/grayscale
  • if format == color, then I want to publish my images on /image/color

That works, but if I want to change format on the fly (eg from grayscale to color), I want to "unadvertise" the topic /image/grayscale" so it doesnt show up in the rostopic list anymore.

Is this in any way possible? I tried first deleting my image_transport object and nodehandle object, then creating new objects and advertise the new topic, but the old topic remains in the list of available topics.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-24 01:52:05 -0600

wilson1994 gravatar image

I found an answer to my question:

you have to destroy (or call shutdown on) your image_transport::Publisher objects to unadvertise that specific topic.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2020-04-23 09:24:22 -0600

Seen: 256 times

Last updated: Apr 23 '20