Robotics StackExchange | Archived questions

error compiling PCL ROS Tutorial

Hi all, i tried the tutorial here

wiki.ros.org/pcl/Tutorials#pcl.2BAC8-PointCloud.3CT.3E

but I get several compiling errors.

My system is: Ubuntu 12.04 with Hydro installed by sudo apt-get install ros-hydro-desktop-full as explained here

wiki.ros.org/hydro/Installation/Ubuntu

there are no other libraries installed. The code is the same used here

wiki.ros.org/pcl/Tutorials?action=AttachFile&do=view&target=example_planarsegmentation.cpp

with the modifications for hydro explained here

wiki.ros.org/pcl/Tutorials#line-1-30

UPDATE: I've corrected something and now the catkin_make output is:

[ 42%] Built target pgrlibdcstereo
[ 57%] Built target shmem_client_triclops
[ 71%] [ 85%] Built target example2
Building CXX object pcl_tutorial/CMakeFiles/example.dir/src/example.cpp.o
[100%] Built target shmem_server_triclops
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp: In function ‘void cloud_cb(const PCLPointCloud2ConstPtr&)’:
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:17:34: error: no matching function for call to ‘fromROSMsg(const pcl::PCLPointCloud2&, pcl::PointCloud<pcl::PointXYZ>&)’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:17:34: note: candidate is:
/opt/ros/hydro/include/pcl_conversions/pcl_conversions.h:486:8: note: template<class T> void pcl::fromROSMsg(const PointCloud2&, pcl::PointCloud<PointT>&)
In file included from /opt/ros/hydro/include/ros/serialization.h:37:0,
                 from /opt/ros/hydro/include/ros/publisher.h:34,
                 from /opt/ros/hydro/include/ros/node_handle.h:32,
                 from /opt/ros/hydro/include/ros/ros.h:45,
                 from /home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:1:
