Ask Your Question
0

Publish MarkerArray in an already existing Marker Topic

asked 2021-03-28 10:30:33 -0500

UndefinedDuck gravatar image

Hi guys, I have a node that publishes a MarkerArray Topic:

ros::Publisher obst_pub = nh.advertise<visualization_msgs::MarkerArray>("/obstacles_markers", 1);

which contains my obstacles. Then I have another node that calculates the width of obstacles through the laser scanner and put it in a MarkerArray as well.

Now the problem is that I want to publish this new MarkerArray into the other existing topic "obstacles_markers", is that possible?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-03-28 12:25:25 -0500

gvdhoorn gravatar image

Now the problem is that I want to publish this new MarkerArray into the other existing topic "obstacles_markers"

that's not really a problem.

is that possible?

yes, of course.

Publish-subscribe is a many-to-many interaction pattern/style.

Subscribers do not know who published a message, nor do publishers know who subscribers are.

In fact, publishers do not know anything about subscribers (nor the other way around).

So it's perfectly possible to publish to the same topic from different nodes.

edit flag offensive delete link more

Comments

Perhaps you've always thought about topics as being channels to which only sender and receiver are connected, each on one end (ie: the beginning and the end). But that's not how topics works (or: you're not restricted to such a topology).

gvdhoorn gravatar image gvdhoorn  ( 2021-03-28 12:26:53 -0500 )edit

So I can define a topic in the other node with the same name of the first one and publish on it without having conflicts?

UndefinedDuck gravatar image UndefinedDuck  ( 2021-03-28 12:44:31 -0500 )edit

Isn't that what I wrote in my answer?

As long as the types are exactly the same, you can publish with as many publishers on a the same topic as you'd like.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-28 14:47:43 -0500 )edit

Ok got it, I'm a totally beginner so thank you

UndefinedDuck gravatar image UndefinedDuck  ( 2021-03-28 15:20:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-03-28 10:30:33 -0500

Seen: 55 times

Last updated: Mar 28 '21