1 Introduction

Ubi-Com includes advanced mobile applications and interactive communication services on mobile devices to provide computing and communication services at anytime and anywhere. Here we focus on the interactive mobile node applications in formation flocking fields. The control and coordination of mobile nodes in groups is a widely studied topic in distributed system. Nodes are used to relieve humans of tasks that are included in the following four aspects: dirty, dull, dangerous or difficult [6, 1317]. It is much like man that has always developed technology to save time for other more challenging tasks, now the time has come for coordination nodes. Mobile nodes cooperating in groups offer several advantages, e.g., redundancy and flexibility, and can sometimes perform tasks that would be impossible for one single node [2, 3, 5, 7]. Recent advances in distributed system have started making it feasible to deploy large numbers of inexpensive nodes for tasks such as surveillance and search. However, coordination motion of multiple nodes in a plane to accomplish such tasks remains a challenging problem.

In this paper, we study the flocking problem, where there are two kinds of nodes: the leader and the follower. The leader acts independently of the others, and we can assume that it is driven by a human pilot or supervisor. Every follower can distinguish the leader from the other followers. And the followers are required to follow the leader wherever it goes (following), and stay in a formation they are given in input (flocking). In this context, a formation is simply a pattern described as a set of points in the plane. And all the nodes have the same formation in input. There are several applications for flocking of a group of nodes, such as in military [8], or in factories, where nodes can be asked to move heavy loads [4].

Although many papers have addressed the flocking problem, few studies have focused on the efficiency of the algorithm [18, 19]. To this question, this paper presents a novel scheme to obtain the shortest distance and the shortest time to finish the formation and move in some pattern. Simulation results further demonstrate that this can solve the flocking of a group of autonomous mobile nodes quickly.

The remainder of the paper is organized as follows: Section 2 discusses more work related to flocking problem. In Section 3, the system model and basic concepts are defined. Section 4 presents the novel flocking algorithm. In Section 5, we evaluate the performance of the proposed algorithm. Finally, we conclude our work and discuss further work in Section 6.

2 Related work

In order to design and evaluate the solutions of flocking, the approach usually adopted is to design solutions based on heuristics and tailored to the capabilities of the nodes employed, and then test the solutions by computer simulations, or on real nodes.

For instance, experiments in [9] were conducted on a team of simple mobile units in order to produce complex behaviors, by compounding basic ones. For example, safe-wandering, i.e., the ability to avoid collisions while moving; dispersion, i.e., the ability of the nodes to spread out over an area; aggregation, i.e., the ability to gather; and gathering, i.e., the ability to reach a predetermined destination, and so on. In particular, the author points out that flocking can be obtained by combining safe-wandering, aggregation, dispersion, and gathering.

T. Balch and C. Arkin studied formation and navigation problems in a team of multi-nodes. In particular, in [10] the problem of specifying the behavior for the navigation of a mobile unit is analyzed, and results of both computer simulation and real experimentation are reported. In [8], the approach is extended to multi-node teams that navigate the environment maintaining particular formations: in particular the cases of a line, column, diamond and wedge are examined. In their study, the authors assumed that the path along which the group of nodes had to move was known in advance to every unit.

In [11], this paper gives architecture for autonomous mobile robot nodes. The architecture is composed of three levels: control, functional, and planner levels. The control and functional levels manage robot node resources, while the planner level carries out complex operations such as planning and cooperation. The nodes were asked to move in a matrix shape along a path represented by a straight line followed by a right turn and then a straight line again. In contrast, in this paper we do not assume any knowledge by the followers of the path that the leader will follow. The followers have only a common description of the formation they have to keep while moving.

A similar problem is studied in [12], where the author derives equations describing navigational strategies for nodes moving in formation, and following the movement described by one (or more) leader. In the studied framework, the nodes have identities, hence their positions in the formation are fixed. Moreover, in order for the i th node to compute its position at time t, it has to know the position of either the (i − 1)th node or the leader at time t. Hence, some degree of synchrony has to be introduced in order to implement these strategies.

