Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 import roslib; roslib.load_manifest('rocon_gateway_examples')
00011 import rospy
00012 import rocon_gateway
00013 from gateway_comms.srv import Advertise,AdvertiseRequest
00014 from gateway_comms.msg import ConnectionType, Rule
00015
00016 """
00017 Advertise /chatter Publisher
00018
00019 Usage:
00020 1> roslaunch --port=11311 rocon_gateway_hub pirate.launch # starts hub
00021
00022 2a> roslaunch --port=11312 rocon_gateway pirate_tutorials.launch # launches gateway on master_uri 11312 and starts /chatter publisher
00023 2b> rosrun rocon_gateway_examples advertise_chatter.py __master=http://localhost:11312 # advertise /chatter
00024
00025 2c> rosservice call /gateway/gateway_info # check if chatter is advertised properly
00026
00027 3a> roslaunch --port=11313 rocon_gateway pirate.launch # launches gateway on master_uri 11313.
00028 3b> rosservice call /gateway/remote_gateway_info [] # check if /chatter is visible
00029 """
00030
00031 if __name__ == '__main__':
00032
00033 rospy.init_node('advertise_chatter')
00034
00035
00036 advertise_srv = rospy.ServiceProxy('/gateway/advertise',Advertise)
00037
00038
00039 req = AdvertiseRequest()
00040 req.cancel = False
00041
00042 rule = Rule()
00043 rule.name = '/chatter'
00044 rule.type = ConnectionType.PUBLISHER
00045 rule.node = ''
00046 req.rules = []
00047 req.rules.append(rule)
00048
00049
00050 rospy.loginfo("Advertise : %s [%s,%s,%s]."%('advertise',rule.type, rule.name, rule.node or 'None'))
00051 resp = advertise_srv(req)
00052
00053
00054 rospy.loginfo(str(resp))
00055
00056