ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

I want to publish some data to a certain topic. And I do not want this topic to accept any other data from other nodes which tries to publish to it.

asked 2014-08-27 12:00:11 -0500

ebakor gravatar image

I wrote my problem with details below. But it may be a bit complicated. That is why, firstly, I am going to indicate it clearly. This is my question as I wrote on the title:

I want to publish some data to a certain topic. And I do not want this topic to accept any other data from other nodes which tries to publish to it. Or I want this topic to erase all the data coming from nodes except the node that I permit to publish to that node. How can I write this commend into my heartbeat node. How should the strategy be? (I am using Python). Any help would be appreciated

And my problem with details is this:

I am trying to write a heartbeat node for my robot. My robot has its own computer on it. I am going to publish heartbeat data from main computer to topic "A" which my heartbeat node subscribes to and which runs on the robot. Similarly I am going to control this robot from main computer by publishing to topic "B" and "C" that my engine node and brake motor node subscribes to. All these nodes (heartbeat, brake motor, engine) are going to run on the robot.

If heartbeat node realise that there is no data published to topic "A" (that is; connection between main computer and robot has failed), it is going to publish data to topic "B" and "C" in order to stop the engine and brake.

There is no problem about things above.

The problem is this:

When heartbeat node realises that connection is lost, I want it to clear all data flowing on the topic "B" and "C" to engine and brake motor nodes and than publish "stop" and "brake" data to them. I am trying to do this in case there is data on topic "B" and when my heartbeat tries to stop engine there should not be any data which tries to work the engine.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-27 12:25:59 -0500

ahendrix gravatar image

ROS is explicitly designed to be an anonymous publish and subscribe communications framework - this means that, by design, you shouldn't know where data on a particular topic is coming from.

I suggest you change your architecture to use a separate topic for your emergency stop command, or use a multiplexer to control which topic is sent to your engine control, and switch that mux based on your heartbeat status.

edit flag offensive delete link more


For how to implement a heartbeat I recommend that you look at the bond packages.

tfoote gravatar image tfoote  ( 2014-08-27 15:30:07 -0500 )edit

Thank you!..

ebakor gravatar image ebakor  ( 2014-08-28 06:26:54 -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


Asked: 2014-08-27 12:00:11 -0500

Seen: 303 times

Last updated: Aug 27 '14