# A Simple and Efficient Method for RSS-AOA-Based Localization with Heterogeneous Anchor Nodes
## 3 Proposed Two-Stage Localization Method
### The Second Stage  
In the second stage, the weight matrix is constructed by using the estimated variances of the LWLS equation residuals. Therefore, the variances of the residuals in (15)-(17) are first estimated.  
To estimate the variance of the residual for each item in Equations (15)-(17), we can express all RSS-AOA time series measurements in the form of \(NT\) equations as follows:  
\[\hat{r}_{1 it}=\hat{\epsilon}_{it}^{\mathrm{T}}(\mathbf{x}-\mathbf{a}_{i}), \tag{21}\]  
\[\hat{r}_{2 it}=(\cos\hat{\alpha}_{i}\hat{\mathbf{u}}_{it}-\mathbf{k})^{\mathrm{T}}(\mathbf{x }-\mathbf{a}_{i}), \tag{22}\]  
\[\hat{r}_{3 it}=\tilde{\lambda}_{ij}\hat{\mathbf{u}}_{it}^{\mathrm{T}}(\mathbf{x}-\mathbf{a}_ {i})-\beta, \tag{23}\]  
where \(\hat{r}_{1 it},\hat{r}_{2 it}\), and \(\hat{r}_{3 it}\) are the residuals of (21), (22), and (23), respectively. \(\hat{\epsilon}_{ij}=[-\sin\phi_{ij},\cos\phi_{ij},0]^{\mathrm{T}}\), \(\hat{\mathbf{u}}_{ij}=[\cos\phi_{ij}\sin\alpha_{ij},\sin\phi_{ij}\sin\alpha_{ij}, \cos\alpha_{ij}]^{\mathrm{T}}\), \(\tilde{\lambda}_{ij}=10^{\frac{\hat{r}_{ij}}{\hat{r}_{3 it}}}\).  
The rough estimate of the target node location \(\hat{\mathbf{x}}_{\mathrm{WLS}}\) obtained in the first stage is substituted into Equations (21)-(23) to estimate the residual for each term. Then, we obtain the estimated residuals as  
\[\hat{r}_{1 it}=\hat{\epsilon}_{it}^{\mathrm{T}}(\hat{\mathbf{x}}_{\mathrm{WLS}}-\bm {a}_{i}), \tag{24}\]  
\[\hat{r}_{2 it}=(\cos\hat{\alpha}_{i}\hat{\mathbf{u}}_{it}-\mathbf{k})^{\mathrm{T}}(\hat {\mathbf{x}}_{\mathrm{WLS}}-\mathbf{a}_{i}), \tag{25}\]  
\[\hat{r}_{3 it}=\tilde{\lambda}_{ij}\hat{\mathbf{u}}_{it}^{\mathrm{T}}(\hat{\mathbf{x}}_ {\mathrm{WLS}}-\mathbf{a}_{i})-\beta. \tag{26}\]  
Then, the estimated variances of the residuals in (15)-(17) are calculated as follows:  
\[\hat{\sigma}_{r_{1i}}^{2}=\frac{1}{T}\sum_{t=1}^{T}\hat{r}_{1 it}, \tag{27}\]  
\[\hat{\sigma}_{r_{2i}}^{2}=\frac{1}{T}\sum_{t=1}^{T}\hat{r}_{2 it}, \tag{28}\]  
The matrix form of the ML estimation is written as  
\[\hat{\mathbf{x}}_{\text{ML}}=\arg\min_{x}\lVert\hat{\mathbf{W}}(\mathbf{A}\mathbf{x}-\mathbf{b}) \rVert^{2}, \tag{31}\]  
where \(\hat{\mathbf{W}}=\text{diag}(\frac{1}{\hat{s}_{r_{11}}},\frac{1}{\hat{s}_{r_{12}}}, \cdots,\frac{1}{\hat{s}_{r_{11}}},\frac{1}{\hat{s}_{r_{21}}},\cdots,\frac{1}{ \hat{s}_{r_{22}}},\frac{1}{\hat{s}_{r_{22}}},\cdots,\frac{1}{\hat{s}_{r_{23}}}, \frac{1}{\hat{s}_{r_{31}}},\frac{1}{\hat{s}_{r_{32}}},\cdots,\frac{1}{\hat{s}_{ r_{33}}})\).  
Finally, the closed-form solution of the estimated target localization in the second stage is obtained as  
\[\hat{\mathbf{x}}_{\text{WLS2}}=\left(\mathbf{A}^{\text{T}}\hat{\mathbf{W}}^{\text{T}}\mathbf{W} \mathbf{A}\right)^{-1}\mathbf{A}^{\text{T}}\hat{\mathbf{W}}^{\text{T}}\mathbf{W}\mathbf{b}. \tag{32}\]  
It is worth noting that the proposed algorithm can combine AOA with any signal propagation model that provides distance measurements, including ultra-wideband ranging. To adapt the algorithm, Equation (17) should be modified to \(\hat{\mathbf{u}}_{i}^{\text{T}}(\mathbf{x}-\mathbf{a}_{i})\approx d_{i}\), where \(d_{i}\) is the measured distance. Additionally, the noise modeling for Equation (17) should be updated accordingly.