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

using the rosnode python API for introspection

asked 2011-09-28 23:07:17 -0500

chcorbato gravatar image

updated 2011-10-14 04:42:30 -0500


I'm trying to develop introspection nodes for ROS. So far I've been able to use some methods in the rosnode API to retrieve information on the nodes and topics from the master, and to execute the kill_node() method, but failing to actually kill the node (it actually returns me a correct list of the nodes it managed to kill and those it couldn't).

Does anyone knows if it a problem with permissions for the node calling that method? Because the command line tool rosnode kill works fine for me.

I launch a node to test its killing: $ rosrun amcl amcl

Calling the rosnode API doesn't seems to work, here is the method I use (passing '/amcl' as argument). I've tried to resolve the full name by looking at rosnode code, but I'm not sure of what a fully resolved node name is in ROS:

def kill_node1(x):
    a = scriptutil.script_resolve_name('/rosnode', x)

whereas this method that executes the rosnode command works:

def kill_node2(x):
    cmd = 'rosnode kill ' + x + ' &' 

Thank you in avdance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-09-29 05:01:45 -0500

kwc gravatar image

updated 2011-10-14 05:41:28 -0500


The problem is that kill_nodes() takes an array of node names, not a string.

First, a warning: the rosnode documentation notes "This library is intended for internal use only." That means that I am likely to tweak the internal API in non-backwards-compatible ways. You may wish to copy some of the easier routines into your own code to be safe.

There shouldn't be any permissions issues; the general technique (right now) is to make an XMLRPC call to the node to kill. This will change in the future, but that's how it works now.

My only guess is that your code may be specifying node names differently -- they have to be fully resolved names.

edit flag offensive delete link more


Thank you very much for the advice, I knew of the intended use but surely I'd better copy the code. I have updated the question with more info, because trying to resolve the name gives me the same result
chcorbato gravatar image chcorbato  ( 2011-10-14 04:32:57 -0500 )edit
see updated answer, kill_nodes() needs an array of strings, not a string
kwc gravatar image kwc  ( 2011-10-14 05:41:53 -0500 )edit
thank you very much, that was the issue. Sorry it was trivial, I'm new to python programming
chcorbato gravatar image chcorbato  ( 2011-10-16 21:23:08 -0500 )edit

Question Tools


Asked: 2011-09-28 23:07:17 -0500

Seen: 1,502 times

Last updated: Oct 14 '11