[ros-users] Rospy get available services

Ken Conley kwc at willowgarage.com
Mon Jun 14 21:22:37 UTC 2010


There's currently no high level API for this, but it's only a couple of
lines of code. The example below is cturtle. For boxturtle use
"roslib.masterapi" instead.

$ rospython rosgraph
>>> import rosgraph.masterapi
>>> m = rosgraph.masterapi.Master('/mynode')
>>> m.getSystemState()[2]
[['/rosout/set_logger_level', ['/rosout']], ['/rosout/get_loggers',
['/rosout']]]
>>> services = m.getSystemState()[2]
>>> service_names = [x[0] for x in services]
>>> service_names
['/rosout/set_logger_level', '/rosout/get_loggers']

or, more briefly:

service_names = [x[0] for x in
rosgraph.masterapi.Master('/mynode').getSystemState()[2]]

 - Ken

On Mon, Jun 14, 2010 at 12:30 PM, Sarah Osentoski <sosentos at cs.brown.edu>wrote:

>  Hi everyone,
>
> I'm working on some code using python.  I noticed that while there is a
> nice way to get the list of published topics and their types using
> get_published_topics, there doesn't seem to be a similar function for
> services.
>
> Am I missing something?  If not, will this functionality be added sometime
> in the future?
>
> Thanks,
>
>  Sarah Osentoski
> Postdoctoral Research Associate
> Department of Computer Science, Brown University
> http://www.cs.brown.edu/~sosentos/ <http://www.cs.brown.edu/%7Esosentos/>
>
>
>
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100614/beccf77e/attachment-0003.html>


More information about the ros-users mailing list