Robotics StackExchange | Archived questions

problem in PCD file generation code for object recognition

I am trying this program to generate pcd file using image pipeline, but i am unable to get any pointcloud through pcd viewer. I am using logitech webcam pro9000 camera and have also used minoru camera for the same, but it is showing the same result. Is it the camera problem or is there something wrong with the code...?

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <boost/foreach.hpp>

pcl::PointCloud<pcl::PointXYZRGB> PC;    

void callback(const sensor_msgs::PointCloud2ConstPtr& msg)
{
     printf("Writing the file...\n");
     pcl::fromROSMsg(*msg, PC);
     int a = pcl::io::savePCDFileBinary"/home/rootx/pcl_proj/pcd/temp.pcd", PC);
     printf("Saved the pcd file...%d Return %d\n", PC.points.size(), a);

}

int main(int argc, char** argv)
{
     ros::init(argc, argv, "sub_pcl");
     ros::NodeHandle nh;
     ros::Subscriber sub = nh.subscrib<sensor_msgs::PointCloud2>("points2", 1, callback);
     ros::spin();
}

I tried this command to view pcd file pcdviewer: rosrun perceptionpcl pcd_viewer

Asked by youga on 2012-02-17 20:27:43 UTC

Comments

Answers