|
@@ -56,6 +56,10 @@ Card::Card( string cardid, int cardtype, double z_offset, double offset_x /*= 12
|
|
|
is_init_kalman = false;
|
|
|
pReaderPathMap = NULL;
|
|
|
pTdoaReaderPathMap = NULL;
|
|
|
+
|
|
|
+ m_pKalmanFilter = new CKalmanFilter();
|
|
|
+ m_pKalmanFilter->Initial(1);
|
|
|
+ m_pKalmanFilter->m_bFlag = false;
|
|
|
}
|
|
|
|
|
|
Card::Card( void )
|
|
@@ -257,6 +261,10 @@ int Card::get_effictive_dist_count( int offset /*= 0*/ )
|
|
|
|
|
|
Card::~Card(void)
|
|
|
{
|
|
|
+ if(m_pKalmanFilter){
|
|
|
+ delete m_pKalmanFilter;
|
|
|
+ m_pKalmanFilter = NULL;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void Card::get_coordinate_2d( int cnt )
|
|
@@ -663,37 +671,61 @@ void Card::get_coordinate( int cnt )
|
|
|
if(pTdoaReaderPathMap->size() > 0 && pRdm.size() > 1){
|
|
|
p = LocateAlgorithm::Pos(&pRdm,*pTdoaReaderPathMap);
|
|
|
|
|
|
- if(p->posx == INVALID_COORDINATE || p->posy == INVALID_COORDINATE || p->posz == INVALID_COORDINATE){
|
|
|
- /*p->posx = this->last_x;
|
|
|
- p->posy = this->last_y;
|
|
|
- p->posz = this->last_z;*/
|
|
|
- p->posx = this->last_locate.x;
|
|
|
- p->posy = this->last_locate.y;
|
|
|
- p->posz = this->last_locate.z;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ //最新通过算法算出的结果
|
|
|
this->x = p->posx / (this->map_scale*1.0);
|
|
|
this->y = p->posy / (this->map_scale*1.0);
|
|
|
this->z = p->posz / (this->map_scale*1.0);
|
|
|
|
|
|
- this->last_locate.x = this->x;
|
|
|
- this->last_locate.y = this->y;
|
|
|
+ ////通过卡尔曼滤波处理
|
|
|
+ this->m_pKalmanFilter->m_bFlag = true;
|
|
|
+ this->m_pKalmanFilter->m_nCounts++;
|
|
|
+
|
|
|
+ long long deltaT = this->t - this->last_locate.t;
|
|
|
+ double vx = 0;
|
|
|
+ double vy = 0;
|
|
|
+ double v = 0;
|
|
|
+
|
|
|
+ if(deltaT != 0){
|
|
|
+ vx = (this->x - this->last_locate.x)/deltaT;
|
|
|
+ vy = (this->y - this->last_locate.y)/deltaT;
|
|
|
+ v = sqrt(pow(this->x - this->last_locate.x,2) + pow(this->x - this->last_locate.x,2))/deltaT;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this->m_pKalmanFilter->m_nCounts == 1){
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(0,1) = this->x;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(1,1) = vx;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(2,1) = this->y;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(3,1) = vy;
|
|
|
+ //第一次直接赋值
|
|
|
+ this->m_pKalmanFilter->m_pCar->x = this->m_pKalmanFilter->m_pCar->z;
|
|
|
+ }else if(this->m_pKalmanFilter->m_nCounts == 2){
|
|
|
+ //两次处理
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(1, 1) = (this->m_pKalmanFilter->m_pCar->z(0, 1) - this->m_pKalmanFilter->m_pCar->x(0, 1))/deltaT;
|
|
|
+ this->m_pKalmanFilter->m_pCar->z(3, 1) = (this->m_pKalmanFilter->m_pCar->z(2, 1) - this->m_pKalmanFilter->m_pCar->x(2, 1))/deltaT;
|
|
|
+ this->m_pKalmanFilter->m_pCar->x = this->m_pKalmanFilter->m_pCar->z;
|
|
|
+ }else{
|
|
|
+ //只有三次以上才允许使用kalman滤波以下的函数
|
|
|
+ if(this->m_pKalmanFilter->m_bFlag){
|
|
|
+ this->m_pKalmanFilter->Predict_Correct();
|
|
|
+ }else{
|
|
|
+ this->m_pKalmanFilter->Predict();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this->last_locate.x = this->x = this->m_pKalmanFilter->m_pCar->x(0,1);
|
|
|
+ this->last_locate.y = this->y = this->m_pKalmanFilter->m_pCar->x(2,1);
|
|
|
this->last_locate.z = this->z;
|
|
|
+ this->v = sqrt(pow(this->m_pKalmanFilter->m_pCar->x(1,1),2) + pow(this->m_pKalmanFilter->m_pCar->x(3,1),2));
|
|
|
+ /*this->last_locate.x = this->x;
|
|
|
+ this->last_locate.y = this->y;
|
|
|
+ this->last_locate.z = this->z;*/
|
|
|
|
|
|
//this->v = sqrt(pow(this->x - this->last_x,2) + pow(this->y - this->last_y,2) + pow(this->z - this->last_z,2))*this->map_scale;
|
|
|
- this->v = 0;
|
|
|
+ //this->v = 0;
|
|
|
this->z = 0;
|
|
|
this->a = 0;
|
|
|
}
|
|
|
- //this->map_scale = 0.02;
|
|
|
|
|
|
- /*this->x = p->posx / (this->map_scale*1.0);
|
|
|
- this->y = p->posy / (this->map_scale*1.0);
|
|
|
- this->v = 0;
|
|
|
- this->z = 0;
|
|
|
- this->a = 0;*/
|
|
|
-
|
|
|
#else
|
|
|
|
|
|
#endif
|