Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('saap_pkg')
00003
00004
00005 import rospy
00006
00007
00008 import auction_msgs.msg
00009
00010
00011 import auction_srvs.srv
00012
00013
00014 import random
00015 import math
00016
00017
00018 winner_id = 'none'
00019 winner_cost = 0
00020
00021 role_assigned = False
00022 node_role = 'none'
00023
00024
00025
00026
00027
00028
00029 def neighbour_node_auction_client(neighbour_node, auction_req):
00030
00031
00032 service_path = neighbour_node+'/auction_server'
00033
00034
00035 rospy.wait_for_service(service_path)
00036
00037 try:
00038
00039 neighbour_node_auction_server = rospy.ServiceProxy(service_path,
00040 auction_srvs.srv.AuctionService)
00041
00042
00043 neighbour_node_bid_response = neighbour_node_auction_server(auction_req)
00044
00045
00046
00047
00048
00049
00050 return neighbour_node_bid_response.bid_data
00051
00052 except rospy.ServiceException, e:
00053 rospy.loginfo("Service call failed: %s",e)
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 def create_neighbour_nodes_list(auction_req):
00065
00066 neighbour_nodes_string = rospy.get_param('~neighbour_nodes_list')
00067 neighbour_nodes_list = neighbour_nodes_string.split(',')
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 nodes_collected_list = list(set(neighbour_nodes_list) - set(auction_req.nodes_collected.split(',')))
00091
00092
00093
00094 while '' in nodes_collected_list:
00095 nodes_collected_list.remove('')
00096
00097
00098 nodes_collected_list = list(set(nodes_collected_list))
00099
00100
00101 while rospy.get_name() in nodes_collected_list:
00102 nodes_collected_list.remove(rospy.get_name())
00103
00104
00105 while auction_req.sending_node in nodes_collected_list:
00106 nodes_collected_list.remove(auction_req.sending_node)
00107
00108
00109 if nodes_collected_list:
00110
00111
00112 nodes_collected_string = ','.join(nodes_collected_list)
00113
00114
00115
00116
00117
00118 neighbour_nodes_list = nodes_collected_string.split(',')
00119
00120 else:
00121 neighbour_nodes_list = []
00122 pass
00123
00124 return neighbour_nodes_list
00125
00126
00127