Ask Your Question
0

How can I identify processes ROS nodelets are running in?

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

thinwybk gravatar image

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

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
1269
1326
1555
1559
1563
1592
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

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

gvdhoorn gravatar image

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

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

Comments

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

thinwybk gravatar imagethinwybk ( 2017-09-30 06:23:38 -0600 )edit

Question answered ? :)

gvdhoorn gravatar imagegvdhoorn ( 2018-02-09 05:32:24 -0600 )edit

Yepp... :)

thinwybk gravatar imagethinwybk ( 2018-02-09 05:46:39 -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

2 followers

Stats

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

Seen: 572 times

Last updated: Sep 30 '17