# Reconfigurable Formation Control of Multi-Agents Using Virtual Linkage Approach
## 3 Formation Control: Virtual Linkage Approach
### Moving in Formation Using Virtual Linkage
#### 3.3.1 Fitting the Virtual Linkage  
A virtual linkage is made up of several cascaded virtual links, where a virtual link is an assembly of agents. In order to align the virtual linkage to a group of agents, we break the fitting process into two steps. Firstly, each virtual links' state is calculated using the corresponding group of agents. Secondly, the virtual linkage is aligned with all virtual links' states. The advantages of doing so lie in two aspects: on the one hand, there is no need to transmit all the agents' state information into a central location. On the other hand, each virtual link can calculate its individual state simultaneously which accelerates the whole fitting process. \begin{table}
\begin{tabular}{l} \hline (1). Align the virtual linkage with the current agents’ position. \\ a. Calculate each virtual links’ state with each group of agents’ position. \\ b. Align the virtual linkage with the virtual links’ state calculated from the above step. \\ (2). Move the virtual linkage to the desired position along the predefined trajectory \\ (3). Calculate individual agent’s positions to track the moving virtual linkage. \\ a. Calculate the desired state for each virtual link to track the moving linkage. \\ b. Calculate individual agent’s positions track the corresponding virtual link. \\ (4). Move the agents to the desired position using agents’ local controller. \\ (5). Go to step (1). \\ \hline \end{tabular}
\end{table} 
Table 1: Moving-in-formation algorithm using virtual linkage. Figure 8: Definition of a virtual link’s coordinate frame and virtual joint angle. Fitting the Virtual Link  
In the first step, an objective function is created to measure the fitness of the virtual link to corresponding agents. Here, the objective function proposed in [19] to fit virtual structure with a group of agents is adopted since a virtual link is a virtual structure. It is defined as the sum error between all the agents' position and its assigned point in the virtual link:  
\[f\big{(}X_{vj}\big{)}=\sum_{i\in vj}d\left({}^{w}r_{i},{}^{w}T_{vj}(X_{vj}) \cdot{}^{vj}p_{i}\right) \tag{1}\]  
where \(i\in vj\) refers to the agents belonging to the \(j\)th virtual link, and \(d\) is the distance between the agent and its assigned point in virtual link (See Figure 3). Recall that, as defined in Section 2.2, the \({}^{w}r_{i}\) is the position of the \(i\)th agent in the world coordinate frame and \({}^{vj}p_{i}\) is the assigned position of agent \(i\) in the frame of the \(j\)th virtual link. The function \({}^{w}T_{vj}\) is a transformation that maps \({}^{vj}p_{i}\) to \({}^{w}p_{i}\), the position of the \(i\)th point of the virtual linkage in the world coordinate frame. In detail, the \({}^{w}T_{vj}\) is a homogeneous transform and takes the form  
\[{}^{w}T_{vj}(X_{vj})=\left[ \begin{array}{cc}R&P\\ 0&1\end{array} \right] \tag{2}\]  
\(R\in SO(3)\) and \(P\in R^{3}\) are parameterized by the element of \(X_{vj}=\left[r_{vj},q_{vj}\right]\) which is the attitude and position of \(F^{vj}\) in the world coordinate frame. The objective of this step is to find \(X_{vj}^{*}\) which enables \(f\big{(}X_{vj}^{*}\big{)}\leq f\big{(}X_{vj}\big{)}\) for all \(X_{vj}\) and treat it as the position and attitude of the \(j\)th virtual link. B. Fitting the Virtual Linkage  
In the second step, the \"best\" position and attitude of the whole virtual linkage is required to be determined using the \(X_{vj}^{*}\) obtained from the above step. The alignment of the virtual linkage is performed by minimizing the error between calculated position and altitude of virtual links \(X_{vj}^{*}\) and their corresponding state derived from the virtual linkage. The objective function is of the form:  
\[F(X_{R})=\sum_{vj=1}^{k}D\left({}^{w}T_{vj}(X_{vj}^{*}),{}^{w}T_{R}(X_{R}) \cdot{}^{R}T_{vj}^{d}(\theta_{d})\right) \tag{3}\]  
where \(k\) is the number of the virtual links, \(D(\cdot)\) is the norm which measures the cost between the calculated state of the \(j\)th virtual links \(X_{vj}^{*}\) and its assigned state in virtual linkage.