-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_parallelized.py
58 lines (42 loc) · 1.41 KB
/
test_parallelized.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import swarm_tasks
from swarm_tasks.simulation import simulation as sim
from swarm_tasks.simulation import visualizer as viz
import swarm_tasks.utils as utils
import swarm_tasks.envs as envs
import swarm_tasks.controllers as ctrl
import swarm_tasks.controllers.potential_field as potf
import swarm_tasks.controllers.base_control as base_control
from swarm_tasks.modules.aggregation import aggr_centroid, aggr_field
from swarm_tasks.modules.dispersion import disp_field
from swarm_tasks.modules.formations import circle
from swarm_tasks.modules.formations import line
from swarm_tasks.modules.surround import surround_attractor
from swarm_tasks.modules import exploration as exp
import numpy as np
import multiprocessing
import time
class ControlProcess(multiprocessing.Process):
def __init__(self, bot):
multiprocessing.Process.__init__(self)
self.bot = bot
def run(self):
global s
#global gui
while 1:
cmd = base_control.base_control(self.bot)
cmd+= base_control.obstacle_avoidance(self.bot)
cmd+=surround_attractor(self.bot)
cmd += exp.explore(self.bot)
cmd.exec(self.bot)
#time.sleep(0.05)
#gui.update()
#s = sim.Simulation(env_name='empty_world', contents_file='attractors')
s = sim.Simulation(num_bots=15, env_name='rectangles', contents_file='attractors')
gui = viz.Gui(s)
gui.show_env()
gui.show_bots()
for b in s.swarm:
ControlProcess(b).start()
while 1:
gui.update()
#time.sleep(0.05)