Do I need to use pcl::PointXYZRGB instead of pcl::PoinXYZRGBA to display RGB8 pointcloud2 in rviz? [closed]

asked 2013-12-03 11:12:02 -0500

Yuto Inagaki gravatar image

updated 2014-01-28 17:18:42 -0500

ngrennan gravatar image

Hi, I'm using hydro, pcl_conversions and pcl-1.7.

I tried to subscribe sensor_msgs::PointCloud2 and convert it to pcl::PointCloud<pcl::pointxyzrgba> through converting pcl::PCLPointCloud2. After execute some process, I want to convert some pointcloud<pcl::pointxyzrgba> and publish it to view in rviz.

But when I test below code, I couldn't set ColorTransfomer as RGB8(not displayed) in rviz.

cloud_cb is callback for sensor_msgs::PointCloud2 which is from /camera/depth_registered/points

cloud_cb (const sensor_msgs::PointCloud2 &pc)
{
  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>());  
  pcl::PCLPointCloud2 pcl_pc;
  pcl_conversions::toPCL(pc, pcl_pc);
  pcl::fromPCLPointCloud2 (pcl_pc, *cloud);

  /*
  Actually, I want to execute some process here.
  But, now, this is for test.
  */

  sensor_msgs::PointCloud2 pc2;  
  pcl::PCLPointCloud2::Ptr pcl_pc_2(new pcl::PCLPointCloud2());
  pcl::toPCLPointCloud2 (*cloud, *pcl_pc_2);
  pcl_conversions::fromPCL( *pcl_pc_2, pc2 );
  pub_.publish(pc2);//this is for publishing sensor_msg::PointCloud2
}

However, when I use PointXYZRGB, it works.

Is it something wrong with my code or I have to use XYZRGB(rgb(float)) for visualizing in rviz? Is there better way?

edit retag flag offensive reopen merge delete

Closed for the following reason PCL Question: The PCL community prefers to answer questions at http://www.pcl-users.org/ by tfoote
close date 2015-11-19 20:09:36.151594