|
@@ -9,6 +9,7 @@
|
|
|
extern COORD_T gLct_astLocationRefPoint[LCT_REF_POINT_MATRIX_LEN * LCT_REF_POINT_MATRIX_LEN]; // 定位参考点
|
|
|
extern flt32 gLct_fDelayDeviationMatrix[LCT_REF_POINT_MATRIX_LEN * LCT_REF_POINT_MATRIX_LEN]; // 定位参考点时延误差
|
|
|
extern LCT_COORDCAL_PARAM_T gg_stLctCoordcalParam;
|
|
|
+extern uint32 gLct_dwFpBaseOffset; // 第一径基础偏移量
|
|
|
|
|
|
// 二维计算
|
|
|
// pstLctBtsList:定位基站队列
|
|
@@ -234,10 +235,22 @@ void lct_coordcal_gen_location_ref_point(COORD_T stLeftBottom, COORD_T stRightTo
|
|
|
// byFirstPathFlag:第一径类型标识(0:计算径,1:跟踪径)
|
|
|
void lct_coordcal_cal_coord_points(LCT_FIRSTPATH_T *pstFirstPathList, uint8 byFirstPathListLen, COORD_T *pstLocationRefPoint, uint16 wMatrixRow, uint16 wMatrixCol, uint8 byFirstPathFlag, LCT_MINIMUM_VALUE_GROUP_T *pstMinmumValueGroup)
|
|
|
{
|
|
|
- // 计算定位参考点的时延误差
|
|
|
- lct_coordcal_cal_ref_point_delay(pstLocationRefPoint, wMatrixRow, wMatrixCol, pstFirstPathList, byFirstPathListLen, byFirstPathFlag, (flt32 *)gLct_fDelayDeviationMatrix);
|
|
|
-
|
|
|
- // 从各参考点“时延误差”中找出所有极小值点
|
|
|
+ // // 计算定位参考点的累计误差
|
|
|
+ // if (gLct_dwFpBaseOffset > 0)
|
|
|
+ // { // 已经计算出第一径基本偏移量
|
|
|
+ // // 计算参考点距离累计误差
|
|
|
+ // lct_coordcal_cal_ref_point_distance_deviation_with_toa(pstLocationRefPoint, wMatrixRow, wMatrixCol, pstFirstPathList, byFirstPathListLen, byFirstPathFlag, (flt32 *)gLct_fDelayDeviationMatrix);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // { // 尚未计算出第一径基本偏移量
|
|
|
+ // // 计算参考点“时延累计误差”
|
|
|
+ // lct_coordcal_cal_ref_point_delay_deviation_with_tdoa(pstLocationRefPoint, wMatrixRow, wMatrixCol, pstFirstPathList, byFirstPathListLen, byFirstPathFlag, (flt32 *)gLct_fDelayDeviationMatrix);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 计算定位参考点的时延累计误差
|
|
|
+ lct_coordcal_cal_ref_point_delay_deviation_with_tdoa(pstLocationRefPoint, wMatrixRow, wMatrixCol, pstFirstPathList, byFirstPathListLen, byFirstPathFlag, (flt32 *)gLct_fDelayDeviationMatrix);
|
|
|
+
|
|
|
+ // 从各参考点“误差”中找出所有极小值点
|
|
|
lct_coordcal_sel_minimum_value((flt32 *)gLct_fDelayDeviationMatrix, wMatrixRow, wMatrixCol, pstLocationRefPoint, byFirstPathFlag, pstMinmumValueGroup);
|
|
|
|
|
|
return;
|
|
@@ -252,7 +265,7 @@ void lct_coordcal_cal_coord_points(LCT_FIRSTPATH_T *pstFirstPathList, uint8 byFi
|
|
|
// byFirstPathFlag:第一径标识(0:当前径,1:跟踪径)
|
|
|
// pfDelayDeviationMatrix:各点时延误差矩阵(返回参数),行列值同输入行列参数
|
|
|
// 返回值,1:成功,0:失败
|
|
|
-void lct_coordcal_cal_ref_point_delay(COORD_T *pstRefPointMatrix, uint16 wMatrixRow, uint16 wMatrixCol, LCT_FIRSTPATH_T *pstFirstPathList, uint8 byFirstPathListLen, uint8 byFirstPathFlag, flt32 *pfDelayDeviationMatrix)
|
|
|
+void lct_coordcal_cal_ref_point_delay_deviation_with_tdoa(COORD_T *pstRefPointMatrix, uint16 wMatrixRow, uint16 wMatrixCol, LCT_FIRSTPATH_T *pstFirstPathList, uint8 byFirstPathListLen, uint8 byFirstPathFlag, flt32 *pfDelayDeviationMatrix)
|
|
|
{
|
|
|
LCT_FIRSTPATH_T stMainBts; // 主站
|
|
|
uint8 byExistFlag = 0;
|
|
@@ -367,6 +380,77 @@ void lct_coordcal_cal_ref_point_delay(COORD_T *pstRefPointMatrix, uint16 wMatrix
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+// 计算定位参考点与所有基站间的距离误差和
|
|
|
+// pstRefPointMatrix:参考点矩阵
|
|
|
+// wMatrixRow:参考点矩阵行
|
|
|
+// wMatrixCol:参考点矩阵列
|
|
|
+// pstFirstPathList:基站第一径列表,
|
|
|
+// byFirstPathListLen:基站第一径列表长度
|
|
|
+// byFirstPathFlag:第一径标识(0:当前径,1:跟踪径)
|
|
|
+// pfDelayDeviationMatrix:各点时延误差矩阵(返回参数),行列值同输入行列参数
|
|
|
+// 返回值,1:成功,0:失败
|
|
|
+void lct_coordcal_cal_ref_point_distance_deviation_with_toa(COORD_T *pstRefPointMatrix, uint16 wMatrixRow, uint16 wMatrixCol, LCT_FIRSTPATH_T *pstFirstPathList, uint8 byFirstPathListLen, uint8 byFirstPathFlag, flt32 *pfDelayDeviationMatrix)
|
|
|
+{
|
|
|
+ COORD_T stLctRefPointCoord; // 参考点坐标
|
|
|
+ uint16 wIndex = 0;
|
|
|
+
|
|
|
+ COORD_T stSlaveBtsCoord; // 从站坐标
|
|
|
+ uint32 dwSlaveBtsIndex = 0; // 从站第一径索引
|
|
|
+ flt32 fSlaveSnr = 0;
|
|
|
+
|
|
|
+ flt32 fSlaveBtsDistance = 0; // 参考点到从站的距离,单位厘米
|
|
|
+ flt32 fSlaveBtsSignalDistance = 0; // 从站信号距离
|
|
|
+
|
|
|
+ flt32 fDelayDeviation = 0; // 时延误差
|
|
|
+ flt32 fDelayDeviationSum = 0; // 时延误差累计和
|
|
|
+
|
|
|
+ // 遍历参考点矩阵,计算各点时延误差累计和
|
|
|
+ for (uint16 y = 0; y < wMatrixRow; y++)
|
|
|
+ {
|
|
|
+ for (uint16 x = 0; x < wMatrixCol; x++)
|
|
|
+ {
|
|
|
+ wIndex = y * wMatrixCol + x; // 计算矩阵索引,
|
|
|
+ stLctRefPointCoord = pstRefPointMatrix[wIndex]; // 定位参考点坐标
|
|
|
+
|
|
|
+ // 组织从站的第一径索引数据和距离数据
|
|
|
+ for (uint8 i = 0; i < byFirstPathListLen; i++)
|
|
|
+ {
|
|
|
+ // 组织从站坐标
|
|
|
+ stSlaveBtsCoord.dwX = pstFirstPathList[i].dwCoordX;
|
|
|
+ stSlaveBtsCoord.dwY = pstFirstPathList[i].dwCoordY;
|
|
|
+ stSlaveBtsCoord.dwZ = pstFirstPathList[i].dwCoordZ;
|
|
|
+
|
|
|
+ // 组织从站第一径索引
|
|
|
+ if (byFirstPathFlag <= 0)
|
|
|
+ { // 计算径
|
|
|
+ dwSlaveBtsIndex = pstFirstPathList[i].dwCalPathIndex;
|
|
|
+ fSlaveSnr = pstFirstPathList[i].fCalPathIndexSnr;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ { // 跟踪径
|
|
|
+ dwSlaveBtsIndex = pstFirstPathList[i].dwTrackPathIndex;
|
|
|
+ fSlaveSnr = pstFirstPathList[i].fTrackPathIndexSnr;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算参考定位点到从站的距离
|
|
|
+ fSlaveBtsDistance = util_distance_cal_p2p_space_distance(stLctRefPointCoord.dwX, stLctRefPointCoord.dwY, stLctRefPointCoord.dwZ, stSlaveBtsCoord.dwX, stSlaveBtsCoord.dwY, stSlaveBtsCoord.dwZ);
|
|
|
+ lct_coordcal_cal_distance_by_toa(dwSlaveBtsIndex, &fSlaveBtsSignalDistance);
|
|
|
+
|
|
|
+ // 时延误差(单位毫秒),即通过坐标计算的时延差与通过基站第一径索引计算的时延差之差
|
|
|
+ fDelayDeviation = fSlaveBtsDistance - fSlaveBtsSignalDistance;
|
|
|
+ // fDelayDeviationSum += fDelayDeviation * fDelayDeviation * fSlaveSnr;
|
|
|
+ fDelayDeviationSum += fDelayDeviation * fDelayDeviation;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存参考点到各基站间的时延误差差和(单位毫秒)
|
|
|
+ pfDelayDeviationMatrix[wIndex] = fDelayDeviationSum;
|
|
|
+ fDelayDeviationSum = 0; // 时延误差清0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
// 计算两点间传输时长,单位:微妙
|
|
|
// stFirstPoint:第1个点坐标,单位厘米
|
|
|
// stSecondPoint:第2个点坐标,单位厘米
|
|
@@ -405,6 +489,18 @@ void lct_coordcal_cal_delay_by_first_path_index(uint32 dwMainBtsIndex, uint32 dw
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+// 通过第一径索引计算两个基站间的距离差
|
|
|
+// dwMainBtsIndex:主站第一径索引
|
|
|
+// dwSlaveBtsIndex:从站第一径索引
|
|
|
+// pfTwoBtsDistance:两基站间时延(单位米)
|
|
|
+void lct_coordcal_cal_distance_by_toa(uint32 dwBtsIndex, flt32 *pfTwoBtsDistance)
|
|
|
+{
|
|
|
+ int32 dwIndexGap = dwBtsIndex - gLct_dwFpBaseOffset; // TOA值
|
|
|
+ *pfTwoBtsDistance = (dwIndexGap * PUB_AUDIO_SPEED) / (flt32)48000; // 米
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
// 选择坐标
|
|
|
// pfDelayDeviationSumMatrix:时延误差矩阵
|
|
|
// wMatrixRow:时延误差矩阵行
|
|
@@ -653,6 +749,7 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, PUB_LCT_BTS_LIST_
|
|
|
{
|
|
|
uint8 byMinimumNum = 0;
|
|
|
LCT_MINIMUM_VALUE_T *pstMiminumValueData = NULL;
|
|
|
+ uint32 dwCoordExpendLen = gg_stLctCoordcalParam.dwCoordExpendLen; // 定位基站围城的矩形框向外扩展长度
|
|
|
|
|
|
int32 dwTemp = 0;
|
|
|
int32 dwMinValueX = 2147483647;
|
|
@@ -742,7 +839,7 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, PUB_LCT_BTS_LIST_
|
|
|
dwY = pstMiminumValueData->stCoord.dwY;
|
|
|
if (dwGapY < 350)
|
|
|
{
|
|
|
- dwY = util_distance_gen_rand_num((dwMaxValueY + dwMinValueY) / 2, dwGapY / 10);
|
|
|
+ dwY = util_distance_gen_rand_num((dwMaxValueY + dwMinValueY) / 2, dwGapY / 2);
|
|
|
}
|
|
|
else if (dwGapY >= 350 && dwGapY < 900)
|
|
|
{
|
|
@@ -754,11 +851,11 @@ void lct_coordcal_dbcheck_minimum_value(uint8 byFirstPathFlag, PUB_LCT_BTS_LIST_
|
|
|
}
|
|
|
pstMiminumValueData->stCoord.dwY = dwY;
|
|
|
|
|
|
- // 再次检查坐标是否合法,极小值点要在基站围成的矩形框内部
|
|
|
- dwMinValueX -= 300;
|
|
|
- dwMaxValueX += 300;
|
|
|
- dwMinValueY -= 300;
|
|
|
- dwMaxValueY += 300;
|
|
|
+ // 再次检查坐标是否合法(极小值点要在基站围成的矩形框内部)
|
|
|
+ dwMinValueX -= dwCoordExpendLen;
|
|
|
+ dwMaxValueX += dwCoordExpendLen;
|
|
|
+ dwMinValueY -= dwCoordExpendLen;
|
|
|
+ dwMaxValueY += dwCoordExpendLen;
|
|
|
if ((dwX >= dwMinValueX) && (dwX <= dwMaxValueX) && (dwY >= dwMinValueY) && (dwY <= dwMaxValueY))
|
|
|
{
|
|
|
if (byFirstPathFlag == CAL_PATH)
|