假設一共有 \(\mathrm{k}\) 個基站,定義 \((\mathrm{x}, \mathrm{y}, \mathrm{z})\) 為每使用k個基站解算出的標簽的位置, \(\left(A x_{k}, A y_{k}, A z_{k}\right)\) 表示第k個基站的坐標, \(d_{k}\) 表示標簽到第K個基站的測量距離。
GDOP 通過下式得出:
\[\begin{gathered} f_{\mathrm{k} 1}=\frac{\mathrm{x}-A x_{k}}{d_{k}}, f_{k 2}=\frac{\mathrm{y}-A y_{k}}{d_{k}}, f_{k 3}=\frac{\mathrm{z}-A z_{k}}{d_{k}} \\ G=\left[\begin{array}{cccc} f_{11} & f_{12} & f_{13} & 1 \\ f_{21} & f_{22} & f_{23} & 1 \\ \vdots & \vdots & & \\ f_{k 1} & f_{k 2} & f_{k 3} & 1 \end{array}\right] \\ \text { GDOP }=\sqrt{\operatorname{tr}\left(G^{T} G\right)^{-1}} \end{gathered} \]
\(\mathrm{G}\) 是距離測量值相對於位置量的偏導數構成的矩陣(Jacobian)
代碼如下:
def get_toa_gdop(bs_list, xyz):
"""
compute the gdop of the toa
:param bs_list: the base station coordinate
:param xyz: the location coordinate of the tag
:return: the gdop value
"""
bs_n = len(bs_list)
if bs_n < 3:
return None
h1 = np.mat(np.zeros((bs_n, 3)))
for i in range(0, len(bs_list)):
ri = np.sqrt((bs_list[i][0] - xyz[0]) ** 2 +
(bs_list[i][1] - xyz[1]) ** 2)
if ri == 0:
h1[i, 0] = 0
h1[i, 1] = 0
h1[i, 2] = 1
else:
h1[i, 0] = (bs_list[i][0] - xyz[0]) / ri
h1[i, 1] = (bs_list[i][1] - xyz[1]) / ri
h1[i, 2] = 1
m_tmp = h1.T * h1
gdop_value = None
try:
g = m_tmp.I
gdop_value = np.sqrt(g[0, 0] + g[1, 1])
finally:
return gdop_value