1 Introduction

Research on decentralized adaptive swarming systems is mainly based on findings in physics, such as Boids [1], motile elements [2], and fluid dynamics [3]. For applications in swarming robots, it is quite important to guarantee collision-freeness. In other words, autonomous robots must maintain a certain distance from others even if they are swarming. Yet many researcher employed a local potential function that implies a local gradient around a robot so that it virtually receives repulsive forces from the other robots. This method cannot guarantee a safe distance due to conflicts with other requirements related to tasks and/or environmental conditions.

In real situations, swarming robots must overcome obstacles. In the case of narrow spaces, the tolerance for safe distance can be quite small, because a swarm must change its whole shape (layout of robots) according to the shape dictated by the environment. In an environment with obstacles, to guarantee conflict avoidance, Sakai et al. proposed collision avoidance in inequality constraints form [4]. However, the constraint rule was heuristically structured. This requires the reconstruction of constraints and proof of ability to avoid collision when the model of robots or obstacles change.

The control barrier function (CBF) [5,6,7], expressed in inequality forms of constraints, can theoretically guarantee collision-freeness in a certain class of systems. Although we find many studies introducing CBF to swarm robots, most of them are not concerned about obstacle regions in which robots gather closely. When robots are densely packed together, the collision avoidance constraints can tightly limit their movements and prevent the deformation of the whole shape of the swarm.

In this study, we consider the implementation of CBF to a robotic swarm and investigate its effects on the deformation of the swarm based on an analysis in the frequency domain. After obtaining the appropriate parameter range, we designed a constraint that can realize kee** a safe distance between robots and retaining the deformability of the swarm. This contributes to the design of functional, collision-free swarms.

2 Problem setting

2.1 Base model of swarm

Let \(\mathcal {N}\) be a set of robots. Suppose a swarm consists of \(|\mathcal {N}|\) robots that move in a two-dimensional plane; the position of a robot \(\varvec{x}_i\in \mathbb {R}^2(i\in \mathcal {N})\) follows:

$$\begin{aligned} m\ddot{\varvec{x}_i} + \eta \dot{\varvec{x}_i} = \varvec{u}_i, \end{aligned}$$
(1)

where m and \(\eta \) are positive constant values, and \(\varvec{u}_i\in \mathbb {R}^2\) is the control input for robot i. We employ the model in [11] to calculate \(\varvec{u}_i\).

