## 3 Methods
### Anti-Collision and Obstacle Avoidance  
Anti-collision and obstacle avoidance is essential for task implementation. It ensures the agents avoid hitting others in the swarm or obstacles in the environment. With the low-complexity swarm in mind, here we use a simplified Vector Field Histogram (VFH) algorithm to achieve this goal. VFH algorithm determines the movement direction by constructing vector field histogram to represent polar obstacle density (POD). First, it divides sensing field of an agent into \(n\) sectors and each sector's cover angle is \(360^{\circ}/n\). Then, the following equation is used to calculate the corresponding POD in the histogram for each sector [27]:  
\[h^{k}(\mathbf{q_{i}})=\int_{\Omega_{k}}P(\mathbf{p})^{n}\cdot\left(1-\frac{d( \mathbf{q_{i}},\mathbf{p})}{d_{max}}\right)^{m}d\mathbf{p} \tag{12}\]  
where \(h^{k}(\mathbf{q_{i}})\) is the polar obstacle density in sector \(k\), \(P(\mathbf{p})\) is the probability a point is occupied by an obstacle, \(d(\mathbf{q_{i}},\mathbf{p})\) is the distance from the center of the agent to point \(\mathbf{p}\), \(d_{max}\) is the maximum detection range of the sensor, and the dominion of integration \(\Omega_{k}\) is defined as  
\[\Omega_{k}=\left\{\mathbf{p}\in k\wedge d(\mathbf{q_{i}},\mathbf{p})<d_{s}\right\} \tag{13}\]  
By applying a threshold to the polar histogram, a set of candidate directions that are closest to the target direction can be obtained. In the next step, the strategy to choose a direction of this set depends on the relationships between the selected sectors and the target sector. It has been proven that this method is effective for obstacle avoidance of mobile robots. In our case, since the simple swarm members need to keep the formation during moving, we have to consider the low computational complexity as well as the velocity constraints. By adopting the fundamental principle of VHF algorithm, we can design our actions in state \(S_{2}\) for anti-collision and obstacle avoidance as follows. As shown in Figure 6, it is assumed that the robot can detect the ranges in \(2a+1\) sectors (\(a>0\)) in its visual field, i.e., \(-125^{\circ}\) to \(125^{\circ}\), where \(0^{\circ}\) is the heading direction of an agent. By considering the effects of neighbor sectors, the smoothed polar obstacle density on \(k\)th direction can be represented as:  
\[\rho_{k}=\sum_{i=-l}^{l}w(i)f(k+i) \tag{14}\]  
\[f(k+i)=(1-\frac{\min\{d_{s},d(k+i)\}}{d_{s}})^{2} \tag{15}\]  
Figure 5: Configurations of swarm members. where \(l\) is a positive number that represents the compute window of each direction \(k\in[-a,a]\), \(d(k+i)\) is the distance from the center of the agent to the obstacle in direction \(k+i\), \(d_{s}\) is the predefined safe distance, and \(w(i)\) is the weight of the corresponding neighbor directions, which can be determined by:  
\[w(i)= \begin{cases}\frac{l-|i|+1}{\sum_{i=-l}^{l}(l-|i|+1)},&-a\leq k+i\leq a\\ 0,&\text{others}\end{cases}  \tag{16}\]  
This choice of \(w(i)\) ensures that the farther the neighbor direction from \(k\) is, the smaller the weight is as well as that the current heading direction \(k\) (\(i=0\)) has the largest one. Consequently, denote \(\hat{k}=\text{argmin}\{\rho_{k}\}\) as the potential direction(s); we can choose the solution direction by:  
\[k_{s}= \begin{cases}\hat{k},\qquad\hat{k}\quad\text{is unique}\\ argmin(||k_{l}-\hat{k}||),\qquad\text{others}\end{cases}  \tag{17}\]  
where \(k_{s}\) is the solution direction, and \(k_{l}\) is a direction that contains a target determined by formation control strategy. Furthermore, the safe distance \(d_{s}\) is related to the turning radius at maximum speed and the update cycle \(T\) of the agent, i.e.,  
\[d_{s}=K_{s}(\frac{v_{max}}{\omega_{max}}+v_{max}T) \tag{18}\]  
where \(K_{s}>1\) is the safety coefficient. We can use the following equations to determine the final inputs for anti-collision and obstacle avoidance. \[v(n+1)=\rho_{min}\cos(k_{s}\beta),\qquad\text{others} \tag{19}\]  
\[\omega(n+1)=