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

Unable to compile subscriber PointCloud<PointT>

asked 2014-01-30 05:15:11 -0500

mark_vision gravatar image

updated 2014-04-20 14:09:28 -0500

ngrennan gravatar image

Hi, I have a node written by someone else that I do not want to modify. The node publish a pcl::PointCloud<pointxyzrgb>

I just want to take the cloud, process it and publish a new cloud of the same type. I tried the simplest code possible, but it does not compile. Here there is the code (note that I commented out many things to make the example as simple as possible):

#include <ros ros.h="">
// PCL specific includes
#include <pcl_conversions pcl_conversions.h="">
#include <pcl point_cloud.h="">
#include <pcl point_types.h="">
#include <std_msgs string.h="">
#include <sstream>
#include <iostream>

using namespace std;

ros::Publisher pub;
//bool firstone = true;
//int banana = 0;
//pcl::PointCloud<pcl::pointxyzrgb> firstCloud;
//pcl::PointCloud<pcl::pointxyzrgb> secondCloud;

void cloud_cb(const pcl::PointCloud<pcl::pointxyzrgb>::ConstPtr&amp; input) {

//    if (firstone) {
//        firstCloud = (*input);
//        firstone = false;
//    } else {
//        secondCloud = (*input);
//        firstone = true;
//    }
//    std_msgs::String msg;
//    std::stringstream ss;
//    ss &lt;&lt; banana &lt;&lt; "  " &lt;&lt; "Width: " &lt;&lt; (*input).width &lt;&lt; "Height: " &lt;&lt; (*input).height &lt;&lt; endl;
//    banana++;
// = ss.str();
//    pub.publish(msg);


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

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

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

catkin_make shoots this:

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/hyq_registration/src/hyq_registration.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::PointCloud<pcl::pointxyzrgb>]’:
/opt/ros/hydro/include/ros/message_traits.h:228:103:   instantiated from ‘const char* ros::message_traits::md5sum() [with M = pcl::PointCloud<pcl::pointxyzrgb>]’
/opt/ros/hydro/include/ros/subscribe_options.h:110:5:   instantiated from ‘void ros::SubscribeOptions::init(const string&amp;, uint32_t, const boost::function<void(const boost::shared_ptr<const="" m="">&amp;)&gt;&amp;, const boost::function<boost::shared_ptr<t>()&gt;&amp;) [with M = pcl::PointCloud<pcl::pointxyzrgb>, std::string = std::basic_string<char>, uint32_t = unsigned int]’
/opt/ros/hydro/include/ros/node_handle.h:666:5:   instantiated from ‘ros::Subscriber ros::NodeHandle::subscribe(const string&amp;, uint32_t, void (*)(const boost::shared_ptr<const m="">&amp;), const ros::TransportHints&amp;) [with M = pcl::PointCloud<pcl::pointxyzrgb>, std::string = std::basic_string<char>, uint32_t = unsigned int]’
/home/mcamurri/hyq-ws/src/hyq_registration/src/hyq_registration.cpp:49:81:   instantiated from here
/opt/ros/hydro/include/ros/message_traits.h:121:37: error: ‘__s_getMD5Sum’ is not a member of ‘pcl::PointCloud<pcl::pointxyzrgb>’
/opt/ros/hydro/include/ros/message_traits.h: In static member function ‘static const char* ros::message_traits::DataType<m>::value() [with M = pcl::PointCloud<pcl::pointxyzrgb>]’:
/opt/ros/hydro/include/ros/message_traits.h:237:105 ...
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-01-30 05:31:56 -0500

mark_vision gravatar image

updated 2014-01-30 05:32:36 -0500

OK I figured it out:

I was supposed to use

#include <pcl_ros point_cloud.h="">

instead of:

#include <pcl point_cloud.h="">

This is very confusing, though.

Why is ROS using so many types (PointCloud, PointCloud2, etc.) with similar features? Why don't they use only the pcl::PointCloud type and then create proper functions to manage it instead of using custom header files?


edit flag offensive delete link more


I don't know why the code is like that, the preview was correct.

mark_vision gravatar image mark_vision  ( 2014-01-30 05:33:20 -0500 )edit

Because PCL's data types evolved. More information here:

bchr gravatar image bchr  ( 2014-01-30 05:54:17 -0500 )edit

Question Tools

1 follower


Asked: 2014-01-30 05:15:11 -0500

Seen: 963 times

Last updated: Jan 30 '14