# Unable to #include pcl files in header

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->height = msg->width = 1;
msg->points.push_back (pcl::PointXYZ(1.0, 2.0, 3.0));

ros::Rate loop_rate(4);
while (nh.ok())
{
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?

edit retag 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?

( 2014-01-28 00:48:52 -0500 )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?

( 2014-01-28 01:13:19 -0500 )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.

( 2014-01-28 01:33:33 -0500 )edit

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

( 2014-01-28 01:49:44 -0500 )edit

Sort by » oldest newest most voted

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} )
link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS})


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.

more

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

( 2014-01-28 01:15:06 -0500 )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.

( 2014-01-28 02:20:46 -0500 )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

( 2014-01-28 02:23:40 -0500 )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

( 2014-04-23 15:20:04 -0500 )edit

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/ )

more

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.

more