ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

epoxi's profile - activity

2015-05-13 02:49:26 -0500 received badge  Teacher (source)
2015-04-18 04:55:35 -0500 received badge  Editor (source)
2015-04-18 04:53:48 -0500 answered a question hi,i have problem with the roscreate-package instruction.
2015-04-17 06:41:11 -0500 answered a question lots of nan data when convert pointcloud2 to pcl::PointXYZ

You still need to remove the NaN values from the point cloud. You can do that in the callback like this:

void callback (pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in_)

        pcl::PointCloud<pcl::PointXYZ> filtered_cloud_ = pcl::PointCloud<pcl::PointXYZ>::Ptr (new pcl::PointCloud<pcl::PointXYZ>);

    //remove NaN points from the cloud
    std::vector<int> indices;
    pcl::removeNaNFromPointCloud(*cloud_in_,*filtered_cloud_, indices);

2015-04-17 06:30:39 -0500 received badge  Popular Question (source)
2015-04-15 06:04:15 -0500 received badge  Enthusiast
2015-04-02 10:34:31 -0500 asked a question Point Cloud subscriber class

Hi, I'm trying to build a class, that allows simple access to a point cloud published in ROS by a Kinect device. It subscribes to a sensor_msgs Point Cloud, converts it to a PCL Point Cloud (which should be accessible through the object instance).

My System

  • ROS Hydro
  • PCL 1.7

My code


#include <ros/ros.h>
#include <ros/package.h>
#include <image_transport/image_transport.h>
#include <sensor_msgs/image_encodings.h>
#include <iostream>

// PCL specific includes
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/point_types.h>
#include <pcl_ros/point_cloud.h>

My connector class.

The currently received point cloud should be accessible through the public pointer "pc".

class CameraConnector

        ros::NodeHandle nh_;

        // point cloud
        ros::Subscriber pc_sub_;


    // point cloud pointer
    pcl::PointCloud<pcl::PointXYZ>::Ptr pc;

    CameraConnector(bool flag);

    /* message callbacks */
    void pc_callback ( const sensor_msgs::PointCloud2ConstPtr& msg );


/* ========================================== *\
\* ========================================== */

/* constructor */
CameraConnector::CameraConnector(bool flag):

  // Subscribe to depth point cloud
  pc_sub_ = nh_.subscribe ("/camera/depth/points", 1, &CameraConnector::pc_callback, this);



/* ========================================== *\
\* ========================================== */

void CameraConnector::pc_callback ( const sensor_msgs::PointCloud2ConstPtr& msg )

    // convert to XYZ PC
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::fromROSMsg(*msg, *cloud);

    // Do some filtering ...

    // set class pointer, so the point cloud can be accessed from outside the class
    pc = &cloud;


The main function:

int main(int argc, char** argv)
    /* ROS stuff */
    ros::init(argc, argv, "dyn_3d_modeling");
    ros::Rate r(10);

    CameraConnector cam(true);
    pcl::visualization::CloudViewer viewer_("Cloud Viewer");

    while (ros::ok())

        /* visualize point cloud at a framerate of 10/sec */



    return 0;


The problem:

I'm not sure how to save a pointer to the current point cloud in the class attribute ptr. I tried it this way:

// set class pointer, so the point cloud can be accessed from outside the class
pc = &cloud;

And then access the point cloud in the main() function through:

CameraConnector cam(true);   // init
cam.pc;   // access the point cloud

But when I compile, the following message shows up:

error: no match for ‘operator=’ in ‘((CameraConnector*)this)->CameraConnector::pc = & cloud’

note: boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(const boost::shared_ptr<T>&) [with T = pcl::PointCloud<pcl::PointXYZ>; boost::shared_ptr<T> = boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >]
/usr/include/boost/smart_ptr/shared_ptr.hpp:309:18: note:   no known conversion for argument 1 from ‘pcl::PointCloud<pcl::PointXYZ>::Ptr* {aka boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >*}’ to ‘const boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >&’
/usr/include/boost/smart_ptr/shared_ptr.hpp:318:18: note: template<class Y> boost::shared_ptr& boost::shared_ptr::operator=(const boost::shared_ptr<Y>&) [with Y = Y; T = pcl::PointCloud<pcl::PointXYZ>]
/usr/include/boost/smart_ptr/shared_ptr.hpp:318:18: note:   template argument deduction/substitution failed:
/home/mat/ros_workspace/dyn_3d_mod/src/pcl_test.cpp:63:8: note:   mismatched types ‘const boost::shared_ptr<X>’ and ‘pcl::PointCloud<pcl::PointXYZ>::Ptr* {aka boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >*}’

I would appreciate any help very much.