|
@@ -1,5 +1,5 @@
|
|
|
#include "Estimator.h"
|
|
|
-#include "utils/TimerRecord.h"
|
|
|
+
|
|
|
|
|
|
Estimator::Estimator(const float& filter_corner, const float& filter_surf,
|
|
|
int ivox_nearby_type,int max_ivox_node,float resolution){
|
|
@@ -43,7 +43,7 @@ Estimator::Estimator(const float& filter_corner, const float& filter_surf,
|
|
|
|
|
|
void Estimator::print()
|
|
|
{
|
|
|
- TimerRecord::PrintAll();
|
|
|
+
|
|
|
}
|
|
|
Estimator::~Estimator(){
|
|
|
}
|
|
@@ -714,10 +714,7 @@ void Estimator::EstimateLidarPose(std::list<LidarFrame>& lidarFrameList,
|
|
|
if (((laserCloudCornerFromMapNum > 0 && laserCloudSurfFromMapNum > 100) /*||
|
|
|
(laserCloudCornerFromLocalNum > 0 && laserCloudSurfFromLocalNum > 100)*/))
|
|
|
{
|
|
|
- TimerRecord::Execute(
|
|
|
- [&, this]() {
|
|
|
- Estimate(lidarFrameList, exTlb, gravity);
|
|
|
- }, "Estimate all");
|
|
|
+ Estimate(lidarFrameList, exTlb, gravity);
|
|
|
}
|
|
|
//根据优化结果重新赋值队列第一帧imu状态
|
|
|
transformTobeMapped = Eigen::Matrix4d::Identity();
|
|
@@ -864,45 +861,43 @@ void Estimator::Estimate(std::list<LidarFrame>& lidarFrameList,
|
|
|
std::vector<std::vector<ceres::CostFunction *>> edgesNon(windowSize);
|
|
|
std::thread threads[3];
|
|
|
//添加2帧点云与local地图匹配约束
|
|
|
- TimerRecord::Execute(
|
|
|
- [&,this]() {
|
|
|
+
|
|
|
for (int f = 0; f < windowSize; ++f)
|
|
|
{
|
|
|
|
|
|
- auto frame_curr = lidarFrameList.begin();
|
|
|
- std::advance(frame_curr, f);
|
|
|
- transformTobeMapped = Eigen::Matrix4d::Identity();
|
|
|
- transformTobeMapped.topLeftCorner(3, 3) = frame_curr->Q * exRbl;
|
|
|
- transformTobeMapped.topRightCorner(3, 1) = frame_curr->Q * exPbl + frame_curr->P;
|
|
|
-
|
|
|
- threads[0] = std::thread(&Estimator::processPointToLine, this,
|
|
|
- std::ref(edgesLine[f]),
|
|
|
- std::ref(vLineFeatures[f]),
|
|
|
- std::ref(laserCloudCornerStack[f]),
|
|
|
- std::ref(exTlb),
|
|
|
- std::ref(transformTobeMapped));
|
|
|
-
|
|
|
-
|
|
|
- threads[1] = std::thread(&Estimator::processPointToPlanVec, this,
|
|
|
- std::ref(edgesPlan[f]),
|
|
|
- std::ref(vPlanFeatures[f]),
|
|
|
- std::ref(laserCloudSurfStack[f]),
|
|
|
- std::ref(exTlb),
|
|
|
- std::ref(transformTobeMapped));
|
|
|
-
|
|
|
-
|
|
|
- threads[2] = std::thread(&Estimator::processNonFeatureICP, this,
|
|
|
- std::ref(edgesNon[f]),
|
|
|
- std::ref(vNonFeatures[f]),
|
|
|
- std::ref(laserCloudNonFeatureStack[f]),
|
|
|
- std::ref(exTlb),
|
|
|
- std::ref(transformTobeMapped));
|
|
|
-
|
|
|
- threads[0].join();
|
|
|
- threads[1].join();
|
|
|
- threads[2].join();
|
|
|
+ auto frame_curr = lidarFrameList.begin();
|
|
|
+ std::advance(frame_curr, f);
|
|
|
+ transformTobeMapped = Eigen::Matrix4d::Identity();
|
|
|
+ transformTobeMapped.topLeftCorner(3, 3) = frame_curr->Q * exRbl;
|
|
|
+ transformTobeMapped.topRightCorner(3, 1) = frame_curr->Q * exPbl + frame_curr->P;
|
|
|
+
|
|
|
+ threads[0] = std::thread(&Estimator::processPointToLine, this,
|
|
|
+ std::ref(edgesLine[f]),
|
|
|
+ std::ref(vLineFeatures[f]),
|
|
|
+ std::ref(laserCloudCornerStack[f]),
|
|
|
+ std::ref(exTlb),
|
|
|
+ std::ref(transformTobeMapped));
|
|
|
+
|
|
|
+
|
|
|
+ threads[1] = std::thread(&Estimator::processPointToPlanVec, this,
|
|
|
+ std::ref(edgesPlan[f]),
|
|
|
+ std::ref(vPlanFeatures[f]),
|
|
|
+ std::ref(laserCloudSurfStack[f]),
|
|
|
+ std::ref(exTlb),
|
|
|
+ std::ref(transformTobeMapped));
|
|
|
+
|
|
|
+
|
|
|
+ threads[2] = std::thread(&Estimator::processNonFeatureICP, this,
|
|
|
+ std::ref(edgesNon[f]),
|
|
|
+ std::ref(vNonFeatures[f]),
|
|
|
+ std::ref(laserCloudNonFeatureStack[f]),
|
|
|
+ std::ref(exTlb),
|
|
|
+ std::ref(transformTobeMapped));
|
|
|
+
|
|
|
+ threads[0].join();
|
|
|
+ threads[1].join();
|
|
|
+ threads[2].join();
|
|
|
}
|
|
|
- },"Estimator::feature match");
|
|
|
|
|
|
|
|
|
int cntSurf = 0;
|
|
@@ -1004,63 +999,63 @@ void Estimator::Estimate(std::list<LidarFrame>& lidarFrameList,
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (iterOpt == 0)
|
|
|
+ if (iterOpt == 0)
|
|
|
+ {
|
|
|
+ thres_dist = 10.0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ thres_dist = 1.0;
|
|
|
+ }
|
|
|
+ for (int f = 0; f < windowSize; ++f)
|
|
|
+ {
|
|
|
+ int cntFtu = 0;
|
|
|
+ for (auto &e : edgesLine[f])
|
|
|
{
|
|
|
- thres_dist = 10.0;
|
|
|
+ if (std::fabs(vLineFeatures[f][cntFtu].error) > 1e-5)
|
|
|
+ {
|
|
|
+ problem.AddResidualBlock(e, loss_function, para_PR[f]);
|
|
|
+ vLineFeatures[f][cntFtu].valid = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ vLineFeatures[f][cntFtu].valid = false;
|
|
|
+ }
|
|
|
+ cntFtu++;
|
|
|
+ cntCorner++;
|
|
|
}
|
|
|
- else
|
|
|
+ cntFtu = 0;
|
|
|
+ for (auto &e : edgesPlan[f])
|
|
|
{
|
|
|
- thres_dist = 1.0;
|
|
|
+ if (std::fabs(vPlanFeatures[f][cntFtu].error) > 1e-5)
|
|
|
+ {
|
|
|
+ problem.AddResidualBlock(e, loss_function, para_PR[f]);
|
|
|
+ vPlanFeatures[f][cntFtu].valid = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ vPlanFeatures[f][cntFtu].valid = false;
|
|
|
+ }
|
|
|
+ cntFtu++;
|
|
|
+ cntSurf++;
|
|
|
}
|
|
|
- for (int f = 0; f < windowSize; ++f)
|
|
|
- {
|
|
|
- int cntFtu = 0;
|
|
|
- for (auto &e : edgesLine[f])
|
|
|
- {
|
|
|
- if (std::fabs(vLineFeatures[f][cntFtu].error) > 1e-5)
|
|
|
- {
|
|
|
- problem.AddResidualBlock(e, loss_function, para_PR[f]);
|
|
|
- vLineFeatures[f][cntFtu].valid = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- vLineFeatures[f][cntFtu].valid = false;
|
|
|
- }
|
|
|
- cntFtu++;
|
|
|
- cntCorner++;
|
|
|
- }
|
|
|
- cntFtu = 0;
|
|
|
- for (auto &e : edgesPlan[f])
|
|
|
- {
|
|
|
- if (std::fabs(vPlanFeatures[f][cntFtu].error) > 1e-5)
|
|
|
- {
|
|
|
- problem.AddResidualBlock(e, loss_function, para_PR[f]);
|
|
|
- vPlanFeatures[f][cntFtu].valid = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- vPlanFeatures[f][cntFtu].valid = false;
|
|
|
- }
|
|
|
- cntFtu++;
|
|
|
- cntSurf++;
|
|
|
- }
|
|
|
|
|
|
- cntFtu = 0;
|
|
|
- for (auto &e : edgesNon[f])
|
|
|
- {
|
|
|
- if (std::fabs(vNonFeatures[f][cntFtu].error) > 1e-5)
|
|
|
- {
|
|
|
- problem.AddResidualBlock(e, loss_function, para_PR[f]);
|
|
|
- vNonFeatures[f][cntFtu].valid = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- vNonFeatures[f][cntFtu].valid = false;
|
|
|
- }
|
|
|
- cntFtu++;
|
|
|
- cntNon++;
|
|
|
- }
|
|
|
+ cntFtu = 0;
|
|
|
+ for (auto &e : edgesNon[f])
|
|
|
+ {
|
|
|
+ if (std::fabs(vNonFeatures[f][cntFtu].error) > 1e-5)
|
|
|
+ {
|
|
|
+ problem.AddResidualBlock(e, loss_function, para_PR[f]);
|
|
|
+ vNonFeatures[f][cntFtu].valid = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ vNonFeatures[f][cntFtu].valid = false;
|
|
|
+ }
|
|
|
+ cntFtu++;
|
|
|
+ cntNon++;
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ceres::Solver::Options options;
|
|
@@ -1071,10 +1066,7 @@ void Estimator::Estimate(std::list<LidarFrame>& lidarFrameList,
|
|
|
options.num_threads = 6;
|
|
|
ceres::Solver::Summary summary;
|
|
|
|
|
|
- TimerRecord::Execute(
|
|
|
- [&,this]() {
|
|
|
- ceres::Solve(options, &problem, &summary);
|
|
|
- },"Estimate::ceres solve");
|
|
|
+ ceres::Solve(options, &problem, &summary);
|
|
|
|
|
|
//将优化的结果赋值到lidarFrameList的每一帧数据
|
|
|
double2vector(lidarFrameList);
|