Segmentation fault when computing LUM

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Segmentation fault when computing LUM

vrshy
Hi

I'm getting a segmentation fault when computing LUM, please find below the code and kindly point out if I've made any mistakes.

 LOG(INFO) << "Start of Lidar LUM" << std::endl;
  for (std::size_t l = 0; l < xyzi_elch_vec.size(); l++)
  {
    organizepointcloud.OrganizeIntoPointCloud(xyzi_elch_vec[l], pcl0_organized);
    lum.addPointCloud(pcl0_organized.makeShared());
  }
  for (std::size_t j = 0; j < xyzi_elch_vec.size() - 1; j++)
  {
    pcl::copyPointCloud(xyzi_elch_vec[j], pcl0);
    organizepointcloud.OrganizeIntoRangeImage(pcl0, pcl0_range);
    organizepointcloud.OrganizeIntoPointCloud(pcl0, pcl0_organized);
    pcl0_range.convertTo(pcl0_range, CV_8UC1);

    for (std::size_t k = j + 1; k < xyzi_elch_vec.size(); k++)
    {
      // LOG(INFO) << "iteration " << j << std::endl;
      pcl::copyPointCloud(xyzi_elch_vec[k], pcl1);
      organizepointcloud.OrganizeIntoPointCloud(pcl1, pcl1_organized);
      organizepointcloud.OrganizeIntoRangeImage(pcl1, pcl1_range);
      pcl1_range.convertTo(pcl1_range, CV_8UC1);

      camodometry.FeatureDetectionandMatch(
          pcl0_range, pcl1_range, pcl0_corres, pcl1_corres);
      // return 0;
      for (std::size_t i = 0; i < pcl0_corres.size(); i++)
      {
        pcl::Correspondence temp_corr;
        temp_corr.index_query = static_cast<int>(
            pcl0_corres[i].y * pcl0_range.cols + pcl0_corres[i].x);
        temp_corr.index_match = static_cast<int>(
            pcl1_corres[i].y * pcl1_range.cols + pcl1_corres[i].x);
        net_correspondences.push_back(temp_corr);
      }
      pcl::CorrespondencesPtr shared_corres(&net_correspondences);
      if (net_correspondences.size() > 0)
      {
        lum.setCorrespondences(j, k, shared_corres);
      }
    }
  }
  /////////////////////////////////////////////////////////////////////////
  LOG(INFO) << "Start of LUM Computation" << std::endl;
  lum.setMaxIterations(20);
  lum.setConvergenceThreshold(0.1);
  lum.compute();
  LOG(INFO) << "End of LUM Computation" << std::endl;
  lidarutil.XYZItoPLY(*lum.getConcatenatedCloud(), "Map_lum.ply");
  return 0;

Regards
Vrshy
Reply | Threaded
Open this post in threaded view
|

Re: Segmentation fault when computing LUM

Chris Flesher
Try running a debugger on it to see where the problem is. Add the following line to your CMakeLists.txt file:
SET(CMAKE_BUILD_TYPE Debug)

Then after building run gdb:
gdb program_name
set args command_line_args
run
bt

Then keep pressing enter to get the full stack. Maybe that would tell you where the problem is.

On Tue, Apr 4, 2017 at 7:40 PM, vrshy <[hidden email]> wrote:
Hi