$$\begin{aligned} \varvec{u}_i= & {} \varvec{f}_i^O + \varvec{f}_i^F + \varvec{f}_i^P, \end{aligned}$$
(2)
$$\begin{aligned} \varvec{f}_i^O= & {} {\left\{ \begin{array}{ll} -k_o\frac{d_o^2-||\varvec{x}_{io}||^2}{d_o^2}\frac{\varvec{x}_{io}}{||\varvec{x}_{io}||} &{} (||\varvec{x}_{io}||<d_o)\\ 0 &{} (||\varvec{x}_{io}||\ge d_o) \end{array}\right. }, \end{aligned}$$
(3)
$$\begin{aligned} \varvec{f}_i^F= & {} -k_F\sum _{j\in \mathcal {N}_i}\left( \frac{1}{||\varvec{d}_{ij}||^3}-\frac{1}{||\varvec{d}_{ij}||^2}\right) e^{-||\varvec{d}_{ij}||}\varvec{d}_{ij}, \end{aligned}$$
(4)
$$\begin{aligned} \varvec{f}_i^P= & {} k_P \frac{\nabla c(\varvec{x})}{\Vert \nabla c(\varvec{x})\Vert }, \end{aligned}$$
(5)

where \(\varvec{x}_{io}\) denotes the relative position of the nearest object, and \(\varvec{d}_{ij} := \frac{\varvec{x}_{ij}}{r_c},\, \varvec{x}_{ij} := \varvec{x}_j-\varvec{x}_i\). \(\mathcal {N}_i := \{j\in \mathcal {N}\mid \Vert \varvec{x}_{ij}\Vert \le r_v\}\) is a set of neighbors of robots i. \(\varvec{f}_i^O\),\(\varvec{f}_i^F\) are terms corresponding to collision avoidance from obstacles and distance maintained between robots, respectively. \(d_o\) represents the maximum distance that takes obstacles into account, and \(r_c\) represents a nominal distance between robots given by a user.

To achieve a certain swarm task, \(\varvec{f}_i^P\) guides each robot based on \(c(\varvec{x})\), which is an attractant field that contains information on the direction of a swarm. For each task, \(c(\varvec{x})\) should be determined; for example, the odor concentration information can be included in the odor source search problem.

2.2 CBF constraints for swarm

While the base model is simple in structure, it can not guarantee a safe distance to prevent collisions. In (2), \(\varvec{f}_i^F\) may conflict with \(\varvec{f}_i^O\) and \(\varvec{f}_i^P\). Although \(\varvec{f}_i^F\) attempts to maintain an appropriate distance between robots, it cannot theoretically guarantee the distance. If we determine a set of parameters \(k_F, k_O\) and \(k_P\) experimentally, the actual distances will vary depending on the environment and the number of robots.

Here, we consider guaranteeing a safe distance by applying CBF constraints. However, in the case of obstacle space and high density of robots, CBF may conflict with the input to exhibit desired behaviours by which a whole shape of a swarm can be deformed.

As CBF has a parameter that denotes the naivety of the constraint, we must adjust it to introduce appropriate constraints. Naive constraints can significantly restrict the movements of robots, and consequently, prevent them from deforming. If we set an aggressive parameter, extreme changes in input occur, which can destabilize the system. Therefore, it is necessary to find a suitable range for the parameter. For this purpose, we need to investigate the effect of the parameter on the deformability of a swarm.

Problem statement We set the following two goals for this study:

  • To implement CBF to guarantee safe distance between robots.

  • To investigate the effect of the CBF parameter on the deformability of a swarm.

The goals allow us to obtain a suitable range for the CBF parameter that enables the smooth deformation of a swarm while maintaining a safe distance between the robots.

In this study, deformability is regarded as the ability to change the aspect ratio of the entire shape of a swarm in response to periodic external forces. We regard deformability as an indicator of the ability to accomplish tasks, such as passing through narrow spaces. The periodic external force is a normalized force caused by environmental conditions. For example, if there are many small obstacles, a swarm undergoes high-frequency external perturbations. If a swarm is squeezed for a long time in a narrow space, the swarm is affected by a low-frequency force.

3 Control barrier function and swarm deformability

3.1 Control barrier function

Here, we review the zeroing control barrier function (ZCBF) published by Ames et al. [6]. Let state \(\varvec{x}\in \mathbb {R}^n\) follow the input-affine system shown below, using the input \(\varvec{u}\in \mathbb {R}^m\);

$$\begin{aligned} \dot{\varvec{x}} = f(\varvec{x}) + g(\varvec{x})\varvec{u}, \end{aligned}$$
(6)

where f and g are locally Lipschitz. Consider \(h(\varvec{x}):\mathbb {R}^n\rightarrow \mathbb {R}\) to be a continuously differentiable function, and \(\mathcal {C} = \{\varvec{x}\in \mathbb {R}^n\mid h(\varvec{x})\ge 0\}\). Then, \(h(\varvec{x})\) is said to be a ZCBF for the set \(\mathcal {C}\) if there exists an extended class \(\mathcal {K}\) function \(\alpha : \mathbb {R}\rightarrow \mathbb {R}\) such that

$$\begin{aligned} \sup _{\varvec{u}\in \mathbb {R}^m}[\dot{h}(\varvec{x}) + \alpha (h(\varvec{x}))] \ge 0. \end{aligned}$$
(7)

Let h be a ZCBF of \(\mathcal {C}\). If a Lipschitz continuous controller \(\varvec{u}\) satisfies the inequality (8) any time, then set \(\mathcal {C}\) becomes forward invariant.

$$\begin{aligned} L_fh(\varvec{x}) + L_gh(\varvec{x})\varvec{u} + \alpha (h(\varvec{x}))\ge 0, \end{aligned}$$
(8)

where \(L_f\) and \(L_g\) are the Lie derivatives along f and g. There exists an example of the input satisfying constraint (8) with an equal sign.

$$\begin{aligned} \varvec{u}=-\frac{L_fh(\varvec{x})+\alpha (h(\varvec{x}))}{\Vert L_gh(\varvec{x})\Vert ^2}L_gh(\varvec{x})^\mathsf {T} \end{aligned}$$

If we describe the safety condition as \(h(\varvec{x})\ge 0\) and select the control input \(\varvec{u}\) to satisfy constraint (8), then \(\varvec{x}(t_0)\in \mathcal {C}\Rightarrow \varvec{x}(t)\in \mathcal {C}\,\forall t\ge 0\) is guaranteed (the relative degree of u and h is required to be 1). In the remainder of the paper, we simply refer to the input constraint method by ZCBF as the CBF method.

3.2 Implementation of control barrier function to the base model

We introduce CBF constraints for our swarm system. We apply the CBF to robots in decentralized manner. Let us discuss the implementation of CBF from the perspective of agent i. We consider the constraint for collision avoidance with agent j, included in the set of neighbors of robot i, \(\mathcal {N}_i\). Let \(T_c\) be the control period and \(\varvec{q} = [\varvec{q}_1^\mathsf {T}, \varvec{q}_2^\mathsf {T}]^\mathsf {T} = [\varvec{x}_{ij}^\mathsf {T}, \dot{\varvec{x}}_{ij}^\mathsf {T}]^\mathsf {T}\in \mathbb {R}^4\). We define the safety function \(h(\varvec{q})\) between agents i and j as follows,

$$\begin{aligned} h(\varvec{q}) = \Vert \varvec{q}_1\Vert + \varvec{q}_2^\mathsf {T}\frac{\varvec{q}_1}{\Vert \varvec{q}_1\Vert }T_c -r_s, \end{aligned}$$
(9)

where \(r_s\) is the minimum, safe distance, \(h(\varvec{q})\) is the safety condition between the two agents. If \(h(\varvec{q})\ge 0\), the distance between robot i and j is larger than \(r_s\) considering the movement of \(\varvec{q}_2\) during the control period \(T_c\). From each agent’s system (1), \(\varvec{q}\) follows (10),

$$\begin{aligned} \dot{\varvec{q}} = f(\varvec{q}) + g(\varvec{q})(\varvec{u}_j-\varvec{u}_i), \end{aligned}$$
(10)

where

$$\begin{aligned} f(\varvec{q}) = \left( \varvec{q}_2^\mathsf {T},-\frac{\eta }{m}\varvec{q}_2^\mathsf {T}\right) ^\mathsf {T},\ g(\varvec{q}) = \left( \begin{array}{cccc}0&{}0&{}\frac{1}{m}&{}0\\ 0&{}0&{}0&{}\frac{1}{m} \end{array}\right) ^\mathsf {T}. \end{aligned}$$

We derive the condition for \(\varvec{u}\in \mathbb {R}^2\) to maintain \(h(\varvec{q})\ge 0\) using the CBF method. From (9) and (10), the input constraints between agents corresponding to (8) can be written as follows:

$$\begin{aligned} L_fh(\varvec{q}) + L_gh(\varvec{q})(\varvec{u}_j-\varvec{u}_i) + \gamma h(\varvec{q})\ge 0. \end{aligned}$$
(11)

\(\gamma > 0\) is a parameter that denotes the naivety of the constraint. If \(\gamma \) is small, robots are required to slow down earlier, and a large \(\gamma \) implies sudden stop**. Since in our decentralized assumption, agent i does not know the input \(\varvec{u}_{j}\), we divide constraint (11) to attribute to each agent as follows:

$$\begin{aligned} L_fh(\varvec{q}) -2L_gh(\varvec{q})\varvec{u}_i + \gamma h(\varvec{q})\ge 0, \end{aligned}$$
(12)
$$\begin{aligned} L_fh(\varvec{q}) -2(-L_gh)(\varvec{q})\varvec{u}_j + \gamma h(\varvec{q})\ge 0. \end{aligned}$$
(13)

Decentralized constraints (12) and (13) for robots i and j are sufficient conditions for constraint (11).

Because we consider the perspective of i, the signs of the second terms of (12) and (13) are different. When we consider the perspective of robot j (\(\varvec{q} = [\varvec{x}_{ji}^\mathsf {T}, \dot{\varvec{x}}_{ji}^\mathsf {T}]^\mathsf {T})\), (13) attains the same form as (12). Agent i has the same constraints as in (12) with all agents included in \(\mathcal {N}_i\).

We construct raw control input \(\hat{\varvec{u}_i}\) as

$$\begin{aligned} \hat{\varvec{u}}_i = \varvec{f}_i^P + \varvec{f}_i^F. \end{aligned}$$
(14)

When we compare (14) with (2), \(\varvec{f}_i^O\) is replaced by the CBF constraints because this force only denotes the collision avoidance constraint. \(\varvec{f}_i^F\) is also a constraint term but this term is needed to gather the robots as a swarm. Finally, we determine the control input of the robot using the quad program as

$$\begin{aligned} \begin{aligned} \varvec{u}_i&= \mathop \mathrm{arg~min}\limits _{\varvec{u}_i\in \mathbb {R}^2}\frac{1}{2}\left| \left| \varvec{u}_i-\hat{\varvec{u}}_i\right| \right| ^2\\&\mathrm{s.t.}\, L_fh(\varvec{q})-2L_gh(\varvec{q})\varvec{u}_i+\gamma h(\varvec{q})\ge 0\ \forall j\in \mathcal {N}_i. \end{aligned} \end{aligned}$$
(15)

3.3 Analysis of swarm system with CBF constraint

In this section, we discuss the behavior of the swarm system with CBF. To simplify the discussion, we assume that the constraints between a pair of robots can be addressed using a one-dimensional line in the relative direction. Under this assumption, the constraint function \(h(\varvec{q})\) can be rewritten as follows:

$$\begin{aligned} h(\varvec{q}) = \varvec{q}_1 + T_c\varvec{q}_2. \end{aligned}$$
(16)

Note that we assume that \(r_s=0\). If the control inputs \(\varvec{u}\) of the robots satisfy constraint (12), then \(\varvec{x}_{ij}\) satisfies the following inequality:

$$\begin{aligned} \ddot{\varvec{x}}_{ij} + \left( \frac{1}{T_c} + \gamma \right) \dot{\varvec{x}}_{ij} + \frac{\gamma }{T_c}\varvec{x}_{ij} \ge 0. \end{aligned}$$
(17)

Suppose that an equal sign holds, that is, when the input reflects the constraints of CBF, the frequency domain of (17) is as follows:

$$\begin{aligned} G_{cbf}(s) = \frac{1}{\left( s+\frac{1}{T_c}\right) (s+\gamma )}. \end{aligned}$$
(18)

This is a simple second-order low-passage system with poles \(-\frac{1}{T_c}\) and \(-\gamma \). The control period \(T_c\) is a parameter of a system. Therefore, we can design the frequency property of CBF by tuning \(\gamma \) considering \(T_c\). For example, a small \(\gamma \) cancels out the characteristics of the original system in the low-frequency region, while a larger \(\gamma \) is expected to preserve it to the possible extent. It should be noted that if we set an exceedingly large \(\gamma \), the system can become unstable owing to the discretization by the control period.

As the CBF system (17) represents a local system between a pair of robots, we need to discuss the behavior of the entire system.

Fig. 1
figure 1

Deformation property of swarm.(\(n=8\))

Consider a swarm composed of eight robots as indicated in Fig. 1. Suppose the left 4 and right 4 robots are subgroups in the swarm. Let \(x_i\) be an x position of a robot i, then \(\xi \) represents the distance between the center positions of the subgroups.

$$\begin{aligned} \xi = \frac{1}{n}[1,\dots ,1,-1,\dots ,-1](x_1,x_2,\dots ,x_8)^{\mathsf {T}}. \end{aligned}$$

We assume that we can observe the deformation level of the swarm along the x-axis by \(\xi \). The constrained inputs of each robot are only the internal forces in both left and right subgroups that cancel out. Behaviors (17) between robots belonging to different subgroups (marked as the red edge in Fig.1) directly affect the behavior of \(\xi \). Thus, the deformation property \(\xi \) follows a simple summation of (17). The deformation along y-axis can be explained in the same manner. Since we believe that analysis can be generalized, we assume that system (17) works over the entire swarm.

3.4 Investigating deformability by extra periodic forces

We apply a periodic external force and examine the aspect ratio to investigate the deformability of the system. Suppose an attractant field \(c(\varvec{x})\) is given as follows,

$$\begin{aligned} c(\varvec{x}) = A\cos \left( \frac{2\pi }{\lambda }x\right) \sin \left( \frac{2\pi }{T_{f}}t\right) . \end{aligned}$$
(19)

where A is constant and \(T_f\) denotes the period of external force.

Using the maximum distance \(l_x(t), l_y(t)\). Then, we define an aspect ratio of a swarm as \(\rho (t) := l_y(t)/l_x(t)\).

Let \(\rho _{T_f}\) be a response of the aspect ratio against an external force with period \(T_f\).

$$\begin{aligned} \rho _{T_f} := \max _{t\in \mathcal {T}}[\rho (t)]-\min _{t\in \mathcal {T}}[\rho (t)], \end{aligned}$$
(20)

where observation range \(\mathcal {T}=[T_o-\frac{T_f}{2}, T_o + \frac{T_f}{2}]\) and \(\rho _{T_f}\) is the oscillation gain in response to external periodic forces.

We obtain a frequency response curve by observing \(\rho _{T_f}\) with varying \(T_f\). By comparing the response curves for various \(\gamma \), it is possible to compare the change in the frequency response of the aspect ratio with the changes in the CBF parameter.

4 Simulation of collision avoidance and deformability

We performed computer simulations in three different cases to verify the generalizability of our method in terms of the number of robots, the initial shape of a swarm, and the parameters of the base model.

  • Case 1 : 20 robots, square shape (Fig.2(a)) and \(\eta =20\).

  • Case 2 : 36 robots, rectangular shape (Fig.2(b)) and \(\eta =20\).

  • Case 3 : 20 robots, square shape (Fig.2(a)) and \(\eta =5\).

The control period was set as \(T_c = 0.02\) s. We applied \(\gamma =0.1,\ 0.5,\ 1.0,\ 5.0,\ 10,\ 20\) and 100 for each case. Table 1 shows the other parameters we used. The simulations were performed by MATLAB R2020a. We used the quadprog function in the optimization toolbox to solve the quad program (15) of CBF. We carried out 20 trials for each condition, where we applied random perturbations (\(\pm 0.1\)m) to the initial positions of the robots. The plots in Figs.5,6, and 7 show the average of the results.

Fig. 2
figure 2

Types of swarm shape in simulation

Table 1 Simulation parameters

Results of Case 1

Fig. 3
figure 3

Time change of minimum distance (\(T_f = 8\) s). Green line denotes safety distance to keep. The figure on the right is an zoomed version of the left one

First, we verified whether the safety distance was guaranteed by CBF. Fig.3 shows the minimum distance among robots when we imposed the external periodic force (\(T_f = 8\) s). The horizontal green line indicates the safe distance we set. The dashed curve colored with sky blue, which indicates the result without CBF, violated the safe distance. In the contrast, the other curves showing results with CBF almost maintain longer distances than the safe distance.

However, as mentioned in 3.3, when \(\gamma \) is quite large (\(\gamma =100\), the deep blue curve), the minimum distance fluctuated near the boundary and invaded the safe distance.

Fig. 4
figure 4

Time change of aspect ratio \(\rho (t)\). (a) and (b) are \(T_f = 0.5\) s and \(T_f = 2\) s

Next, we observed the frequency response, as the measure of the deformability to external periodic forces. Fig.4 shows the changes of the aspect ratio of the whole shape of the swarm. We applied two frequencies, \(T_f=0.5\)s and 2.0s, respectively. The black curve shows the original responses without CBF. When we applied CBF with \(\gamma <1\), the curves show different results from the original ones, where the initial aspect ratios were not maintained. On the other hand, when we set \(\gamma \ge 1\), the responses with CBF were almost the same as the original responses, where the initial aspect ratios were kept under the external forces.

Fig. 5
figure 5

Frequency response of aspect ratio change (20 robots, \(\eta = 20\))

We also observed the frequency responses of the aspect ratio. Fig.5 clearly shows that the results of the cases with \(\gamma <1\) had significantly different shapes of the curves from those of other cases. However, the original system had a peak at approximately 1 rad/s; \(\gamma <1\) cases did not.

This results can be explained as follows. CBF affects the frequency responses of aspect ratio of a whole swarm as a low-pass filter (18). One breakpoint frequency is \(\gamma \) rad/s. If we set \(\gamma <1\), CBF changes frequency responses by canceling the original one with a peak frequency at 1 rad/s. On the other hand, if we set \(\gamma >1\), CBF does not affect the peak frequency. In this case, the frequency responses is maintained the same as the non-CBF case.

According to the results, we conclude that we should set \(1<\gamma <100\) so that a swarm with CBF keeps its original property against external forces and avoids collision.

Results of Case 2

Fig. 6
figure 6

Frequency response of aspect ratio change (36 robots, \(\eta = 5\))

We increased the number of robots and changed the initial shape of the swarm. Fig. 6 shows the frequency responses. Almost the as with Case 1, the response curves of \(\gamma \ge 1\) were almost the same as the original one, yet those of \(\gamma <1\) looked different. This result verifies that the effects of the CBF on the frequency responses are the same even if the number of robots and initial shape changes.

Results of Case 3

Fig. 7
figure 7

Frequency response of aspect ratio change (20 robots, \(\eta = 5\))

We changed the viscosity of the robots from \(\eta =20\) to \(\eta = 5\). Fig. 7 shows the frequency responses. The characteristic waveform of the original system (without CBF) moved to a higher frequency, approximately at 2 rad/s. In case 3, \(\gamma <2\) resulted in different shapes of the response curves from the original one, yet \(\gamma <1\) did in Case 1 and 2.

In Case 3, as in Cases 1 and 2, we can design the CBF that maintains the frequency responses by choosing the \(\gamma \) larger than the peak frequency of the original responses (2 rad/s). Therefore, the design for the range of \(\gamma \) applies even when parameters in the robot model, such as viscosity \(\eta \), changes.

According to the simulation results in Case 1, 2, and 3, we verified that the proposed method surely kept the safe distance and the original property of the frequency response to the external forces. However, it must be noted that the design of the parameter \(\gamma \) is crucial. When the mass m or viscosity \(\eta \) in the robot model gets smaller, the peak frequency of the original system is increase. It requires a larger lower limit of \(\gamma \).

When the control period \(T_c\) is larger, upper limit of the \(\gamma \) decreases to avoid vibration and guarantee collision-freeness. The range of feasible \(\gamma \) depends the parameters of the robot model. We need to pay attention to design \(\gamma \) to achieve both collision-freeness and deformability.

5 Conclusions

In this study, we implemented the CBF to a robotic swarm that is composed of autonomous mobile robots. Although CBF theoretically guarantees collision-freeness, it can limit the motion of the robots. This reduces the deformability of the entire shape of the swarm. Deformability is quite important for adaptive behaviors in obstacle regions. By analyzing the response of the original system and the CBF system, we can obtain a feasible range of a parameter that facilitate the retention of the original deformability while guaranteeing safe distance. Through verifications by the simulations, we believe that the results contribute to the designing of appropriate constraints in swarm models.

In future, we will investigate the influence of inequality constraints, such as CBF, on the swarm in the performance of actual tasks. When the robots are dense (distances among robots are small), the CBF constraints for collision avoidance become more severe. In such a case, the decentralized constraints in this paper do not guarantee the existence of a quadratic programming solution. It is necessary to modify the method to decentralize the CBF constraints.