rostopic_list-v.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 ## This code is made by Safdar Zaman on 20.1.2011 2:17pm Thursday Robotics Lab CityTower TU Graz Austria
00003 ## This Code is to find out the Published and Subscribed Topics.
00004 ## It also mentions the messages on the topic
00005 ## This program acts just like 'rostopic list -v' ros command on the terminal
00006 ## first import necessary lib packages
00007 import os
00008 import xmlrpclib
00009 ## catch the ID for the system
00010 caller_id = '/script'
00011 ## get connected to the ROS MASTER
00012 m = xmlrpclib.ServerProxy(os.environ['ROS_MASTER_URI'])
00013 ## get State of the running ROS system into 3 variables
00014 code, msg, val = m.getSystemState(caller_id)
00015 ## get info about all published topics and their messages
00016 pubcode, statusMessage, topicList = m.getPublishedTopics(caller_id, "")
00017 ## check for the successful connection
00018 if code == 1:
00019   pubs, subs, srvs = val
00020 else:
00021   print "call failed", code, msg
00022 ## get work started and play with the system variables now :-)
00023 print "\nPublished topics:"
00024 for pb in pubs:
00025    for t in topicList:
00026      if t[0] == pb[0]:
00027        if len(pb[1]) < 2:
00028          print " *", pb[0], "[",t[1],"]", len(pb[1]), " publisher"
00029        else:
00030          print " *", pb[0], "[",t[1],"]", len(pb[1]), " publishers"
00031 print "\nSubscribed topics:"
00032 for sb in subs:
00033   for t in topicList:
00034      if t[0] == pb[0]:
00035        if len(sb[1]) < 2:
00036          print " *", sb[0], "[",t[1],"]", len(sb[1]), " subscriber"
00037        else:
00038          print " *", sb[0], "[",t[1],"]", len(sb[1]), " subscribers"


tug_ist_diagnosis_generator
Author(s): Safdar Zaman, Gerald Steinbauer
autogenerated on Mon Jan 6 2014 11:51:14