/opt/ros/hydro/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = pcl::ModelCoefficients]’:
/opt/ros/hydro/include/ros/message_traits.h:255:104:   instantiated from ‘const char* ros::message_traits::md5sum(const M&) [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/publisher.h:112:7:   instantiated from ‘void ros::Publisher::publish(const M&) const [with M = pcl::ModelCoefficients]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:35:29:   instantiated from here
/opt/ros/hydro/include/ros/message_traits.h:126:34: error: ‘const struct pcl::ModelCoefficients’ has no member named ‘__getMD5Sum’
/opt/ros/hydro/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::DataType<M>::value(const M&) [with M = pcl::ModelCoefficients]’:
/opt/ros/hydro/include/ros/message_traits.h:264:106:   instantiated from ‘const char* ros::message_traits::datatype(const M&) [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/publisher.h:112:7:   instantiated from ‘void ros::Publisher::publish(const M&) const [with M = pcl::ModelCoefficients]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:35:29:   instantiated from here
/opt/ros/hydro/include/ros/message_traits.h:143:36: error: ‘const struct pcl::ModelCoefficients’ has no member named ‘__getDataType’
In file included from /opt/ros/hydro/include/ros/publisher.h:34:0,
                 from /opt/ros/hydro/include/ros/node_handle.h:32,
                 from /opt/ros/hydro/include/ros/ros.h:45,
                 from /home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:1:
/opt/ros/hydro/include/ros/serialization.h: In static member function ‘static uint32_t ros::serialization::Serializer<T>::serializedLength(typename boost::call_traits<T>::param_type) [with T = pcl::ModelCoefficients, uint32_t = unsigned int, typename boost::call_traits<T>::param_type = const pcl::ModelCoefficients&]’:
/opt/ros/hydro/include/ros/serialization.h:172:43:   instantiated from ‘uint32_t ros::serialization::serializationLength(const T&) [with T = pcl::ModelCoefficients, uint32_t = unsigned int]’
/opt/ros/hydro/include/ros/serialization.h:848:45:   instantiated from ‘ros::SerializedMessage ros::serialization::serializeMessage(const M&) [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/publisher.h:118:7:   instantiated from ‘void ros::Publisher::publish(const M&) const [with M = pcl::ModelCoefficients]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:35:29:   instantiated from here
/opt/ros/hydro/include/ros/serialization.h:144:34: error: ‘const struct pcl::ModelCoefficients’ has no member named ‘serializationLength’
/opt/ros/hydro/include/ros/serialization.h: In static member function ‘static void ros::serialization::Serializer<T>::write(Stream&, typename boost::call_traits<T>::param_type) [with Stream = ros::serialization::OStream, T = pcl::ModelCoefficients, typename boost::call_traits<T>::param_type = const pcl::ModelCoefficients&]’:
/opt/ros/hydro/include/ros/serialization.h:154:3:   instantiated from ‘void ros::serialization::serialize(Stream&, const T&) [with T = pcl::ModelCoefficients, Stream = ros::serialization::OStream]’
/opt/ros/hydro/include/ros/serialization.h:855:3:   instantiated from ‘ros::SerializedMessage ros::serialization::serializeMessage(const M&) [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/publisher.h:118:7:   instantiated from ‘void ros::Publisher::publish(const M&) const [with M = pcl::ModelCoefficients]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:35:29:   instantiated from here
/opt/ros/hydro/include/ros/serialization.h:127:5: error: ‘const struct pcl::ModelCoefficients’ has no member named ‘serialize’
In file included from /opt/ros/hydro/include/ros/serialization.h:37:0,
                 from /opt/ros/hydro/include/ros/publisher.h:34,
                 from /opt/ros/hydro/include/ros/node_handle.h:32,
                 from /opt/ros/hydro/include/ros/ros.h:45,
                 from /home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:1:
/opt/ros/hydro/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::MD5Sum<M>::value() [with M = pcl::ModelCoefficients]’:
/opt/ros/hydro/include/ros/message_traits.h:228:103:   instantiated from ‘const char* ros::message_traits::md5sum() [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/advertise_options.h:92:5:   instantiated from ‘void ros::AdvertiseOptions::init(const string&, uint32_t, const SubscriberStatusCallback&, const SubscriberStatusCallback&) [with M = pcl::ModelCoefficients, std::string = std::basic_string<char>, uint32_t = unsigned int, ros::SubscriberStatusCallback = boost::function<void(const ros::SingleSubscriberPublisher&)>]’
/opt/ros/hydro/include/ros/node_handle.h:239:7:   instantiated from ‘ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool) [with M = pcl::ModelCoefficients, std::string = std::basic_string<char>, uint32_t = unsigned int]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:48:60:   instantiated from here
/opt/ros/hydro/include/ros/message_traits.h:121:37: error: ‘__s_getMD5Sum’ is not a member of ‘pcl::ModelCoefficients’
/opt/ros/hydro/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::DataType<M>::value() [with M = pcl::ModelCoefficients]’:
/opt/ros/hydro/include/ros/message_traits.h:237:105:   instantiated from ‘const char* ros::message_traits::datatype() [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/advertise_options.h:93:5:   instantiated from ‘void ros::AdvertiseOptions::init(const string&, uint32_t, const SubscriberStatusCallback&, const SubscriberStatusCallback&) [with M = pcl::ModelCoefficients, std::string = std::basic_string<char>, uint32_t = unsigned int, ros::SubscriberStatusCallback = boost::function<void(const ros::SingleSubscriberPublisher&)>]’
/opt/ros/hydro/include/ros/node_handle.h:239:7:   instantiated from ‘ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool) [with M = pcl::ModelCoefficients, std::string = std::basic_string<char>, uint32_t = unsigned int]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:48:60:   instantiated from here
/opt/ros/hydro/include/ros/message_traits.h:138:39: error: ‘__s_getDataType’ is not a member of ‘pcl::ModelCoefficients’
/opt/ros/hydro/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::Definition<M>::value() [with M = pcl::ModelCoefficients]’:
/opt/ros/hydro/include/ros/message_traits.h:246:107:   instantiated from ‘const char* ros::message_traits::definition() [with M = pcl::ModelCoefficients]’
/opt/ros/hydro/include/ros/advertise_options.h:94:5:   instantiated from ‘void ros::AdvertiseOptions::init(const string&, uint32_t, const SubscriberStatusCallback&, const SubscriberStatusCallback&) [with M = pcl::ModelCoefficients, std::string = std::basic_string<char>, uint32_t = unsigned int, ros::SubscriberStatusCallback = boost::function<void(const ros::SingleSubscriberPublisher&)>]’
/opt/ros/hydro/include/ros/node_handle.h:239:7:   instantiated from ‘ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool) [with M = pcl::ModelCoefficients, std::string = std::basic_string<char>, uint32_t = unsigned int]’
/home/mcamurri/hyq-ws/src/pcl_tutorial/src/example.cpp:48:60:   instantiated from here
/opt/ros/hydro/include/ros/message_traits.h:155:48: error: ‘__s_getMessageDefinition’ is not a member of ‘pcl::ModelCoefficients’
make[2]: *** [pcl_tutorial/CMakeFiles/example.dir/src/example.cpp.o] Error 1
make[1]: *** [pcl_tutorial/CMakeFiles/example.dir/all] Error 2
make: *** [all] Error 2
Base path: /home/mcamurri/hyq-ws
Source space: /home/mcamurri/hyq-ws/src
Build space: /home/mcamurri/hyq-ws/build
Devel space: /home/mcamurri/hyq-ws/devel
Install space: /home/mcamurri/hyq-ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/mcamurri/hyq-ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/mcamurri/hyq-ws/build"
####
Invoking "make" failed

It seems like it is looking for the old fromROSMsg() method, who accepts sensor_msgs::PointCloud2 instead of pcl::PCLPointCloud2 but the official API clearly states that it accept the PCL one, and also Netbeans says that is ok with pcl::PCLPoincloud2. The code is now this:

   #include <ros/ros.h>
// PCL specific includes
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>

#include <pcl/sample_consensus/model_types.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/segmentation/sac_segmentation.h>

ros::Publisher pub;

void
cloud_cb(const pcl::PCLPointCloud2ConstPtr& input) {

    pcl::PointCloud<pcl::PointXYZ> cloud;
    pcl::fromROSMsg(*input, cloud);


    pcl::ModelCoefficients coefficients;
    pcl::PointIndices inliers;
    // Create the segmentation object
    pcl::SACSegmentation<pcl::PointXYZ> seg;
    // Optional
    seg.setOptimizeCoefficients(true);
    // Mandatory
    seg.setModelType(pcl::SACMODEL_PLANE);
    seg.setMethodType(pcl::SAC_RANSAC);
    seg.setDistanceThreshold(0.01);

    seg.setInputCloud(cloud.makeShared());
    seg.segment(inliers, coefficients);

    // Publish the model coefficients
    pub.publish(coefficients);
}

int
main(int argc, char** argv) {
    // Initialize ROS
    ros::init(argc, argv, "my_pcl_tutorial");
    ros::NodeHandle nh;

    // Create a ROS subscriber for the input point cloud
    ros::Subscriber sub = nh.subscribe("input", 1, cloud_cb);

    // Create a ROS publisher for the output point cloud
    pub = nh.advertise<pcl::ModelCoefficients> ("output", 1);

    // Spin
    ros::spin();
}

the package.xml stuff is:

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>pcl_conversions</build_depend>
  <build_depend>pcl_ros</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>libpcl-all</build_depend>
  <run_depend>pcl_conversions</run_depend>
  <run_depend>pcl_ros</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <run_depend>libpcl-all</run_depend>

and the CMakeLists.txt find package is:

find_package(catkin REQUIRED COMPONENTS
  pcl_conversions
  pcl_ros
  roscpp
  sensor_msgs
)

please help me!!

Asked by mark_vision on 2014-01-27 23:11:42 UTC

Comments

The first part of the tutorial worked fine?

Asked by lfelipesv on 2014-01-28 01:06:17 UTC

Yes the first one works. I corrected some errors on the second one but still doesn't work. I posted the code on the edit. If I try with the old sensor_msgs::PointCloud2 everywhere it shoots other compile errors.

Asked by mark_vision on 2014-01-30 00:42:25 UTC

Answers