In [1], an algorithm solving this problem has been tested by using computer simulation; the algorithm assumes no agreement. All the experiments demonstrated that the algorithm performed well, and in all cases the followers were able to assume the desired formation and to maintain it while following the leader along its route. Moreover, the oblivious of the nodes in the algorithm contributes to the result, since the followers do not base their computation on leader’s past positions. Unfortunately, in all the above papers, there is no consideration about the speed, i.e., how fast the followers can follow the leader to form into a certain pattern.

In paper [20], the authors proposed a self-organizing framework for small-scale, distributed mobile node teams, which can adjust their formation to adapt to a variety of circumstances. In that paper, they assumed every node to be a point of a local coordinate system. By dividing the sum of all points by the number of members, they could obtain a center point for a team. This center point is called a common origin. Therefore, the authors implicitly assume all the nodes are synchronous. Because if the nodes are asynchronous, the common origin may not be the same once some nodes have moved.

The papers [21, 22] tried to solve the weakness in the leader-follower model, i.e., when the leader is dead, how to select a unique leader. The contributions in these papers are to move some nodes, in order to find the unique furthest one from the new average position of all nodes as their leader. But, when the scale of a swarm of nodes becomes very large, the worst case may appear that there exist many leaders at any time, and no unique leader can be found in finite time.

With emphasis on its reliability, a node formation control scheme based on a vision-based follow-the-leader scenario is proposed in [23]. Perception is enhanced by the control a pan-tilt-zoom camera, which gives the follower nodes a large field of view and improvements of leader detection. Furthermore, the authors also proposed bidirectional and non-oblivious node control based on the use of iodometry to detection outliers in the follower vision-based position estimation, and the leader’s path planning is took into account visibility constraints.

This paper [24] proposed that a group of autonomous mobile agents can asymptotically exhibit stable flocking behavior, where every agent is steered using local state information from its nearest neighbors. Under the assumption that the graph representing agent interconnections remains connected at all times, the authors showed a set of control laws that guarantee flocking asymptotically.

In [25], the authors proposed a leaderless distributed flocking algorithm, which is more conducive in implementation on embodied agents than the established algorithms, which are used in computer animation. The combined problems of obstacle avoidance, navigation towards a goal point and flocking become very difficult for the following two reasons: First, there is often a tradeoff in the three sub-goals of safety, reaching the goal point, and group cohesion. Second, the choice of obstacle representation is difficult and is far from obvious. The authors in [26] addressed the tradeoff by assigning the sub-goals as constraints and cost function in an optimization problem. They used subsets of the configuration space for both obstacles and neighboring nodes to solve the second problem. The vehicle subsets and control actions were derived from Voronoi partitions, navigation functions and mirror neighbors.

3 System model

We study the distributed coordination and control of a set of asynchronous, anonymous, memory-less mobile nodes that can freely move on the two-dimensional plane, and the leader can communicate with the followers. In particular, we study the flocking problem, i.e., to form a certain pattern and follow a designated node, the leader, while maintaining the pattern. And, we assume all the nodes are viewed as points, that is, the size of the node is not considered. The nodes can not communicate with each other (see Fig. 1).

Fig. 1
figure 1

A basic mobile node model for directed targets [4]

The nodes unit have simple computational capabilities. They are equipped with sensors that let all nodes observe the positions of the leader of the flock. All nodes are able to observe their surroundings, computing a destination based on what they observed, and moving towards the computed destination; hence they performs an (endless) cycle of observing, computing, and moving [4].

All mobile nodes have their own local view of the world. This view includes a local Cartesian coordinate system having an origin,Footnote 1 a unit of length, and the directions of two coordinate axes,Footnote 2 together with their orientations, identified as the positive and negative axes. In general, there is no agreement among the followers on the properties of the local coordinate systems (i.e., the nodes have different concepts of where North, East, South, and West are) [4].

4 The new flocking algorithm

In detail, we consider the basic node model for directed targets as shown in Fig. 1 (directed wedge formation). Notice that, there are n multiple followers (F 1, F 2, ⋯, F i , ⋯, F n ), one leader (L), and a certain directed target pattern. The follower F i will get the target T i and then follow the leader L.

