talker.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('rospy_tutorials')
00004 
00005 import rospy
00006 from std_msgs.msg import String
00007 from std_msgs.msg import Int16
00008 from map_mux.srv import *
00009 
00010 def talker():
00011     rospy.init_node('talker', anonymous=True)
00012     print 12
00013     rospy.wait_for_service('change_map')
00014     print 13
00015 
00016     #pub = rospy.Publisher('change_map', Int16)
00017     r = rospy.Rate(.2) # 10hz
00018     i = 1
00019     while not rospy.is_shutdown():
00020         if i == 1:
00021             i = 2
00022         elif i == 2:
00023             i = 3
00024         elif i == 3:
00025             i = 1
00026         try:
00027             change_map = rospy.ServiceProxy('change_map', ChangeMap)
00028 #        add_two_ints = rospy.ServiceProxy('add_two_ints', AddTwoInts)
00029             ii = change_map(i)
00030             print i
00031             print "..."+str(ii)
00032         except rospy.ServiceException , e:
00033             print "failure"
00034 
00035         #rospy.loginfo(i)
00036         #pub.publish(i)
00037         r.sleep()
00038 
00039 if __name__ == '__main__':
00040     try:
00041         talker()
00042     except rospy.ROSInterruptException: pass
00043 
00044 
00045 
00046 
00047 ##!/usr/bin/env python
00048 #import roslib; roslib.load_manifest('beginner_tutorials')
00049 #
00050 #import sys
00051 #
00052 #import rospy
00053 #from beginner_tutorials.srv import *
00054 #
00055 #def add_two_ints_client(x, y):
00056 #    rospy.wait_for_service('add_two_ints')
00057 #    try:
00058 #        add_two_ints = rospy.ServiceProxy('add_two_ints', AddTwoInts)
00059 #        resp1 = add_two_ints(x, y)
00060 #        return resp1.sum
00061 #    except rospy.ServiceException, e:
00062 #        print "Service call failed: %s"%e
00063 #
00064 #def usage():
00065 #    return "%s [x y]"%sys.argv[0]
00066 #
00067 #if __name__ == "__main__":
00068 #    if len(sys.argv) == 3:
00069 #        x = int(sys.argv[1])
00070 #        y = int(sys.argv[2])
00071 #    else:
00072 #        print usage()
00073 #        sys.exit(1)
00074 #    print "Requesting %s+%s"%(x, y)
00075 #    print "%s + %s = %s"%(x, y, add_two_ints_client(x, y))


map_mux
Author(s):
autogenerated on Tue Mar 10 2015 10:08:38