Filling MRPT velodyne scan observation












0















I'm new to MRPT and I would like to use it for building an occupancy grid map using velodyne point clouds.



The KITTI dataset provide velodyne point clouds in (x,y,z,r) format, where r is the reflectance. I'm trying to fill a mrpt::obs::CObservationVelodyneScan with such data, but using insertObservation method seems to do just nothing.
Can you point me in the right direction for using this observation type?



My code basically looks like this:



COccupancyGridMap2D map;

// allocate 4 MB buffer (only ~130*4*4 KB are needed)
int32_t num = 1000000;
float *data = (float*)malloc(num*sizeof(float));

// pointers
float *px = data+0;
float *py = data+1;
float *pz = data+2;
float *pr = data+3;

// load point cloud
FILE *stream;
stream = fopen (args.velodyne_filename.c_str(),"rb");
num = fread(data,sizeof(float),num,stream)/4;

obs::CObservationVelodyneScan v;
v.point_cloud.x.resize(num);
v.point_cloud.y.resize(num);
v.point_cloud.z.resize(num);
v.point_cloud.intensity.resize(num);

for (int32_t i=0; i<num; i++)
{
v.point_cloud.x[i] = *px;
v.point_cloud.y[i] = *py;
v.point_cloud.z[i] = *pz;
v.point_cloud.intensity[i] = *pr;

px+=4; py+=4; pz+=4; pr+=4;
}
fclose(stream);

map.likelihoodOptions.likelihoodMethod = OccupancyGridMap2D::lmRayTracing;

map.insertObservation(&v);


Thanks,



Francesco