We use the relative motion theory of motion of objects to solve the cooperative flocking of the mobile nodes. We assume that every node has its own coordinates in the plane. In order to make all the followers approach the leader as soon as possible, each follower follows its leader at its maximum available velocity (v max ) before reaching its target. Each node can observe using its own compass, compute and move.

The follower node can get its relative velocity to the leader by the equation:

$$ v= \delta S / \delta t $$

where δS is the difference of the distance between the follower and the leader during the period δt. And the orientation of the velocity can be gotten by the follower’s own compass.

In order to further describe our algorithm, we assume the variables in Table 1.

Table 1 Parameter description

Among these variables, v L , v F and v max are the vectors. Based on the relative motion theory, if we assume the leader is a reference object, i.e., the leader is still, then the follower node F will have a velocity |v L |, and the direction of relative velocity of the follower is opposite to the velocity of the leader L, v L . In details, we discuss the motion of the followers in the following two cases based on the angle α between the vector v L and the vector \(\overrightarrow{FT}\).

4.1 Case 1: α = 0 or π

When the direction of the leader’s velocity v L is parallel with the line \(\overrightarrow{FT}\) (see Fig. 2a), the follower F moves with maximum velocity along the direction of \(\overrightarrow{FT}\), i.e., |v F | = |v max |.

Fig. 2
figure 2

The presented fast flocking algorithm: a The orientation of the leader’s velocity v L is parallel with the vector \(\overrightarrow{FT}\); b The orientation of the leader’s velocity v L is not parallel with the vector \(\overrightarrow{FT}\)

In Fig. 2a, a coordinate system can be built using the position of the follower F as the origin. Assume the coordinate of the target is (x t , y t ), then the follower F will arrive at the target in the period \({\sqrt{((x_t)^2+(y_t)^2)}}/{(|v_{max}-v_L|)}\).

4.2 Case 2: α ≠ 0 and απ

When the direction of the leader’s rate of the leader is not parallel with the line \(\overrightarrow{FT}\), i.e., there is an acute angle or an obtuse angle between − v L and the vector \(\overrightarrow{FT}\) (see Fig. 2b, i.e., for the angle \(\angle \alpha\), \(\angle \alpha \neq 0\), and \(\angle \alpha \neq \pi\)). The acute angle and the obtuse angle cases have the same analysis algorithm, here we just choose the obtuse angle case as an example.

In general, we assume that the velocity of the leader L is less than that of the followers; otherwise, the followers cannot follow the leader, i.e., |v L | < min{|v F1|, |v F2|, ⋯, |v Fn | } [1]. The motion target of the follower F is to arrive at the target position T that is near the leader, and to form some formation.

In order to describe the algorithm, we build the coordinate system as shown in Fig. 3, and we assume that the coordinates of the leader is L(x l , y l ), while the follower F is the origin of the coordinate system. The target coordinates of the follower F is T(x t , y t ).

Fig. 3
figure 3

The navigation track of two followers and the leader. Here before the two followers reach targets, the leader doesn’t change direction (ac)

Therefore, we can get the function of the line \(\overrightarrow{FT}\):

$$\label{eq1} y = \frac{y_t}{x_t} \cdot x. $$
(1)

The detailed description is as follows:

Based on the above coordinate system, we can construct a circle, where the center of the circle is F, and the radius is the velocity |v F | (here we choose the maximum velocity for the node to let the node reach the target T as soon as possible, i.e., |v F  = v max |). Then one gets the function of the circle C:

$$\label{eq2} x^2 +y^2 = |v_{F}|^2. $$
(2)

If the follower F can reach the target T, then the sum vector of vectors v F and − v L must have the same direction as the vector \(\overrightarrow{FT}\). So we assume that there is a point B (x b , y b ), where \(\overrightarrow{FB}=v_F + (-v_L)\). Then B must be in the beeline FT described by Function (1). So

$$\label{eq3} y_b = \frac{y_t}{x_t} \cdot x_b. $$
(3)

Based on the point B, we draw vector \(\overrightarrow{AB}\), where point A (x a , y a ) is in the circle (Eq. 2) and \(\overrightarrow{AB}\) has the same direction as vector − v L . So

