|
@@ -136,7 +136,7 @@ iv::decition::BrainDecition::BrainDecition()
|
|
|
|
|
|
mpaVechicleState = iv::modulecomm::RegisterSend(gstrmembrainstate.data(),10000,10);
|
|
|
|
|
|
-// mpfusion = iv::modulecomm::RegisterRecv("lidar_obs",ListenOBS);//20210929,cxw,buyong zhege
|
|
|
+ mpfusion = iv::modulecomm::RegisterRecv("lidar_obs",ListenOBS);//20210929,cxw,buyong zhege
|
|
|
// mpfusion = iv::modulecomm::RegisterRecv("li_ra_fusion",ListenFusion);
|
|
|
|
|
|
|
|
@@ -1428,11 +1428,11 @@ void iv::decition::BrainDecition::GetFusion(const char *pdata, const int ndatasi
|
|
|
}
|
|
|
void iv::decition::BrainDecition::UpdateOBS(std::shared_ptr<std::vector<iv::ObstacleBasic> > lidar_obs)
|
|
|
{
|
|
|
-// std::shared_ptr<std::vector<iv::ObstacleBasic>> mobs;
|
|
|
-// iv::LidarGridPtr ptr;
|
|
|
-// mMutex_.lock();
|
|
|
-// lidar_obs.swap(mobs);
|
|
|
-// mMutex_.unlock();
|
|
|
+ std::shared_ptr<std::vector<iv::ObstacleBasic>> mobs;
|
|
|
+ iv::LidarGridPtr ptr;
|
|
|
+ mMutex_.lock();
|
|
|
+ lidar_obs.swap(mobs);
|
|
|
+ mMutex_.unlock();
|
|
|
|
|
|
// ptr = (Obs_grid *)malloc(sizeof(Obs_grid[iv::grx][iv::gry]));
|
|
|
// memset(ptr, 0, sizeof(Obs_grid[iv::grx][iv::gry]));
|
|
@@ -1483,41 +1483,41 @@ void iv::decition::BrainDecition::UpdateOBS(std::shared_ptr<std::vector<iv::Obst
|
|
|
|
|
|
|
|
|
|
|
|
-// mMutex_.lock();
|
|
|
-//// fusion_obs.swap(mfusion_obs_);
|
|
|
-// if(fusion_ptr_ != NULL)
|
|
|
-// {
|
|
|
-// free(fusion_ptr_);
|
|
|
-// fusion_ptr_ = NULL;
|
|
|
-// }
|
|
|
-// fusion_ptr_ = (Obs_grid *)malloc(sizeof(Obs_grid[iv::grx][iv::gry]));
|
|
|
-// memset(fusion_ptr_,0,sizeof(Obs_grid[iv::grx][iv::gry]));
|
|
|
-// for(int i =0; i<iv::grx; i++) //复制到指针数组
|
|
|
-// {
|
|
|
-// for(int j =0; j<iv::gry; j++)
|
|
|
-// {
|
|
|
-// fusion_ptr_[i*(iv::gry)+j].ob = 0;
|
|
|
-// }
|
|
|
+ mMutex_.lock();
|
|
|
+// fusion_obs.swap(mfusion_obs_);
|
|
|
+ if(fusion_ptr_ != NULL)
|
|
|
+ {
|
|
|
+ free(fusion_ptr_);
|
|
|
+ fusion_ptr_ = NULL;
|
|
|
+ }
|
|
|
+ fusion_ptr_ = (Obs_grid *)malloc(sizeof(Obs_grid[iv::grx][iv::gry]));
|
|
|
+ memset(fusion_ptr_,0,sizeof(Obs_grid[iv::grx][iv::gry]));
|
|
|
+ for(int i =0; i<iv::grx; i++) //复制到指针数组
|
|
|
+ {
|
|
|
+ for(int j =0; j<iv::gry; j++)
|
|
|
+ {
|
|
|
+ fusion_ptr_[i*(iv::gry)+j].ob = 0;
|
|
|
+ }
|
|
|
|
|
|
-// }
|
|
|
+ }
|
|
|
|
|
|
-// for(int i=0;i<mobs->size();i++)
|
|
|
-// {
|
|
|
-// iv::ObstacleBasic xobs = mobs->at(i);
|
|
|
-// int dx,dy;
|
|
|
-// dx = (xobs.nomal_x + gridwide * (double)centerx)/gridwide;
|
|
|
-// dy = (xobs.nomal_y + gridwide * (double)centery)/gridwide;
|
|
|
-// if((dx>=0)&&(dx<iv::grx)&&(dy>=0)&&(dy<iv::gry))
|
|
|
-// {
|
|
|
-// fusion_ptr_[dx*(iv::gry) +dy].high = xobs.high;
|
|
|
-// fusion_ptr_[dx*(iv::gry) +dy].low = xobs.low;
|
|
|
-// fusion_ptr_[dx*(iv::gry) + dy].ob = 2;
|
|
|
-// fusion_ptr_[dx*(iv::gry) + dy].obshight = xobs.nomal_z;
|
|
|
-// fusion_ptr_[dx*(iv::gry) + dy].pointcount = 5;
|
|
|
-// }
|
|
|
+ for(int i=0;i<mobs->size();i++)
|
|
|
+ {
|
|
|
+ iv::ObstacleBasic xobs = mobs->at(i);
|
|
|
+ int dx,dy;
|
|
|
+ dx = (xobs.nomal_x + gridwide * (double)centerx)/gridwide;
|
|
|
+ dy = (xobs.nomal_y + gridwide * (double)centery)/gridwide;
|
|
|
+ if((dx>=0)&&(dx<iv::grx)&&(dy>=0)&&(dy<iv::gry))
|
|
|
+ {
|
|
|
+ fusion_ptr_[dx*(iv::gry) +dy].high = xobs.high;
|
|
|
+ fusion_ptr_[dx*(iv::gry) +dy].low = xobs.low;
|
|
|
+ fusion_ptr_[dx*(iv::gry) + dy].ob = 2;
|
|
|
+ fusion_ptr_[dx*(iv::gry) + dy].obshight = xobs.nomal_z;
|
|
|
+ fusion_ptr_[dx*(iv::gry) + dy].pointcount = 5;
|
|
|
+ }
|
|
|
|
|
|
-// }
|
|
|
-// mMutex_.unlock();
|
|
|
+ }
|
|
|
+ mMutex_.unlock();
|
|
|
}
|
|
|
|
|
|
void iv::decition::BrainDecition::UpdateFusion(std::shared_ptr<iv::fusion::fusionobjectarray> fusion_obs)
|