## 2 A Behavior-Based Self-Deployment and -Repair Algorithm  
### An Implementation of SPF for MWSN  
This work proposes a behavior-based algorithm valid both for deployment and self-healing. Reactive behaviors are based on the local conditions of the nodes at each time instant. Our algorithm is based on the social potential fields (SPF), originally proposed for swarm robots [29]. SPF assigns simple attraction and repulsion forces to goals and/or constraints. The combination of all forces results in a more complex emergent behavior. In our case, we rely on two repulsion forces and a clustering one. We have purposefully designed two repulsion forces depending on their purpose. One is meant to avoid collision with obstacles and to prevent robots from leaving the area to be covered. The other is meant to expand the network, i.e., to keep the robot as far away from all of the others as possible. Repulsion forces are split into two types, not only because they serve different purposes, but also because it is easier to adjust their parameters when the goal of each one is clearly defined at the reactive level. Forces are active at all times, but nodes only move when they are not balanced. SPF-derived motion is typically smooth and tends to present no discontinuities. In our case, that means that while nodes are moving, there will be a continuous trade-off between keeping away from each other and preserving connectivity. * Repulsion force(s) \(f_{t1}(r_{i,j})\) repels the robot from other robots or physical obstacles in its vicinity to prevent collisions. In our implementation, the coverage area boundary is modeled as a virtual obstacle, so that it also repels nodes to prevent them from leaving the area. * Repulsion force(s) \(f_{t2}(r_{i,j})\) moves robots away from each other to expand the network. These forces can be calculated using RSS. * An attraction force (clustering force) \(f_{c}(r_{i,j})\) increases with \(r_{i,j}\) to avoid the loss of communication. \(r_{i,j}\) is the distance between robots \(i\) and \(j\). Unlike other node relocalization techniques, e.g., [31], our algorithm does not need absolute localization information of elements in the environment to operate. However, it still needs to estimate relative distances between robots and with respect to the coverage area boundaries. The locations of all elements under simulation are always known. In real tests, locations are often estimated by RSS-based trilateration [27,32]. However, RSS is affected by environmental factors and obstacles, so RSS-based localization may yield significant errors. In our case, errors are constrained, because we only need to estimate relative distances between nodes separated by one hop. Besides, in areas where errors could be critical, distances are estimated with an onboard range sensor to prevent collisions with other nodes and obstacles in the environment. Thus, unlike other methods [33], our system does not need to assume that there are no obstacles in the environment, nor have knowledge about its layout. Nevertheless, our system performance would still be affected by localization errors, especially to estimate distances to the deployment area boundaries. Some approaches rely on creating a static beacon infrastructure to reduce localization errors [34]. In open environments where GPS is reliable, some of the network nodes equipped with a GPS receiver may work as beacons to autonomously create this infrastructure during deployment [35]. Mobile robots may statistically combine this information and/or sensor feedback with odometry to improve localization accuracy, e.g., [36]. However, this process may involve computational load not affordable for inexpensive robots. Unlike deliberative navigation systems, reactive approaches do not heavily rely on localization, so RSS-based localization errors are acceptable because they are not accumulative, i.e., they are typically bounded to a few meters. Besides, in our system, nodes typically keep a distance of a few meters between each other, whereas the communication range is larger.