$$\label{eq4} {x_a}^2 +{y_a}^2 = |v_{F}|^2. $$
(4)

If \(|\overrightarrow{AB}|\) = |( − v L )|, i.e.,

$$\label{eq5} \sqrt{{(x_b-x_a)}^2 +{(y_b-y_a)}^2} = |v_{L}|. $$
(5)

Then we can get \(\overrightarrow{AB}=-v_L\), i.e.,

$$\label{eq6} v_{F} +(-v_L) = \overrightarrow{FB}. $$
(6)

Therefore, the follower F moves with the maximum velocity along \(\overrightarrow{FA}\). And it will spend time \(|\overline{FT}|/|v_{F} +(-v_L)|\) to reach the target T.

Furthermore, \(\overrightarrow{AB}\) ∥ ( − v L ), and − v L is in the line axis x, so

$$\label{eq7} y_a=y_b. $$
(7)

From Eqs. 5 and 7, we can obtain

$$\label{eq8} {(x_b-x_a)}^2 = |v_{L}|^2. $$
(8)

The angle \(\angle \alpha\) is an obtuse angle, so y a  = y b  > 0, x a  > x b  > 0. Then from Eq. 8, we can obtain

$$\label{eq9} {x_a}= x_b + |v_{L}|. $$
(9)

Substitute y b of Function (3) into Function (4), and y a  = y b , one has

$$\label{eq10} {x_a}^2 +\left(\frac{y_t}{x_t}\right)^2 \cdot {x_b}^2 = |v_{F}|^2. $$
(10)

Substitute x a of Function (9) into Function (10) and obtain:

$$\label{eq11} {(x_b + |v_L|)}^2 +\left(\frac{y_t}{x_t}\right)^2 \cdot {x_b}^2 = |v_{F}|^2, $$
(11)

i.e.,

$$\label{eq12} \left(1+\frac{{y_t}^2}{{x_t}^2}\right) \cdot {x_b}^2 + 2 \cdot |v_L|\cdot x_b + |v_{L}|^2 - |v_{F}|^2 = 0. $$
(12)

For the unknown parameter x b in Eq. 12, the discriminant ∆ is

$$\label{eq13} \bigtriangleup = 4\cdot |v_L|^2 + 4 \cdot\left(1+\frac{{y_t}^2}{{x_t}^2}\right) \cdot ( |v_{F}|^2 - |v_{L}|^2) $$
(13)

Since \(|v_{L}|^2 < |v_{F}|^2\), then ∆ > 0. Then

$$\label{eq14} x_b\!=\!\frac{-2|v_{L}| \pm \sqrt{4\cdot |v_L|^2 + 4 \cdot\left(1+\frac{{y_t}^2}{{x_t}^2}\right) \cdot ( |v_{F}|^2 - |v_{L}|^2)}}{2\left(1+\frac{{y_t}^2}{{x_t}^2}\right)} $$
(14)

For

$$\label{eq15}4\cdot |v_L|^2 + 4 \cdot\left(1+\frac{{y_t}^2}{{x_t}^2}\right) \cdot ( |v_{F}|^2 - |v_{L}|^2) > 4\cdot |v_L|^2, $$
(15)

then

$$\label{eq16}\sqrt{ 4\cdot |v_L|^2 + 4 \cdot\left(1+\frac{{y_t}^2}{{x_t}^2}\right) \cdot ( |v_{F}|^2 - |v_{L}|^2)} > 2\cdot |v_L|. $$
(16)

Furthermore, since x b  > 0, then

$$\label{eq17} x_b=\frac{-{x_t}^2 |v_{L}| + {x_t} \sqrt{{x_t}^2 |v_F|^2 + {y_t}^2 ( |v_{F}|^2 - |v_{L}|^2)}}{{y_t}^2 + {x_t}^2}. $$
(17)

Substitute x b of Eq. 17 into Eq. 9 and obtain:

