advertise_chatter.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #       
00003 # License: BSD
00004 #   https://raw.github.com/robotics-in-concert/rocon_multimaster/master/rocon_gateway_examples/LICENSE 
00005 #
00006 ##############################################################################
00007 # Imports
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     #  Setup gateway service
00036     advertise_srv = rospy.ServiceProxy('/gateway/advertise',Advertise)
00037    
00038     # Create Service Request Object
00039     req = AdvertiseRequest()
00040     req.cancel = False          # if true, it unadvertise the exisiting topic
00041 
00042     rule = Rule()
00043     rule.name = '/chatter'               # Topic name
00044     rule.type = ConnectionType.PUBLISHER # Advertise publisher
00045     rule.node = ''                       # If specified, it advertise only a particular node's publisher
00046     req.rules = []
00047     req.rules.append(rule)
00048     
00049     # Call service
00050     rospy.loginfo("Advertise : %s [%s,%s,%s]."%('advertise',rule.type, rule.name, rule.node or 'None')) 
00051     resp = advertise_srv(req)
00052 
00053     # Print response
00054     rospy.loginfo(str(resp))
00055 
00056 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


rocon_gateway_examples
Author(s): Jihoon
autogenerated on Sat Nov 10 2012 14:08:33