|
@@ -65,6 +65,8 @@ Card::Card( string cardid, int cardtype, double z_offset, double offset_x /*= 12
|
|
|
pReaderPathMap = NULL;
|
|
|
pTdoaReaderPathMap = NULL;
|
|
|
last_s_locate_reader[0] = last_s_locate_reader[1] = -1;
|
|
|
+ m_syncNumList.clear();
|
|
|
+ m_dFirstDiff = m_dSecondDiff = 0.0;
|
|
|
|
|
|
last_locate.tt = 0;
|
|
|
last_locate.a = last_locate.antenna_id = last_locate.reader_id = last_locate.t = 0;
|
|
@@ -491,7 +493,8 @@ void Card::get_coordinate( int cnt )
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- HeapSort(p_dists_locate,k);
|
|
|
+ //HeapSort(p_dists_locate,k);
|
|
|
+ SelectSort(p_dists_locate,k);
|
|
|
|
|
|
ReceiveDataMap pRdm;
|
|
|
pRdm.clear();
|
|
@@ -539,7 +542,105 @@ void Card::get_coordinate( int cnt )
|
|
|
this->origin_locate.y = p->posy / (this->map_scale*1.0);
|
|
|
|
|
|
double interval_time = this->p_reader->reader_interval_time;
|
|
|
- double deltaT = (this->sync_num - this->m_nLastLocateT)*interval_time;
|
|
|
+
|
|
|
+ double deltaT = 0.0;
|
|
|
+ double cvx = 0;
|
|
|
+ double cvy = 0;
|
|
|
+ double cv = 0;
|
|
|
+
|
|
|
+ double cx = 0;
|
|
|
+ double cy = 0;
|
|
|
+ double cz = 0;
|
|
|
+
|
|
|
+ cx = p->posx / (this->map_scale*1.0);
|
|
|
+ cy = p->posy / (this->map_scale*1.0);
|
|
|
+ cz = p->posz / (this->map_scale*1.0);
|
|
|
+
|
|
|
+ if(this->m_nLastLocateT == 0){
|
|
|
+ m_syncNumList.push_back(this->sync_num);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ list<unsigned long long>::iterator it = m_syncNumList.begin();
|
|
|
+ deltaT = (this->sync_num - *it)*interval_time;
|
|
|
+ if(deltaT - 2.0 > 0 ){
|
|
|
+ m_syncNumList.pop_front();
|
|
|
+ m_syncNumList.push_back(this->sync_num);
|
|
|
+
|
|
|
+ cvx = (cx - this->last_locate.x)/deltaT;
|
|
|
+ cvy = (cy - this->last_locate.y)/deltaT;
|
|
|
+ cvx *= this->map_scale;
|
|
|
+ cvy *= this->map_scale;
|
|
|
+
|
|
|
+ cv = sqrt(pow(cvx,2) + pow(cvy,2));
|
|
|
+
|
|
|
+ double avx = (cvx - last_vx) / deltaT;
|
|
|
+ double avy = (cvy - last_vy) / deltaT;
|
|
|
+ double av = sqrt(pow(avx,2) + pow(avy,2));
|
|
|
+ //车卡的加速度
|
|
|
+ switch(this->card_type){
|
|
|
+ case CT_PERSON:
|
|
|
+ if(av > 3){
|
|
|
+ this->x = this->last_locate.x;
|
|
|
+ this->y = this->last_locate.y;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case CT_VEHICLE:
|
|
|
+ if(av > 5){
|
|
|
+ //保留上次结果
|
|
|
+ this->x = this->last_locate.x;
|
|
|
+ this->y = this->last_locate.y;
|
|
|
+ //this->m_nLastLocateT = this->sync_num;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ this->last_vx = cvx;
|
|
|
+ this->last_vy = cvy;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //if(deltaT != 0){
|
|
|
+ // cvx = (cx - this->last_locate.x)/deltaT;
|
|
|
+ // cvy = (cy - this->last_locate.y)/deltaT;
|
|
|
+ // cvx *= this->map_scale;
|
|
|
+ // cvy *= this->map_scale;
|
|
|
+
|
|
|
+ // /*if(vx>=0){
|
|
|
+ // nSign = 1;
|
|
|
+ // }
|
|
|
+ // else{
|
|
|
+ // nSign = -1;
|
|
|
+ // }*/
|
|
|
+ // cv = sqrt(pow(cvx,2) + pow(cvy,2));
|
|
|
+ // //v *= nSign;
|
|
|
+
|
|
|
+ // //last_vx = last_vy = 0.0;
|
|
|
+ // double avx = (cvx - last_vx) / deltaT;
|
|
|
+ // double avy = (cvy - last_vy) / deltaT;
|
|
|
+ // double av = sqrt(pow(avx,2) + pow(avy,2));
|
|
|
+ // //车卡的加速度
|
|
|
+ // switch(this->card_type){
|
|
|
+ // case CT_PERSON:
|
|
|
+ // if(av > 3){
|
|
|
+ // this->x = this->last_locate.x;
|
|
|
+ // this->y = this->last_locate.y;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // break;
|
|
|
+ // case CT_VEHICLE:
|
|
|
+ // if(av > 5){
|
|
|
+ // //保留上次结果
|
|
|
+ // this->x = this->last_locate.x;
|
|
|
+ // this->y = this->last_locate.y;
|
|
|
+ // //this->m_nLastLocateT = this->sync_num;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // this->last_vx = cvx;
|
|
|
+ // this->last_vy = cvy;
|
|
|
+ //}
|
|
|
|
|
|
if(m_nFilterType == FILTER_KALMAN){
|
|
|
////通过卡尔曼滤波处理
|
|
@@ -568,60 +669,60 @@ void Card::get_coordinate( int cnt )
|
|
|
this->m_pKalmanFilter->m_bFlag = true;
|
|
|
this->m_pKalmanFilter->m_nCounts++;
|
|
|
|
|
|
- double vx = 0;
|
|
|
- double vy = 0;
|
|
|
- double v = 0;
|
|
|
-
|
|
|
- x = p->posx / (this->map_scale*1.0);
|
|
|
- y = p->posy / (this->map_scale*1.0);
|
|
|
- z = p->posz / (this->map_scale*1.0);
|
|
|
-
|
|
|
- if(deltaT != 0){
|
|
|
- vx = (this->x - this->last_locate.x)/deltaT;
|
|
|
- vy = (this->y - this->last_locate.y)/deltaT;
|
|
|
- vx *= this->map_scale;
|
|
|
- vy *= this->map_scale;
|
|
|
-
|
|
|
- /*if(vx>=0){
|
|
|
- nSign = 1;
|
|
|
- }
|
|
|
- else{
|
|
|
- nSign = -1;
|
|
|
- }*/
|
|
|
- v = sqrt(pow(vx,2) + pow(vy,2));
|
|
|
- //v *= nSign;
|
|
|
-
|
|
|
- //last_vx = last_vy = 0.0;
|
|
|
- double avx = (vx - last_vx) / deltaT;
|
|
|
- double avy = (vy - last_vy) / deltaT;
|
|
|
- double av = sqrt(pow(avx,2) + pow(avy,2));
|
|
|
- //车卡的加速度
|
|
|
- switch(this->card_type){
|
|
|
- case CT_PERSON:
|
|
|
- if(av > 3){
|
|
|
- this->x = this->last_locate.x;
|
|
|
- this->y = this->last_locate.y;
|
|
|
- return;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CT_VEHICLE:
|
|
|
- if(av > 0.5){
|
|
|
- //保留上次结果
|
|
|
- this->x = this->last_locate.x;
|
|
|
- this->y = this->last_locate.y;
|
|
|
- //this->m_nLastLocateT = this->sync_num;
|
|
|
- return;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- this->last_vx = vx;
|
|
|
- this->last_vy = vy;
|
|
|
- }
|
|
|
-
|
|
|
- this->m_pKalmanFilter->m_pCar->z(0,0) = this->x;
|
|
|
- this->m_pKalmanFilter->m_pCar->z(1,0) = vx;
|
|
|
- this->m_pKalmanFilter->m_pCar->z(2,0) = this->y;
|
|
|
- this->m_pKalmanFilter->m_pCar->z(3,0) = vy;
|
|
|
+ //double vx = 0;
|
|
|
+ //double vy = 0;
|
|
|
+ //double v = 0;
|
|
|
+
|
|
|
+ //x = p->posx / (this->map_scale*1.0);
|
|
|
+ //y = p->posy / (this->map_scale*1.0);
|
|
|
+ //z = p->posz / (this->map_scale*1.0);
|
|
|
+
|
|
|
+ //if(deltaT != 0){
|
|
|
+ // vx = (this->x - this->last_locate.x)/deltaT;
|
|
|
+ // vy = (this->y - this->last_locate.y)/deltaT;
|
|
|
+ // vx *= this->map_scale;
|
|
|
+ // vy *= this->map_scale;
|
|
|
+
|
|
|
+ // /*if(vx>=0){
|
|
|
+ // nSign = 1;
|
|
|
+ // }
|
|
|
+ // else{
|
|
|
+ // nSign = -1;
|
|
|
+ // }*/
|
|
|
+ // v = sqrt(pow(vx,2) + pow(vy,2));
|
|
|
+ // //v *= nSign;
|
|
|
+
|
|
|
+ // //last_vx = last_vy = 0.0;
|
|
|
+ // double avx = (vx - last_vx) / deltaT;
|
|
|
+ // double avy = (vy - last_vy) / deltaT;
|
|
|
+ // double av = sqrt(pow(avx,2) + pow(avy,2));
|
|
|
+ // //车卡的加速度
|
|
|
+ // switch(this->card_type){
|
|
|
+ // case CT_PERSON:
|
|
|
+ // if(av > 3){
|
|
|
+ // this->x = this->last_locate.x;
|
|
|
+ // this->y = this->last_locate.y;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // break;
|
|
|
+ // case CT_VEHICLE:
|
|
|
+ // if(av > 0.5){
|
|
|
+ // //保留上次结果
|
|
|
+ // this->x = this->last_locate.x;
|
|
|
+ // this->y = this->last_locate.y;
|
|
|
+ // //this->m_nLastLocateT = this->sync_num;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // this->last_vx = vx;
|
|
|
+ // this->last_vy = vy;
|
|
|
+ //}
|
|
|
+
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(0,0) = cx;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(1,0) = cvx;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(2,0) = cy;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(3,0) = cvy;
|
|
|
|
|
|
if(this->m_pKalmanFilter->m_nCounts == 1){
|
|
|
//第一次直接赋值
|
|
@@ -691,8 +792,7 @@ void Card::get_coordinate( int cnt )
|
|
|
this->m_pKalmanFilter->m_pCar->t = this->m_nLastLocateT = this->sync_num;
|
|
|
this->v = nSign * sqrt(pow(this->m_pKalmanFilter->m_pCar->x(1,0),2) + pow(this->m_pKalmanFilter->m_pCar->x(3,0),2))*this->map_scale;
|
|
|
|
|
|
- int nv = (int)(v*1000);
|
|
|
- this->v = nv*1.0/1000.0;
|
|
|
+ this->v = cv*3.6;
|
|
|
}else{
|
|
|
//TRACE(_T("no kalman . \n"));
|
|
|
//最新通过算法算出的结果
|
|
@@ -706,17 +806,7 @@ void Card::get_coordinate( int cnt )
|
|
|
this->y = p->posy / (this->map_scale*1.0);
|
|
|
this->z = p->posz / (this->map_scale*1.0);
|
|
|
|
|
|
- double vx = 0,vy = 0,v = 0;
|
|
|
- if(deltaT != 0){
|
|
|
- vx = (this->x - this->last_locate.x)/deltaT;
|
|
|
- vy = (this->y - this->last_locate.y)/deltaT;
|
|
|
- vx *= this->map_scale;
|
|
|
- vy *= this->map_scale;
|
|
|
-
|
|
|
- v = sqrt(pow(vx,2) + pow(vy,2));
|
|
|
- }
|
|
|
-
|
|
|
- this->v = this->v*3.6;
|
|
|
+ this->v = cv*3.6;
|
|
|
|
|
|
this->last_locate.x = this->x;
|
|
|
this->last_locate.y = this->y;
|