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

Publish MarkerArray in an already existing Marker Topic

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

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 -0600

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 -0600 )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 -0600 )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 -0600 )edit

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

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

Question Tools

1 follower

Stats

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

Seen: 175 times

Last updated: Mar 28 '21