$$\label{eq18} x_a= |v_L|+\displaystyle \frac{-{x_t}^2 \cdot |v_{L}| \!+\! {x_t} \cdot \sqrt{{x_t}^2 \cdot |v_F|^2 \!+ \!{y_t}^2 \cdot ( |v_{F}|^2\! -\! |v_{L}|^2)}}{{y_t}^2 + {x_t}^2}, $$
(18)

i.e.,

$$\label{eq19} x_a= \frac{{y_t}^2 \cdot |v_{L}| + {x_t} \cdot \sqrt{{x_t}^2 \cdot |v_F|^2 + {y_t}^2 \cdot ( |v_{F}|^2 - |v_{L}|^2)}}{{y_t}^2 + {x_t}^2}. $$
(19)

Substitute x b of Eq. 17 into Eq. 3, and y a  = y b , then we can obtain

$$ \begin{array}{lll}\label{eq20} y_a&\!=\!&y_b \\ &\!=\!& \displaystyle \frac{-{x_t} y_t \cdot |v_{L}| \!+ \! y_t \cdot \sqrt{{x_t}^2 \cdot |v_F|^2 + {y_t}^2 \cdot ( |v_{F}|^2 - |v_{L}|^2)}}{{y_t}^2 + {x_t}^2}.\\ \end{array} $$
(20)

Based on the above analysis, the follower F moves with maximum velocity along the direction \(\overrightarrow{FA}\) with the slope arctan(y a /x a ), i.e.,

$$\label{eq21} arctan\left(\frac{-{x_t} y_t |v_{L}| + y_t \sqrt{{x_t}^2 |v_F|^2 + {y_t}^2 ( |v_{F}|^2 - |v_{L}|^2)}}{ {y_t}^2 |v_{L}| + {x_t} \sqrt{{x_t}^2 |v_F|^2 + {y_t}^2 ( |v_{F}|^2 - |v_{L}|^2)} }\right). $$
(21)

And the time to reach the target T is shown by \(|\overline{FT}|/(v_{F} +(-v_L))\) (i.e., \( \sqrt{({x_t}^2 + {y_t}^2)}/\sqrt{({x_b}^2 + {y_b}^2)}\)). Substitute x b and y b of Eqs. 17 and 20 into the above equation, and the time is

$$\label{eq22} \frac{{x_t}^2 + {y_t}^2}{ \sqrt{{x_t}^2 \cdot |v_F|^2 + {y_t}^2 \cdot ( |v_{F}|^2 - |v_{L}|^2)} -{x_t} \cdot |v_{L}| }. $$
(22)

After the follower node reaches its target, it will follow the track of the leader closely. The distance between the leader and the target of the follower F is R F . When the leader rotates at the joint rate ω, the velocity of the follower F will become (v L  + R F * ω) [1].

4.3 Analysis of the algorithm correctness

In the above algorithm, using the follower F as the origin, the coordinate system is built. So each follower has its own local coordinate system. If all followers use a public coordinate system, then the follower F has the corresponding coordinates (x f , y f ). In this case, we use a similar algorithm, and only exchange the coordinate system, i.e., using (x − x f ) and (y − y f ) instead of x, y respectively in the above analysis. Thus, this algorithm is suitable for a local coordinate system, and a public coordinate system.

The above algorithm is suited to the case that the leader has the same velocity v L before the followers arrive at the targets. Actually, the leader can change velocity sometimes. Then in that case, each node should dynamically change the corresponding relative velocity − v L , and change to the new velocity based on the above scheme. So our scheme is still suited to this dynamic case.

Theorem 1

The follower F moves along the direction of \(\overrightarrow{FT}\), and at the velocity of v max , and it will be its target by (1) the shortest distance and (2) the least time.

Proof

  1. (1)

    The follower F moves along the direction of \(\overrightarrow{FT}\), which is the shortest path to arrive at its target. Based on the geometric theorem, the line segment \(\overrightarrow{FT}\) is the shortest path between two points F and T. Here we assume the length of the line segment \(\overline{FT}\) is s least , where \(s_{least} = \sqrt{(y_F - y_t)^2 + (x_F -x_t)^2}\), here, (x f , y f ) are the coordinates of the follower F.

  2. (2)

    In order to save time, the follower F will move as fast as it can, i.e., at the maximum rate of v L . Based on the equation of velocity, the time t = s/v, where s is the distance between the follower and its target, and v is the velocity of the follower node. Therefore, we can get the least time s least /|v F  − v L | to reach its target.

