Skip to main content
. 2023 Nov 15;8(7):549. doi: 10.3390/biomimetics8070549
Algorithm 3: WLVM.
Data: x, y, leaderStart, leaderTarget
1 Initialize parameters
// (n - the number of particles
2 nsize(x,2)+1
3 dt1
4 change1
5 xxleaderStartx
6 yyleaderStarty
7 thetazeros(1,n)
8 for i1 to n do
9 theta(i)leaderStarttheta
10 end
11 while change > 0 do
12 changechange1
13 for each changed swarm do
// (getting the positions and angles for the virtual leader
14 [LeaderPos,LeaderAngle]HybridAstar
15 for time1 to timemax do
16 Calculate averageTheta
17 xx+velcos(theta)dt
18 yy+velsin(theta)dt
19 thetaw1averageTheta+w2leaderAngle(time)+noise
20 Smoothen path
21 Deadlock and collision avoidance
22 end
23 Segment delay
24 end
25 Swarm evaluation
26 if swarm changes then
27 changechange+1
28 end
29 end