# A Self-Organizing Area Coverage Method for Swarm Robots Based on Gradient and Grouping
## 3 Self-Organizing Coverage Based on Gradient
### Self-Organizing Coverage Mechanism  
The area coverage process based on gradient has four status. (1) Initial status; (2) Detection status; (3) Coverage status; (4) Arrival status.And the four status transition relationships are shown in Figure 3.  
```
Input: Robot \(\alpha\) with no gradient Output: Robot \(\alpha\) with gradient
1. \(\alpha.grad\) = INFINITE;
2. if \(\alpha.leder==true\) then
3. \(\alpha.grad=0\);
4. else
5. while \(\|\alpha.\mathbf{x}-\alpha_{i}.\mathbf{x}\|<d_{min}\) do
6. \(grad_{min}\leftarrow\arg\min(\alpha_{i}.grad)\);
7. if \(\alpha.grad>grad_{min}+1\) then
8. \(\alpha.grad>grad_{min}+1\);
9. end if
10. end if
```  
**Algorithm 1** Gradient generation algorithm. Figure 2: Gradient formation of robot based on distance. * Initial status: before covering the target area, all robots are in the Initial status and complete the gradient initialization. * Detection status: the coverage of the target area requires the robot to carry out one by one in order, and the Detection status requires the robot to check its neighbors to determine whether it can cover. * Coverage status: the robot breaks away from the formation and moves towards the target area to achieve the coverage of the target area. * Arrival status: if the robot has reached the appropriate position, it will stop. The idea of self-organizing area coverage method based on gradient is as follows: Firstly, all robots are in the Initial status, and the robots initialize their gradient by monitoring the adjacent neighbors within \(d_{m}in\) distance. The initial gradient will determine the sequence of motion of the swarm robots. Secondly, the robot with the largest gradient will be Coverage status. Thirdly, the robot carries on the covering movement through the boundary circling and the gradient updating two self-organizing behaviors, until the stop condition occurs, the robot status transitions to the Arrival status and complete the covering. The stop conditions are as follows:  
* If the robot is in the target area and is about to leave the target area, it will stop moving and change to the Arrival status. * If the gradient of the robot surrounding the object is greater than or equal to its gradient, the robot in the target area will stop moving and convert to the Arrival status. After the swarm robots generate the gradient according to the distance self-organization, the gradient descent principle can be used to carry out the self-organization area coverage task. The distance \(d_{cover}(d_{cover}\geq d_{safe})\)is the radius of the robot's coverage. Each robot circles with radius \(d_{cover}\) and changes its center of the circle when its nearest neighbor changes, then all robots on the boundary will continue to move. The robot gradient can be automatically updated to the surrounding robot gradient plus 1. Figure 4 describes the self-organizing area coverage process of swarm robots based on gradient. The swarm robots move to the edge of the area in a well-formed formation led by the leader robot, as shown in Figure 4a. All the robots will stop when the leader robot arrives at the boundary of the area. Then the robot with the largest gradient (on the outermost side) will move along the edge of the swarm robots according to the safe distance as the radius, and move towards the direction with low gradient value, and update the gradient at any time, as shown in Figure 4b. Finally, the robot enters the covered area and continues to move until it stops just before leaving the boundary of the area. If the front robot has the same gradient and has stopped while the robot is walking along the edge, the robot will also stop according to the covering distance. If the robot stops outside the covered area, the robot will continue to walk along the edge and enter the area. At this time, the gradient of the robot will increase by 1, as shown in Figure 4c. The self-organizing coverage algorithm based on gradient is shown in Algorithm 2. Figure 3: Self-organizing coverage status transition graph based on gradient.