I'm getting a segmentation fault when computing LUM, please find below the
code and kindly point out if I've made any mistakes.

 LOG(INFO) << "Start of Lidar LUM" << std::endl;
  for (std::size_t l = 0; l < xyzi_elch_vec.size(); l++)
  {
    organizepointcloud.OrganizeIntoPointCloud(xyzi_elch_vec[l],
pcl0_organized);
    lum.addPointCloud(pcl0_organized.makeShared());
  }
  for (std::size_t j = 0; j < xyzi_elch_vec.size() - 1; j++)
  {
    pcl::copyPointCloud(xyzi_elch_vec[j], pcl0);
    organizepointcloud.OrganizeIntoRangeImage(pcl0, pcl0_range);
    organizepointcloud.OrganizeIntoPointCloud(pcl0, pcl0_organized);
    pcl0_range.convertTo(pcl0_range, CV_8UC1);

    for (std::size_t k = j + 1; k < xyzi_elch_vec.size(); k++)
    {
      // LOG(INFO) << "iteration " << j << std::endl;
      pcl::copyPointCloud(xyzi_elch_vec[k], pcl1);
      organizepointcloud.OrganizeIntoPointCloud(pcl1, pcl1_organized);
      organizepointcloud.OrganizeIntoRangeImage(pcl1, pcl1_range);
      pcl1_range.convertTo(pcl1_range, CV_8UC1);

      camodometry.FeatureDetectionandMatch(
          pcl0_range, pcl1_range, pcl0_corres, pcl1_corres);
      // return 0;
      for (std::size_t i = 0; i < pcl0_corres.size(); i++)
      {
        pcl::Correspondence temp_corr;
        temp_corr.index_query = static_cast<int>(
            pcl0_corres[i].y * pcl0_range.cols + pcl0_corres[i].x);
        temp_corr.index_match = static_cast<int>(
            pcl1_corres[i].y * pcl1_range.cols + pcl1_corres[i].x);
        net_correspondences.push_back(temp_corr);
      }
      pcl::CorrespondencesPtr shared_corres(&net_correspondences);
      if (net_correspondences.size() > 0)
      {
        lum.setCorrespondences(j, k, shared_corres);
      }
    }
  }
  /////////////////////////////////////////////////////////////////////////
  LOG(INFO) << "Start of LUM Computation" << std::endl;
  lum.setMaxIterations(20);
  lum.setConvergenceThreshold(0.1);
  lum.compute();
  LOG(INFO) << "End of LUM Computation" << std::endl;
  lidarutil.XYZItoPLY(*lum.getConcatenatedCloud(), "Map_lum.ply");
  return 0;

Regards
Vrshy



--
View this message in context: http://www.pcl-users.org/Segmentation-fault-when-computing-LUM-tp4044243.html
Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Segmentation fault when computing LUM

epipolar
This post has NOT been accepted by the mailing list yet.
I think I have the same problem as vrshy

I run

        pcl::registration::LUM<pcl::PointXYZRGBNormal> lum;
        lum.setMaximumIterations(5);
        lum.setConvergenceThreshold(0.01);
       
        // add clouds
        for (int i=0; i < cl_vector.size(); i++){
            lum.addPointCloud(cl_vector[i]);
        }
       
        // set correspondences
        // corrs vector of objects containing the correspondence information
        for (int i=0; i < corrs.size(); i++){
            lum.setCorrespondences(corrs[i].target, corrs[i].source, corrs[i].correspondences_ptr);
        }
       
        lum.compute();



**************************************
gdb yields

        Program received signal SIGSEGV, Segmentation fault.
        0x00007ffff630ebb0 in _mm256_store_ps (__A=..., __P=<optimized out>) at /usr/lib/gcc/x86_64-linux-gnu/5/include/avxintrin.h:854
        854      *(__m256 *)__P = __A;

bt
       
        #0 Eigen::internal::redux_impl<Eigen::internal::scalar_max_op<float>, Eigen::internal::redux_evaluator<Eigen::Matrix<float, 1, -1, 1, 1, -1> >, 3, 0>::run (func=..., mat=<synthetic pointer>)
            at /usr/include/eigen3/Eigen/src/Core/Redux.h:232
        #1  Eigen::DenseBase<Eigen::Matrix<float, 1, -1, 1, 1, -1> >::redux<Eigen::internal::scalar_max_op<float> > (func=..., this=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/Redux.h:416
        #2  Eigen::DenseBase<Eigen::Matrix<float, 1, -1, 1, 1, -1> >::maxCoeff (this=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/Redux.h:436
        #3  Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::computeInPlace (this=this@entry=0x7fffffffca30) at /usr/include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h:481
        #4  0x00007ffff630fdc5 in Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::compute<Eigen::Matrix<float, -1, -1, 0, -1, -1> > (this=0x7fffffffca30, matrix=...)
            at /usr/include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h:457
        #5  0x00007ffff3b71e71 in Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> > (this=0x7fffffffca30, matrix=...)
            at /usr/include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h:132
        #6  0x00007ffff3b87b4f in Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::colPivHouseholderQr (this=0x7fffffffc9b0) at /usr/include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h:608
        #7  pcl::registration::LUM<pcl::PointXYZRGBNormal>::compute (this=0x7fffffffccf0) at ***/pcl/pcl-pcl-1.8.0/registration/include/pcl/registration/impl/lum.hpp:254
        #8  0x000000000060554e in database::lumRegistration (this=0x7fffffffd730) at ***.cpp:1631
        #9  0x0000000000821647 in main (argc=1, argv=0x7fffffffdc38) at main.cpp:139



Any ideas?