Ask Your Question
1

PCD to Octree

asked 2013-07-01 02:53:55 -0500

arp gravatar image

Hi,

I have a registered point-cloud as PCD file. I want to convert it into octree representation. There are two ways I could go. The first one is by using PCL. The second method by using octomap. Is there any difference between them? Which one should I choose? How could it be done using octomap?

Greetings

edit retag flag offensive close merge delete

Comments

Have you got any answer?

arczi gravatar image arczi  ( 2014-12-13 11:26:04 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2017-07-25 16:43:24 -0500

swethmandava gravatar image

First used pcl to publish a point cloud from the pcd file and then used octomap to get the octree

<launch>
<node pkg = "pcl_ros" type = "pcd_to_pointcloud" name = "show_pointcloud" args = "xyz.pcd _frame_id:=/world" output="screen" /
<node pkg="octomap_server" type="octomap_server_node" name="octomap_server">
    <param name="resolution" value="0.4" />
    <param name="frame_id" type="string" value="world" />
    <!-- maximum range to integrate (speedup!) -->
    <param name="sensor_model/max_range" value="100" />
    <!-- data source to integrate (PointCloud2) -->
    <remap from="cloud_in" to="/cloud_pcd" />
</node>
</launch>
edit flag offensive delete link more
0

answered 2021-08-08 20:56:08 -0500

gaussian gravatar image

updated 2021-08-08 20:57:15 -0500

I wrote this simple piece of code

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <octomap/OcTree.h>
octomap::OcTree  pcdToOctree(const std::string& pcd_file, double resolution)
{
  // Read in the env PCD file as Point Cloud and convert to OcTree
  // FIRST: Load PCD as PCL PointCloud
  pcl::PointCloud<pcl::PointXYZ> cloud;
  if (pcl::io::loadPCDFile<pcl::PointXYZ> (pcd_file, cloud) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read input PCD file \n");
    return (-1);
  }

  // SECOND: Add points to OcTree
  octomap::OcTree final_octree(resolution);
  for (auto p:cloud.points)
  {
    final_octree.updateNode( octomap::point3d(p.x, p.y, p.z), true );
  }
  final_octree.updateInnerOccupancy();
  return final_octree;
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-07-01 02:53:55 -0500

Seen: 1,313 times

Last updated: Aug 08 '21