Skip to content

Commit

Permalink
Merge pull request TixiaoShan#168 from valgur/bugfix/cloud_transform
Browse files Browse the repository at this point in the history
Fix a parallelism bug in transformPointCloud()
  • Loading branch information
TixiaoShan authored Dec 8, 2020
2 parents 8145bad + b8d85c3 commit 18ebdbe
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/mapOptmization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ class mapOptimization : public ParamServer
{
pcl::PointCloud<PointType>::Ptr cloudOut(new pcl::PointCloud<PointType>());

PointType *pointFrom;

int cloudSize = cloudIn->size();
cloudOut->resize(cloudSize);

Expand All @@ -288,11 +286,11 @@ class mapOptimization : public ParamServer
#pragma omp parallel for num_threads(numberOfCores)
for (int i = 0; i < cloudSize; ++i)
{
pointFrom = &cloudIn->points[i];
cloudOut->points[i].x = transCur(0,0) * pointFrom->x + transCur(0,1) * pointFrom->y + transCur(0,2) * pointFrom->z + transCur(0,3);
cloudOut->points[i].y = transCur(1,0) * pointFrom->x + transCur(1,1) * pointFrom->y + transCur(1,2) * pointFrom->z + transCur(1,3);
cloudOut->points[i].z = transCur(2,0) * pointFrom->x + transCur(2,1) * pointFrom->y + transCur(2,2) * pointFrom->z + transCur(2,3);
cloudOut->points[i].intensity = pointFrom->intensity;
const auto &pointFrom = cloudIn->points[i];
cloudOut->points[i].x = transCur(0,0) * pointFrom.x + transCur(0,1) * pointFrom.y + transCur(0,2) * pointFrom.z + transCur(0,3);
cloudOut->points[i].y = transCur(1,0) * pointFrom.x + transCur(1,1) * pointFrom.y + transCur(1,2) * pointFrom.z + transCur(1,3);
cloudOut->points[i].z = transCur(2,0) * pointFrom.x + transCur(2,1) * pointFrom.y + transCur(2,2) * pointFrom.z + transCur(2,3);
cloudOut->points[i].intensity = pointFrom.intensity;
}
return cloudOut;
}
Expand Down

0 comments on commit 18ebdbe

Please sign in to comment.