share|improve this question



























    0















    I'm new to MRPT and I would like to use it for building an occupancy grid map using velodyne point clouds.



    The KITTI dataset provide velodyne point clouds in (x,y,z,r) format, where r is the reflectance. I'm trying to fill a mrpt::obs::CObservationVelodyneScan with such data, but using insertObservation method seems to do just nothing.
    Can you point me in the right direction for using this observation type?



    My code basically looks like this:



    COccupancyGridMap2D map;

    // allocate 4 MB buffer (only ~130*4*4 KB are needed)
    int32_t num = 1000000;
    float *data = (float*)malloc(num*sizeof(float));

    // pointers
    float *px = data+0;
    float *py = data+1;
    float *pz = data+2;
    float *pr = data+3;

    // load point cloud
    FILE *stream;
    stream = fopen (args.velodyne_filename.c_str(),"rb");
    num = fread(data,sizeof(float),num,stream)/4;

    obs::CObservationVelodyneScan v;
    v.point_cloud.x.resize(num);
    v.point_cloud.y.resize(num);
    v.point_cloud.z.resize(num);
    v.point_cloud.intensity.resize(num);

    for (int32_t i=0; i<num; i++)
    {
    v.point_cloud.x[i] = *px;
    v.point_cloud.y[i] = *py;
    v.point_cloud.z[i] = *pz;
    v.point_cloud.intensity[i] = *pr;

    px+=4; py+=4; pz+=4; pr+=4;
    }
    fclose(stream);

    map.likelihoodOptions.likelihoodMethod = OccupancyGridMap2D::lmRayTracing;

    map.insertObservation(&v);


    Thanks,



    Francesco










    share|improve this question

























      0












      0








      0








      I'm new to MRPT and I would like to use it for building an occupancy grid map using velodyne point clouds.



      The KITTI dataset provide velodyne point clouds in (x,y,z,r) format, where r is the reflectance. I'm trying to fill a mrpt::obs::CObservationVelodyneScan with such data, but using insertObservation method seems to do just nothing.
      Can you point me in the right direction for using this observation type?



      My code basically looks like this:



      COccupancyGridMap2D map;

      // allocate 4 MB buffer (only ~130*4*4 KB are needed)
      int32_t num = 1000000;
      float *data = (float*)malloc(num*sizeof(float));

      // pointers
      float *px = data+0;
      float *py = data+1;
      float *pz = data+2;
      float *pr = data+3;

      // load point cloud
      FILE *stream;
      stream = fopen (args.velodyne_filename.c_str(),"rb");
      num = fread(data,sizeof(float),num,stream)/4;

      obs::CObservationVelodyneScan v;
      v.point_cloud.x.resize(num);
      v.point_cloud.y.resize(num);
      v.point_cloud.z.resize(num);
      v.point_cloud.intensity.resize(num);

      for (int32_t i=0; i<num; i++)
      {
      v.point_cloud.x[i] = *px;
      v.point_cloud.y[i] = *py;
      v.point_cloud.z[i] = *pz;
      v.point_cloud.intensity[i] = *pr;

      px+=4; py+=4; pz+=4; pr+=4;
      }
      fclose(stream);

      map.likelihoodOptions.likelihoodMethod = OccupancyGridMap2D::lmRayTracing;

      map.insertObservation(&v);


      Thanks,



      Francesco










      share|improve this question














      I'm new to MRPT and I would like to use it for building an occupancy grid map using velodyne point clouds.



      The KITTI dataset provide velodyne point clouds in (x,y,z,r) format, where r is the reflectance. I'm trying to fill a mrpt::obs::CObservationVelodyneScan with such data, but using insertObservation method seems to do just nothing.
      Can you point me in the right direction for using this observation type?



      My code basically looks like this:



      COccupancyGridMap2D map;

      // allocate 4 MB buffer (only ~130*4*4 KB are needed)
      int32_t num = 1000000;
      float *data = (float*)malloc(num*sizeof(float));

      // pointers
      float *px = data+0;
      float *py = data+1;
      float *pz = data+2;
      float *pr = data+3;

      // load point cloud
      FILE *stream;
      stream = fopen (args.velodyne_filename.c_str(),"rb");
      num = fread(data,sizeof(float),num,stream)/4;

      obs::CObservationVelodyneScan v;
      v.point_cloud.x.resize(num);
      v.point_cloud.y.resize(num);
      v.point_cloud.z.resize(num);
      v.point_cloud.intensity.resize(num);

      for (int32_t i=0; i<num; i++)
      {
      v.point_cloud.x[i] = *px;
      v.point_cloud.y[i] = *py;
      v.point_cloud.z[i] = *pz;
      v.point_cloud.intensity[i] = *pr;

      px+=4; py+=4; pz+=4; pr+=4;
      }
      fclose(stream);

      map.likelihoodOptions.likelihoodMethod = OccupancyGridMap2D::lmRayTracing;

      map.insertObservation(&v);


      Thanks,



      Francesco







      maps point-clouds mrpt






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 9:37









      vpervper

      31




      31
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I was these days also working on the Kitti dataset, so I just added a new function to load a kiti velodyne data file directly into MRPT (see this PR).



          However, after some thinking, I noticed that Kitti raw data does not match exactly with CObservationVelodyneScan, which is aimed at storing the raw ranges for each LiDAR beam, and only optionally, a pointcloud. The Kitti velodyne data are pointclouds, actually, hence I added a new PointCloud type with XYZ+Intensity mrpt::maps::CPointsMapXYZI and added a method loadFromKittiVelodyneFile() to it. Notice this is for the mrpt master git branch, "version 1.9.9".



          Now, how to insert that into a gridmap? Your idea of using a velodyne CObservation to insert it into a gridmap is one of the pending issues on our queue but, anyway, as said above, the Kitti datasets are better loaded as pointclouds.



          I would recommend you converting the pointcloud into a CObservation2DRangeScan, then inserting it into the grid. That would allow you to control what part of the 3D data you really want to be reflected in the grid (i.e. what heights, etc.)



          Hope it helped!






          share|improve this answer
























          • Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

            – vper
            Nov 26 '18 at 10:25













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444024%2ffilling-mrpt-velodyne-scan-observation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I was these days also working on the Kitti dataset, so I just added a new function to load a kiti velodyne data file directly into MRPT (see this PR).



          However, after some thinking, I noticed that Kitti raw data does not match exactly with CObservationVelodyneScan, which is aimed at storing the raw ranges for each LiDAR beam, and only optionally, a pointcloud. The Kitti velodyne data are pointclouds, actually, hence I added a new PointCloud type with XYZ+Intensity mrpt::maps::CPointsMapXYZI and added a method loadFromKittiVelodyneFile() to it. Notice this is for the mrpt master git branch, "version 1.9.9".



          Now, how to insert that into a gridmap? Your idea of using a velodyne CObservation to insert it into a gridmap is one of the pending issues on our queue but, anyway, as said above, the Kitti datasets are better loaded as pointclouds.



          I would recommend you converting the pointcloud into a CObservation2DRangeScan, then inserting it into the grid. That would allow you to control what part of the 3D data you really want to be reflected in the grid (i.e. what heights, etc.)



          Hope it helped!






          share|improve this answer
























          • Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

            – vper
            Nov 26 '18 at 10:25


















          0














          I was these days also working on the Kitti dataset, so I just added a new function to load a kiti velodyne data file directly into MRPT (see this PR).



          However, after some thinking, I noticed that Kitti raw data does not match exactly with CObservationVelodyneScan, which is aimed at storing the raw ranges for each LiDAR beam, and only optionally, a pointcloud. The Kitti velodyne data are pointclouds, actually, hence I added a new PointCloud type with XYZ+Intensity mrpt::maps::CPointsMapXYZI and added a method loadFromKittiVelodyneFile() to it. Notice this is for the mrpt master git branch, "version 1.9.9".



          Now, how to insert that into a gridmap? Your idea of using a velodyne CObservation to insert it into a gridmap is one of the pending issues on our queue but, anyway, as said above, the Kitti datasets are better loaded as pointclouds.



          I would recommend you converting the pointcloud into a CObservation2DRangeScan, then inserting it into the grid. That would allow you to control what part of the 3D data you really want to be reflected in the grid (i.e. what heights, etc.)



          Hope it helped!






          share|improve this answer
























          • Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

            – vper
            Nov 26 '18 at 10:25
















          0












          0








          0







          I was these days also working on the Kitti dataset, so I just added a new function to load a kiti velodyne data file directly into MRPT (see this PR).



          However, after some thinking, I noticed that Kitti raw data does not match exactly with CObservationVelodyneScan, which is aimed at storing the raw ranges for each LiDAR beam, and only optionally, a pointcloud. The Kitti velodyne data are pointclouds, actually, hence I added a new PointCloud type with XYZ+Intensity mrpt::maps::CPointsMapXYZI and added a method loadFromKittiVelodyneFile() to it. Notice this is for the mrpt master git branch, "version 1.9.9".



          Now, how to insert that into a gridmap? Your idea of using a velodyne CObservation to insert it into a gridmap is one of the pending issues on our queue but, anyway, as said above, the Kitti datasets are better loaded as pointclouds.



          I would recommend you converting the pointcloud into a CObservation2DRangeScan, then inserting it into the grid. That would allow you to control what part of the 3D data you really want to be reflected in the grid (i.e. what heights, etc.)



          Hope it helped!






          share|improve this answer













          I was these days also working on the Kitti dataset, so I just added a new function to load a kiti velodyne data file directly into MRPT (see this PR).



          However, after some thinking, I noticed that Kitti raw data does not match exactly with CObservationVelodyneScan, which is aimed at storing the raw ranges for each LiDAR beam, and only optionally, a pointcloud. The Kitti velodyne data are pointclouds, actually, hence I added a new PointCloud type with XYZ+Intensity mrpt::maps::CPointsMapXYZI and added a method loadFromKittiVelodyneFile() to it. Notice this is for the mrpt master git branch, "version 1.9.9".



          Now, how to insert that into a gridmap? Your idea of using a velodyne CObservation to insert it into a gridmap is one of the pending issues on our queue but, anyway, as said above, the Kitti datasets are better loaded as pointclouds.



          I would recommend you converting the pointcloud into a CObservation2DRangeScan, then inserting it into the grid. That would allow you to control what part of the 3D data you really want to be reflected in the grid (i.e. what heights, etc.)



          Hope it helped!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 4:22









          Jose Luis BlancoJose Luis Blanco

          51637




          51637













          • Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

            – vper
            Nov 26 '18 at 10:25





















          • Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

            – vper
            Nov 26 '18 at 10:25



















          Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

          – vper
          Nov 26 '18 at 10:25







          Thank you for your answer. Actually, I already did as you are suggesting and it works perfectly. I just had to set an insert option of the map to take into account for measurements farther than 15m. I will definitely take a look into your unit test for using KITTI velodyne point clouds.

          – vper
          Nov 26 '18 at 10:25




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444024%2ffilling-mrpt-velodyne-scan-observation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks