Simple Examples
These examples show some basic functions of PySwarming, like target, aggregation, and repulsion.
For more examples, you can see the notebooks and examples directories of PySwarming.
Target behavior
[1]:
%matplotlib inline
# importing the swarm creator
import pyswarming.swarm as ps
# creating the swarm
my_swarm = ps.Swarm(n = 10, # number of robots
linear_speed = 0.5, # linear speed of each robot
dT = 1.0, # sampling time
deployment_point_limits = [[0.0, 0.0, 0.0], [5.0, 5.0, 0.0]], # lower and upper limits for the position deployment
deployment_orientation_limits = [[0.0, 0.0, 0.0], [0.0, 0.0, 2*3.1415]], # lower and upper limits for the orientation deployment
distribution_type = 'uniform', # type of distribution used to deploy the robots
plot_limits = [[-50.0, 50.0], [-50.0, 50.0]], # plot limits x_lim, y_lim
behaviors = ['target']) # list of behaviors
my_swarm.behaviors_dict['r_out']['target']['T'] = [-40, -40, 0] # setting the target position [x, y, z]
anim = my_swarm.simulate(mode='anim')
from IPython.display import HTML
HTML(anim.to_jshtml())
[1]: