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

How can I identify processes ROS nodelets are running in?

asked 2017-09-28 11:40:52 -0500

thinwybk gravatar image

updated 2017-09-29 11:12:12 -0500

Is there a way to get the process ID of the process a ROS nodelet is running in (preferably by ROS nodelet name)? This question relates to this quiestion about how to get the process id of a ROS node.

With pgrep one can get a list of pids of nodelets if they are running in separate processes but cannot determine which pid corresponds to which nodelet:

pgrep nodelet
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-09-30 05:04:12 -0500

gvdhoorn gravatar image

updated 2017-09-30 06:02:49 -0500

I think you can do this by using the Master API to retrieve the list of service servers (using getSystemState(..)) and then filtering that list by looking for all providers of any of the typical Nodelet manager services (docs).

After you have that list, you could use the same approach as in #q271776 to get their PIDs.

To figure out which nodelets are running in which specific managers, you should be able to just ask the node by invoking the list service and looking at the result.

As in #q271776, the rosgraph, rosnode and rosservice libraries can help, but most of it is XMLRPC, so could be done without any ROS dependency. Invoking the service might be harder without any ROS, but not undoable.

Edit: perhaps the lookupService(..) could also be used, but I'm not sure whether the documentation for that is correct:

Lookup all provider of a particular service.

this suggests that all provider(s) will be returned, but the return type docs say this:

(code, statusMessage, serviceUrl)

service URL is provides address and port of the service. Fails if there is no provider.

So that implies only a single serviceUrl will be returned.

Edit: rosservice find <service-type> does something similar, so you could probably take a look at that.

edit flag offensive delete link more


Thanks a lot. I will try to get a ROS dependent implementation running and refactor to an implementation without ROS dependency later.

thinwybk gravatar image thinwybk  ( 2017-09-30 06:23:38 -0500 )edit

Question answered ? :)

gvdhoorn gravatar image gvdhoorn  ( 2018-02-09 05:32:24 -0500 )edit

Yepp... :)

thinwybk gravatar image thinwybk  ( 2018-02-09 05:46:39 -0500 )edit

Question Tools



Asked: 2017-09-28 11:40:52 -0500

Seen: 3,285 times

Last updated: Sep 30 '17