Ask Your Question
1

Is there a way to determine IP address of publisher for each message

asked 2017-11-21 04:22:04 -0600

Creed gravatar image

Hello,

I'm currently developing small system for monitoring and management of a mobile robot group in ROS. One of system's features is reservation mechanism, which lets students reserve exclusive access to the robot - reserved robot only reacts to commands coming from that computer. I want to base it on IP addresses of computers in laboratory.

Here comes my question: Is there a (ROS-based) way to determine IP address of publisher for each message coming to the robots from computers in the laboratory?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2017-11-21 07:22:56 -0600

updated 2017-11-21 11:51:48 -0600

Hi,

Maybe I found a solution, not the pretiest, not the easiest, but it may work (but it's cpp only) :

  1. You can find the IP of a ROS node by contacting the master (rosnode info my_node will return the ip of the node, with many other information)

  2. According to The connection header documentation, the node currently sending data can be found in the connection header.

  3. You can use Message event to get the connection header.

  4. To manipulate Message event, you can check Passthrough Filter, just adapt the code to not let the message go through unless the IP is OK. Also check the message filter documentation.

The 3. and 4. are optional, if you can manage to get the connection header by an another way, or the message event by an another way.

It may be easier in Python but i'm not experimented enough in python to help.


Edit from Creed comment :

In CPP, use the cpp publisher tutorial / 2.4 MessageEvent to get message event.

for python check Creed's comment below

edit flag offensive delete link more

Comments

2

Thank you for directing me to the solution.

So finally I came up with this (based on simple publisher/subscriber tutorial):

def callback(data):
    callerid = data._connection_header['callerid']
    master = rosgraph.Master('listener')
    ip = master.lookupNode(callerid)
    print(ip)
Creed gravatar imageCreed ( 2017-11-21 11:34:02 -0600 )edit

Nice, it's indeed easier in python, thanks for the python code :)

lmathieu gravatar imagelmathieu ( 2017-11-21 11:53:39 -0600 )edit
0

answered 2017-11-21 05:13:29 -0600

IvanV gravatar image

I don't think that feature comes out of the box in ROS. You can always use custom messages or encapsulated messages with an "ip" or "source" field on them to identify the sender.

edit flag offensive delete link more

Comments

Use of custom messages is something what came to my mind, but i would like to avoid it, because it forces me to modify already existing code used to steer the robots.

Creed gravatar imageCreed ( 2017-11-21 05:26:32 -0600 )edit

As far as i know, roscore collects ip at least at the moment of first message coming on given topic. So i was wondering if that info is somehow available to gather on low level of ROS (maybe in ros_comm stack?)

Creed gravatar imageCreed ( 2017-11-21 05:28:02 -0600 )edit

You don't actually need to modify current steering node. You can just put a "filtering node" in the middle that reads custom topics and publishes back to steering node only the relevant/de-capsulated ones.

IvanV gravatar imageIvanV ( 2017-11-21 05:34:41 -0600 )edit

On the robot-side it may be good idea for workaround, but still i would have to modify Python wrapper for existing RosAria library, which in fact ends up in rewriting (of course only partially) almost whole code.

Creed gravatar imageCreed ( 2017-11-21 05:57:02 -0600 )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

Stats

Asked: 2017-11-21 04:22:04 -0600

Seen: 757 times

Last updated: Nov 21 '17