示例#1
0
    #print(robot)
    while distance>0.5:
        loc_x = -x_total/40.0
        loc_y = -y_total/40.0
        lock.acquire()
        #print(robot.id,loc_x,loc_y,distance)
        lock.release()
        robot.move(loc_x,loc_y)
        x_total,y_total = relative_distance(robot,robots)
        distance = distance_magnitude(x_total,y_total)
        time.sleep(0.1)

def simulate_meeting_point(robots):
	#run simulation using multithreading
    for robot in robots:
        dynamics_meeting_point(robot,robots)
#        worker = threading.Thread(target=dynamics_meeting_point,args=(robot,robots))
#        print(worker)
#        worker.setDaemon(True)
#        worker.start()



if __name__ == '__main__':
	#main program
	win = draw_windows(1024,1024) #draw window with width = 700 and height = 600
	robots = draw_swarm(70,win) #draw 7 swarm in win
	win.getMouse() #blocking call
	simulate_meeting_point(robots) #start simulation meeting point
	win.getMouse()
plotter = VisdomLinePlotter(env_name="Swarm_Simulation")
simulation_time = time.time()

trial_no="TURK1 s2"

N=100
rho_bar, sigma =10,100
mu=100
l=5*rho_bar
times=pow(2,-8)

rho_k,patches = normal_distribution(rho_bar,sigma,trial_no)
particles=list()

win = draw_windows(1024,1024,trial_no) #draw window with width = 700 and height = 600.
robots = draw_swarm(N,win,l,rho_k,patches) #draw N swarm in win
win.getMouse() #blocking call

for i in range(1,N+1,1):
    particles.append([i,rho_k[i-1]])


#pairwise_list= list(combinations(particles,2))
pairwise_list = random.sample(particles, 2)
#mt_shuffle()

step=0

rho_kmean =np.mean(rho_k)# second term of the energy function
combination= (N*(N-1))/2
U_knot=0 #Order Parameter
示例#3
0
    plt.show()
    return rho_k


N = 1000
rho_bar, sigma = 5, 100
mu = 100
l = 5 * rho_bar
times = pow(2, -8)

rho_k = normal_distribution(rho_bar, sigma)
particles = list()

win = draw_windows(1024, 1024)  #draw window with width = 700 and height = 600.
robots = draw_swarm(N, win, l)  #draw N swarm in win
win.getMouse()  #blocking call

for i in range(1, N + 1, 1):
    particles.append([i, rho_k[i - 1]])

#pairwise_list= list(combinations(particles,2))
pairwise_list = random.sample(particles, 2)
#mt_shuffle()

step = 0

while (1):  #replace with energy function
    pairwise_list = random.sample(particles, 2)
    robot_j = robots[pairwise_list[0][0] - 1]
    rho_j = pairwise_list[0][1]
trial_no = "WEBOTS-SOL3-T1"

N = 100

mu = 100
times = pow(2, -8)
#rho_k,patches = normal_distribution(rho_bar,sigma,trial_no)

particles = list()

w, h = 1024, 1024
win = draw_windows(1024, 1024,
                   trial_no)  #draw window with width = 700 and height = 600.

robots, rho_k = draw_swarm(N, win, trial_no)  #draw N swarm in win
#robots,rho_k = init_uniform_rhok(rho_k,robots,1024,1024,win)
patches = normal_distribution_color(rho_k)
robots = draw_robots(N, win, robots, rho_k, patches)
win.getMouse()  #blocking call.

for i in range(1, N + 1, 1):
    particles.append([i, rho_k[i - 1]])
pairwise_list = list(permutations(particles, 2))
#pairwise_list = random.sample(particles, 2)
mt_shuffle()

step = 0

rho_kmean = np.mean(rho_k)  # second term of the energy function
combination = (N * (N - 1)) / 2