From the above analysis, we arrive at the conclusion that in this scheme the follower node can follow the leader and form a pattern with the shortest path and the least time. And using the same method, all the followers can eventually follow the leader with some predefined pattern. □

5 Performance evaluation

To evaluate the performance of the proposed solution of flocking, we focus on the following parameters: path length, and moving time. We assume that the time, which the nodes move at a certain velocity, is dominant compared to the acceleration period.

Our method is inherently highly flexible in the kinds of geometric formations that can be maintained. Here we give a representative example, where there are two followers and one leader, and the two target sites of the followers are both sides of the leader to form a line formation, and each one is 10 cm distant from the leader. The simulation model is similar to Fig. 1. The line connecting the two targets is vertical with the direction of the leader rate, and all the nodes use the public coordinate system. The initial place for the two followers and the leader are (1, 4), (2, − 4), and ( − 1, 0) respectively. The maximum available velocity for the followers are the same 20 cm/s, and the leader’s velocity are 10 cm/s, while direction can be changed freely.

We divide the simulation into two kinds of cases based on whether the leader changes direction before the two followers reach targets. The simulation results are shown in Figs. 3 and 4.

Fig. 4
figure 4

The navigation track of two followers and the leader. Here before the two followers reach targets, the leader has changed direction (ac)

In Fig. 3, before the two followers reach targets, the velocity of the leader doesn’t change. With the change of the simulation time, Fig. 3a, b and c show the navigation track of two followers and the leader for 1.5 s, 3 s, and 8 s, respectively. In every sub-figure, the circles mean the initial positions of the two followers and the leader. The arrowhead means the position for a mobile node at the end of the simulation time. From the simulation results, we find that Follower 1 spent \((\sqrt{52}-1)/3\) s to reach the target \(((\sqrt{52}-1)/3, 0)\), and Follower 2 spent \((\sqrt{28}-2)/3\) to reach the target \(((\sqrt{28}-2)/3, -2)\). After that, the followers go with the leader in a formation. At 5 s, the leader changed direction, and we could find the velocity of the followers also changed to the same direction as that of the leader, then they kept in a formation.

In Fig. 4, before the two followers reach targets, the leader has changed its direction. Here Fig. 4a, b and c show the navigation track of two followers and the leader at 1.5 s , 2.1 s, and 5 s, respectively. For this case we use the same simulation setting as in the above, so we can comparatively analyze them. During the first 1.5 s period, Fig. 3 and Fig. 4 have same results. While, at the 1.5 s, the leader changed its direction. At this time, the Follower 2 has reached the target, while the Follower 1 is on the way, but did not reach the target. In this case, Follower 2 also changed its velocity to the same direction and the same velocity as the leader. While, Follower 1 re-computed the new direction based on the leader rate, then it spent about 2.08 s to reach the target (2.08, 0.58). After that, Follower 1 also changed its rate to the same direction and the same velocity as the leader. At 4 s, the leader changed its rate again. Then the two followers changed their rates accordingly, and kept in a formation.

In summary, the simulation results demonstrated that our algorithm is an efficient solution of flocking with the shortest path and time.

6 Conclusions

Ubi-Com includes advanced mobile applications and interactive communication services on mobile devices to provide computing and communication services at anytime and anywhere. This paper focuses on the interactive mobile node applications in formation flocking fields. We addressed the flocking problem of a group of mobile nodes, and presented a novel efficient scheme for node flocking. Furthermore, the extensive theoretical analysis proves that this scheme provides the follower nodes an efficient and timely method to follow the leader with the shortest path and the shortest time. The simulation results demonstrate the efficiency of the proposed algorithm. In future work, we will test this scheme with real nodes. More mobile nodes will be deployed to solve the searching and rescuing problems, while with more nodes joining, we also should consider confliction avoidance among nodes when flocking.