ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

problems with pcl/tutorial page

asked 2014-03-07 22:15:11 -0500

keygeorge gravatar image

updated 2014-03-09 16:05:52 -0500

ahendrix gravatar image

hi there! I have been trying to solve the building errors the whole day,but it turned out to be in vain.In the pcl/tutorial page,I have followed the tutorial step by step correctly,but when i use "catkin_make" command to build the package,numerous errors jumped out!I don't know whether the tutorial has some defects or my program exists some faults.please give me a hand,thank you! program as following:

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/conversions.h>
#include <pcl/PCLPointCloud2.h>

ros::Publisher pub;


void cloud_cb(const sensor_msgs::PointCloud2ConstPtr& cloud)
{
    // pcl::PCLPointCloud2 pcl_pc;
     //pcl::PointCloud<pcl::PointXYZ> cloud_out;
    sensor_msgs::PointCloud2 cloud_filtered;
     //pcl_conversions::toPCL(*cloud,pcl_pc);
    // pcl::fromROSMsg (pcl_pc,cloud_in);
     pcl::VoxelGrid<sensor_msgs::PointCloud2> sor;
     sor.setInputCloud(*cloud);
     sor.setLeafSize(0.01,0.01,0.01);
     sor.filter(cloud_filtered);
    // pcl::fromPCLPointCloud2(pcl_pc,cloud_out);
      pub.publish(cloud_filtered);
}


   int main(int argc,char**argv)
{
     ros::init(argc,argv,"my_pcl_tutorial");
     ros::NodeHandle nh;
     ros::Subscriber sub=nh.subscribe("cloud2",1,cloud_cb);
     pub=nh.advertise<sensor_msgs::PointCloud2> ("cloud_filtered",1);

     ros::spin();
}
edit retag flag offensive close merge delete

Comments

1

We could better help you if you attach the errors that you encounter :)

Martin Peris gravatar image Martin Peris  ( 2014-03-09 16:13:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-03-10 19:17:40 -0500

keygeorge gravatar image

thank you guys!i finally fix it by chance.......it is the problem of parameter datatype,which is not suitable for the function,which is pcl::VoxelGrid<sensor_msgs::pointcloud2>,if i replace sensor_msgs::pointcloud2 with pcl::pclpointcloud2,it will be all right!although some part of tutorial demonstrated that sensor_msgs type is all right, in my situation it is not.......i don't know whether the tutorial got some mistakes.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-07 22:15:11 -0500

Seen: 115 times

Last updated: Mar 10 '14