Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 import roslib.message;roslib.load_manifest('tug_ist_diagnosis_generator')
00024 import rospy
00025 import sys
00026 import xmlrpclib
00027 import os
00028 import subprocess
00029 import time
00030 import shlex
00031 import thread
00032 from math import sqrt
00033 import time
00034 class Generator(object):
00035 def __init__(self):
00036 rospy.init_node('observers_generator', anonymous=False)
00037 self.m = xmlrpclib.ServerProxy(os.environ['ROS_MASTER_URI'])
00038 self.caller_id = '/script'
00039 self.mapping = []
00040 self.dataMAT = [[]]
00041 self.dataFile = open('safdarFile', 'w')
00042
00043 def start(self):
00044 self.extract_nodes_topics()
00045
00046 def end(self):
00047 self.dataFile.close()
00048
00049 def callback(self,data,topic):
00050 curr_t = time.time()
00051 self.dataFile.write(str(curr_t)+'\n')
00052 rospy.loginfo('type = '+str(data.header))
00053
00054
00055 def extract_nodes_topics(self):
00056 pubcode, statusMessage, topicList = self.m.getPublishedTopics(self.caller_id, "")
00057 for topic in topicList:
00058 if (topic[0] == '/rosout') | (topic[0] == '/rosout_agg'):
00059 continue
00060
00061 print topic[1]
00062 msg_class = roslib.message.get_message_class(topic[1])
00063 rospy.Subscriber(topic[0], msg_class, self.callback, topic[0])
00064 rospy.spin()
00065
00066 if __name__ == '__main__':
00067 generator = Generator()
00068 generator.start()
00069 generator.end()