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 Remote,RemoteRequest
00014 from gateway_comms.msg import ConnectionType
00015 
00016 """
00017     Flipping chatter. It flips /chatter topic from master_uri 11312 to 11313
00018 
00019     Usage:
00020         1 > roslaunch --port=11311 rocon_gateway_hub priate.launch           // starts hub
00021 
00022         2a > roslaunch --port=11312 rocon_gateway pirate_tutorials.launch     // launches gateway on master_uri 11312 its gateway name is 'gateway' and starts /chatter publisher
00023         3a > roslaunch --port=11313 rocon_gateway priate.launch               // launches gateway on master_uri 11313 its gateway name is 'gateway2'
00024 
00025         2b > rosrun rocon_gateway_examples flip_chatter.py  __master:=http://localhost:11312  // flips /chatter topic in 11312
00026         3b > rostopic list                                                                    // check if the topic exists in 11313
00027 """
00028 
00029 if __name__ == '__main__':
00030     
00031     rospy.init_node('flip_chatter')
00032     rospy.loginfo("Fliping /chatter topic")
00033 
00034     
00035     flip_service = rospy.ServiceProxy('/gateway/flip',Remote)
00036 
00037     
00038     remote_gateway_name = 'gateway1'
00039 
00040     
00041     req = RemoteRequest()
00042     req.remote.gateway = remote_gateway_name 
00043     req.cancel = False          
00044     req.remote.rule.name = "/chatter"
00045     req.remote.rule.type = ConnectionType.PUBLISHER     
00046     req.remote.rule.node = '' 
00047 
00048     
00049     rospy.loginfo("Flip : %s [%s,%s,%s,%s]."%('flipping', req.remote.gateway, req.remote.rule.type, req.remote.rule.name, req.remote.rule.node or 'None')) 
00050     resp = flip_service(req)
00051 
00052     
00053     rospy.loginfo(str(resp))
00054