Ask Your Question

overriding PublisherImpl for filtering outpout messages

asked 2015-05-12 04:59:08 -0500

CharlesOnera gravatar image

Hi guys,

I am preparing some multi-robot experiments and I would like to simulate some communication loss between robots. I have one ROS node on each robot supervising the mission execution. These nodes publish some information about their own execution status to all other robots to maintain a correct execution.

The point is that I would like to filter the published messages to simulate that e.g., robot 1 can communicate with robot 2 but not with robot 3: the published message should then be sent to r2 but not to r3.

Looking at the Publisher implementation (python version), I think this is possible to implement by redefining the publish method at rospy.topics._PublisherImpl.publish and filtering correctly the set of 'connections' of the publisher to send only to the relevant subscribers.

That's where I need help: I don't see any easy way to say to the publisher that I would like to use my new ComSimulationPublisherImpl(_PublisherImpl) implementation instead of the original _PublisherImpl class... Is there an easy way to do so without having to reimplement all the rospy.topics package?



edit retag flag offensive close merge delete


I thought that implementing at the publisher level would scale better than having a specific relay node and could be done much more generic as the relay node would not have to know about all the nodes I have on my system. If you think you have a well-suited design, could you give more details please

CharlesOnera gravatar image CharlesOnera  ( 2015-05-12 07:19:07 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-05-12 05:28:46 -0500

Wolf gravatar image

Maybe different design: not override the publisher but let all publish and subscribe on different topics and set up a muxer/republisher node in the middle that only republishes those topics you want; thereby selectively connects the nodes?

edit flag offensive delete link more

answered 2015-05-12 06:02:43 -0500

dornhege gravatar image

Does this need to be on a node/publisher level?

It is probably way easier to implement a relay node, which just republishes the filtered messages if there are not too many different messages involved.

edit flag offensive delete link more

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: 2015-05-12 04:59:08 -0500

Seen: 48 times

Last updated: May 12 '15