Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('estirabot_apps')
00003 import rospy
00004 import sys
00005 from std_msgs.msg import String, Int32
00006 from pprint import pprint
00007
00008 objects_seen = {'0' : 0, '1' : 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7' :0, '8': 0, '9':0}
00009
00010 def callback(data):
00011 rospy.loginfo("Seen: %s",data.data)
00012 objects_seen[str(data.data)] = objects_seen[str(data.data)] + 1
00013
00014 def listener():
00015 rospy.init_node('count_objects', anonymous=True)
00016 rospy.Subscriber("/iri_textile_count/num_objects_found", Int32, callback)
00017 rospy.spin()
00018
00019 if __name__ == '__main__':
00020 if (len(sys.argv) < 1):
00021 print "Usage: count_objects [expected number]"
00022 exit
00023
00024 listener()
00025 print "Real number of clothes: " + str(sys.argv[1])
00026 pprint(objects_seen)