flip_all.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_demos/LICENSE 
00005 #
00006 
00007 import roslib; roslib.load_manifest('rocon_gateway_demos')
00008 import rospy
00009 import rocon_gateway
00010 import rocon_gateway_demos
00011 from gateway_msgs.msg import *
00012 from gateway_msgs.srv import *
00013 import argparse
00014 import sys
00015 
00016 """
00017   Tests a single flip rule.
00018   
00019   Usage:
00020     1 > roslaunch rocon_gateway_demos pirate_hub.launch
00021     2a> roslaunch rocon_gateway_demos pirate_gateway_tutorials.launch
00022     3a> roslaunch rocon_gateway_demos pirate_gateway.launch
00023     2b> rosrun rocon_gateway_demos flip_all.py
00024     2c> rosrun rocon_gateway_demos flip_all.py --cancel
00025 """
00026 
00027 if __name__ == '__main__':
00028 
00029     parser = argparse.ArgumentParser(description='Flip all connections (unflip if using --cancel')
00030     #parser.add_argument("gateway", help="gateway string identifier", type=str)
00031     parser.add_argument('--cancel', action='store_true', help='cancel the flip')
00032     args = parser.parse_args()
00033     if args.cancel:
00034         action_text = "cancelling"
00035     else:
00036         action_text = "flipping"
00037 
00038     rospy.init_node('flip_all')
00039 
00040     try:
00041         gateway = rocon_gateway_demos.findFirstRemoteGateway()
00042     except rocon_gateway.GatewayError as e:
00043         rospy.logerr("Flip Test : %s, aborting."%(str(e)))
00044         sys.exit(1)
00045     
00046     flip_all = rospy.ServiceProxy('/gateway/flip_all',RemoteAll)
00047     req = RemoteAllRequest() 
00048     req.gateway = gateway
00049     req.cancel = args.cancel
00050     req.blacklist = []
00051 
00052     rospy.loginfo("Flip All : %s all [%s]."%(action_text,req.gateway)) 
00053     resp = flip_all(req)
00054     if resp.result != 0:
00055         rospy.logerr("Flip All : %s"%resp.error_message)
00056 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


rocon_gateway_demos
Author(s): Daniel Stonier
autogenerated on Fri Nov 23 2012 14:51:15