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

Unable to #include pcl files in header

asked 2014-01-28 00:39:20 -0600

Latif Anjum gravatar image

updated 2016-10-24 09:00:19 -0600

ngrennan gravatar image

Hi there,

I am trying to understand how to publish and subscribe to a PointCloud2 data from Kinect. Here is a sample program that publishes a PointCloud data.

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>

typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;

int main(int argc, char** argv)
  ros::init (argc, argv, "pub_pcl");
  ros::NodeHandle nh;
  ros::Publisher pub = nh.advertise<PointCloud> ("points2", 1);

  PointCloud::Ptr msg (new PointCloud);
  msg->header.frame_id = "some_tf_frame";
  msg->height = msg->width = 1;
  msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));

  ros::Rate loop_rate(4);
  while (nh.ok())
    msg->header.stamp = ros::Time::now ();
    pub.publish (msg);
    ros::spinOnce ();
    loop_rate.sleep ();

However, there are errors. My system cannot find files #include <pcl_ros/point_cloud.h> and #include <pcl/point_types.h>. I tried to search for the files, and got them under /pcl-1.5/pcl/point_types.h.

I tried to #include the above path. Now the error changed to fatal error: Eigen/StdVector: No such file or directory, compilation terminated.

Here are my Questions:

  1. Why I have files under /pcl-1.5/pcl/point_types.h rather than general

    pcl/point_types.h? Does it make a difference. Same question for pcl_ros/point_cloud.h

  2. What am I doing wrong? why an already given code is not running properly?

  3. I have no folder called pcl_ros. Why?

Any answer will be appreciated.

edit retag flag offensive close merge delete


I think you will get errors trying to compile this file. But let's try to solve your first problem. When you look for roscd pcl_ros you find nothing, right? And what is your ROS distribution and Ubuntu Release?

lfelipesv gravatar image lfelipesv  ( 2014-01-28 00:48:52 -0600 )edit

Interestingly roscd pcl_ros gives the following path. /opt/ros/fuerte/stacks/perception_pcl/pcl_ros I have ros-fuerte and ubuntu 12.04. Am I using two copies of pcl? one under /pcl-1.5/pcl and another under /stacks/perception_pcl?

Latif Anjum gravatar image Latif Anjum  ( 2014-01-28 01:13:19 -0600 )edit

Try to add manually the source: source /opt/ros/fuerte/setup.bash , or something like that and run again. Let me know if the same error occur.

lfelipesv gravatar image lfelipesv  ( 2014-01-28 01:33:33 -0600 )edit

sorry for my dumbness but I didnt get it. Where should I add source /opt/ros/fuerte/setup.bash?

Latif Anjum gravatar image Latif Anjum  ( 2014-01-28 01:49:44 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2014-01-28 00:49:07 -0600

Wolf gravatar image

updated 2014-01-28 00:49:41 -0600

Which ros distro do you use? Have you added pcl to your CMakeLists.txt properly?

Assuming you use hydro with catkin you need add to your CMakeLists.txt:

find_package( PCL REQUIRED )
include_directories(  ${catkin_INCLUDE_DIRS}  ${PCL_INCLUDE_DIRS} )

and for each of your executables/libs you created like

add_executable( my_exec  my_cpp_file.cpp )

you need to link against both catkin and pcl libs:

target_link_libraries ( my_exec ${PCL_LIBRARIES} ${catkin_LIBRARIES} )

With catkin I think there is no separate ros pcl package anymore.

edit flag offensive delete link more


I am using ros-fuerte on ubuntu 12.04. I work with rosbuild (not much familiar with catkin).

Latif Anjum gravatar image Latif Anjum  ( 2014-01-28 01:15:06 -0600 )edit

I have tried adding everything you suggested to CMakeLists.txt (excluding the catkin libraries because I dont use them) but it still cannot find pcl_ros/point_cloud.h. roscd pcl_ros finds the directory and point_cloud.h file exists under its include folder.

Latif Anjum gravatar image Latif Anjum  ( 2014-01-28 02:20:46 -0600 )edit

As mentioned this is the howto for catkin with ros hydro. Unfortunately, this does not help you for your ros fuerte. I think you have had to add some pcl packages back then, but I am not sure anymore

Wolf gravatar image Wolf  ( 2014-01-28 02:23:40 -0600 )edit

Hi Wolf, I have the same problem and your tip will help me since i am using Hydro. I have question about this line add_executable( my_exec my_cpp_file.cpp ), my_exec name is goint to be "point_types" and my_cpp_file.cpp will be "point_types.cpp" Thanks alot for your input

Robert1 gravatar image Robert1  ( 2014-04-23 15:20:04 -0600 )edit

answered 2016-02-23 23:32:20 -0600

scheng gravatar image

first find out where is your pcl header files. For example, I found mine at /usr/include/pcl-1.7/pcl/point_types.h. then update your package's CMakeLists.txt, include_directories( ${catkin_INCLUDE_DIRS} /usr/include/pcl-1.7/ /usr/include/eigen3/ )

edit flag offensive delete link more

answered 2014-01-28 01:19:23 -0600

Latif Anjum gravatar image

Hi, It looks to me that I have two copies of pcl. I can find pcl under the following addres: /opt/ros/fuerte/include/pcl-1.5/pcl. There is another copy I see at the following address: /opt/ros/fuerte/stacks/perception_pcl.

Am I interpreting it right? Or both these files should exist? As I understand, I have a conflict here. Please help me get around this.

edit flag offensive delete link more

Question Tools



Asked: 2014-01-28 00:39:20 -0600

Seen: 19,835 times

Last updated: Jan 28 '14