Commit 01855b85 authored by wangdawei's avatar wangdawei

unload block

parent 28aa41de
...@@ -130,4 +130,9 @@ float MapMatcherInterface::MatchPointCloud(const PointCloudJ::Ptr pcloud, const ...@@ -130,4 +130,9 @@ float MapMatcherInterface::MatchPointCloud(const PointCloudJ::Ptr pcloud, const
return score; return score;
} }
void MapMatcherInterface::unLoadAllBlocks()
{
}
} // namespace juefx } // namespace juefx
...@@ -47,6 +47,9 @@ public: ...@@ -47,6 +47,9 @@ public:
float MatchPointCloud(const PointCloudJ::Ptr pcloud, const GuessPose guess_pose, float MatchPointCloud(const PointCloudJ::Ptr pcloud, const GuessPose guess_pose,
GnssPoint &final_pose, Eigen::Isometry3f &local_pose); GnssPoint &final_pose, Eigen::Isometry3f &local_pose);
void unLoadAllBlocks();
protected: protected:
virtual float InnerMatch(const VectorCloud &vector_cloud, const GuessPose guess_pose, virtual float InnerMatch(const VectorCloud &vector_cloud, const GuessPose guess_pose,
const Rigid3d &predict_pose, Rigid3d &estimate_pose) = 0; const Rigid3d &predict_pose, Rigid3d &estimate_pose) = 0;
......
...@@ -470,6 +470,9 @@ bool AdjustPPK::ConfigMap(double timestamp) ...@@ -470,6 +470,9 @@ bool AdjustPPK::ConfigMap(double timestamp)
if(meshVec_.find(meshId) == meshVec_.end()){ if(meshVec_.find(meshId) == meshVec_.end()){
return false; return false;
} }
if(currMatcher_){
currMatcher_->unLoadAllBlocks();
}
while(!meshVec_.at(meshId).matcher){ while(!meshVec_.at(meshId).matcher){
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
} }
...@@ -504,26 +507,13 @@ bool AdjustPPK::LocateCloud(const CloudInfoForMatch &cloudInfo) ...@@ -504,26 +507,13 @@ bool AdjustPPK::LocateCloud(const CloudInfoForMatch &cloudInfo)
guessPose.movement = 2; guessPose.movement = 2;
guessPose.rotation = 0.01; guessPose.rotation = 0.01;
guessPose.use_gnss = false; guessPose.use_gnss = false;
uint16_t checkCnt = 0; if(!currMatcher_->IsMapLoaded(guess.translation())){
while(!currMatcher_->IsMapLoaded(guess.translation())){ currMatcher_->loadArea(guess.translation());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if(++checkCnt > 200){
LOG(INFO) << "IsMapLoaded fail ++checkCnt > 200! ";
return false;
}
} }
double avgGridCnt = currMatcher_->AreaAvgGridCnt(guess.translation()); double avgGridCnt = currMatcher_->AreaAvgGridCnt(guess.translation());
if(avgGridCnt < 20000){ if(avgGridCnt < 20000){
LOG(INFO) << "avgGridCnt < 20000! " << "avgGridCnt: " << avgGridCnt; LOG(INFO) << "avgGridCnt < 20000! " << "avgGridCnt: " << avgGridCnt;
if(ppkIndex_ > 0){ CloseToPPK();
double radio = 0.9;
const auto &localPPK = localPoseVec_.at(ppkIndex_ - 1);
mapPose_.translation() =
localPPK.pose.translation() * radio +
mapPose_.translation() * (1 - radio);
mapPose_.linear() =
Quaterniond(mapPose_.linear()).slerp(radio, Quaterniond(localPPK.pose.linear())).toRotationMatrix();
}
return false; return false;
} }
ofs << setprecision(16) << cloudInfo.timestamp << ", " << guess.translation().x() ofs << setprecision(16) << cloudInfo.timestamp << ", " << guess.translation().x()
...@@ -535,6 +525,7 @@ bool AdjustPPK::LocateCloud(const CloudInfoForMatch &cloudInfo) ...@@ -535,6 +525,7 @@ bool AdjustPPK::LocateCloud(const CloudInfoForMatch &cloudInfo)
guessPose.precision_type = MATCH_PRECISION_INIT; guessPose.precision_type = MATCH_PRECISION_INIT;
currMatcher_->MatchPointCloud(cloudInfo.frame, guessPose, finalGnssPose, finalPose); currMatcher_->MatchPointCloud(cloudInfo.frame, guessPose, finalGnssPose, finalPose);
mapPose_ = finalPose.cast<double>(); mapPose_ = finalPose.cast<double>();
CloseToPPK();
skipCnt_ = 5; skipCnt_ = 5;
return true; return true;
} }
...@@ -577,15 +568,15 @@ void AdjustPPK::LoadMap() ...@@ -577,15 +568,15 @@ void AdjustPPK::LoadMap()
LOG(INFO) << "mesh loaded: " << meshId; LOG(INFO) << "mesh loaded: " << meshId;
} }
} }
for(size_t id = period.startId; id <= period.endId; id += 100){ // for(size_t id = period.startId; id <= period.endId; id += 100){
if(requestQuit_){ // if(requestQuit_){
return; // return;
} // }
auto pose = localPoseVec_.at(id).pose; // auto pose = localPoseVec_.at(id).pose;
if(!meshInfo.matcher->IsMapLoaded(pose.translation())){ // if(!meshInfo.matcher->IsMapLoaded(pose.translation())){
meshInfo.matcher->loadArea(pose.translation()); // meshInfo.matcher->loadArea(pose.translation());
} // }
} // }
} }
} }
...@@ -669,4 +660,17 @@ bool AdjustPPK::LoadMesh(const string &streamPath, boost::shared_ptr<VoxelMapMat ...@@ -669,4 +660,17 @@ bool AdjustPPK::LoadMesh(const string &streamPath, boost::shared_ptr<VoxelMapMat
return true; return true;
} }
void AdjustPPK::CloseToPPK()
{
if(ppkIndex_ > 0){
double radio = 0.9;
const auto &localPPK = localPoseVec_.at(ppkIndex_ - 1);
mapPose_.translation() =
localPPK.pose.translation() * radio +
mapPose_.translation() * (1 - radio);
mapPose_.linear() =
Quaterniond(mapPose_.linear()).slerp(radio, Quaterniond(localPPK.pose.linear())).toRotationMatrix();
}
}
} // end of namespace } // end of namespace
...@@ -89,6 +89,8 @@ private: ...@@ -89,6 +89,8 @@ private:
bool LoadMesh(const string &streamPath, bool LoadMesh(const string &streamPath,
boost::shared_ptr<VoxelMapMatcher> &matcher); boost::shared_ptr<VoxelMapMatcher> &matcher);
void CloseToPPK();
private: private:
string ieBaseDir_; string ieBaseDir_;
......
...@@ -50,6 +50,11 @@ void VoxelMap::ConfirmPosition( ...@@ -50,6 +50,11 @@ void VoxelMap::ConfirmPosition(
mapArea_->ConfirmPosition(pose_in_map, final_pose); mapArea_->ConfirmPosition(pose_in_map, final_pose);
} }
void VoxelMap::unLoadAllBlocks()
{
mapArea_->unLoadAllBlocks();
}
float VoxelMap::GetResolution(uint8_t type) const float VoxelMap::GetResolution(uint8_t type) const
{ {
float resolution = mapArea_->getResolution(); float resolution = mapArea_->getResolution();
......
...@@ -24,6 +24,7 @@ public: ...@@ -24,6 +24,7 @@ public:
double AreaAvgGridCnt(const Eigen::Vector3d& pose); double AreaAvgGridCnt(const Eigen::Vector3d& pose);
bool GuessPosition(const GnssPoint &init_pose, Eigen::Isometry3d &pose_in_map); bool GuessPosition(const GnssPoint &init_pose, Eigen::Isometry3d &pose_in_map);
void ConfirmPosition(const Eigen::Vector3d &pose_in_map, GnssPoint &final_pose); void ConfirmPosition(const Eigen::Vector3d &pose_in_map, GnssPoint &final_pose);
void unLoadAllBlocks();
public: public:
float GetResolution(uint8_t type) const; float GetResolution(uint8_t type) const;
......
...@@ -61,6 +61,17 @@ void BlockArea::load() ...@@ -61,6 +61,17 @@ void BlockArea::load()
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void BlockArea::unLoad()
{
vector<juefx::Distribution>().swap(distributionVec_);
for(size_t i = 0; i < 5; i++){
vector<vector<juefx::DistributionIndex>>().swap(indexTable_[i]);
}
loaded_ = false;
}
//--------------------------------------------------------------------------
juefx::Distribution *BlockArea::getGridDistribution( juefx::Distribution *BlockArea::getGridDistribution(
uint8_t layerId, uint8_t shiftedX, uint8_t shiftedY, uint8_t &length) const uint8_t layerId, uint8_t shiftedX, uint8_t shiftedY, uint8_t &length) const
{ {
......
...@@ -27,6 +27,8 @@ public: ...@@ -27,6 +27,8 @@ public:
void load(); void load();
void unLoad();
juefx::Distribution* getGridDistribution( juefx::Distribution* getGridDistribution(
uint8_t layerId, uint8_t shiftedX, uint8_t shiftedY, uint8_t &length) const; uint8_t layerId, uint8_t shiftedX, uint8_t shiftedY, uint8_t &length) const;
......
...@@ -266,6 +266,13 @@ public: ...@@ -266,6 +266,13 @@ public:
float getResolution(); float getResolution();
void unLoadAllBlocks(){
if(!currMesh_){
return;
}
currMesh_->unLoadAllBlocks();
}
private: private:
void backendThreadFunc(); void backendThreadFunc();
......
...@@ -356,7 +356,19 @@ void MeshArea::loadBlockAtArea(const Vector3d &position) ...@@ -356,7 +356,19 @@ void MeshArea::loadBlockAtArea(const Vector3d &position)
} }
} }
// LOG(INFO) << "shiftedIndexToLoad: " << centerIndex.transpose() // LOG(INFO) << "shiftedIndexToLoad: " << centerIndex.transpose()
// << " blockCntLoaded: " <<blockCntLoaded; // << " blockCntLoaded: " <<blockCntLoaded;
}
void MeshArea::unLoadAllBlocks()
{
for(size_t x = 0; x < rowItemCnt_; x++){
for(size_t y = 0; y < colItemCnt_; y++){
BlockContent &blockContent = blockAreaTable_[x][y];
if(blockContent.block->isLoad()){
blockContent.block->unLoad();
}
}
}
} }
} }
...@@ -246,6 +246,7 @@ public: ...@@ -246,6 +246,7 @@ public:
return offset_; return offset_;
} }
void unLoadAllBlocks();
private: private:
void checkBlockState(); void checkBlockState();
...@@ -271,6 +272,7 @@ private: ...@@ -271,6 +272,7 @@ private:
void loadBlockAtArea(const Vector3d &position); void loadBlockAtArea(const Vector3d &position);
private: private:
string meshPath_; string meshPath_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment