Rosanswers logo

i wrote a ros node for kinect pointcloud 2 to pass through filter and publish it to a topic. But when i run the node, it give me this error

/usr/include/boost/smart_ptr/shared_ptr.hpp:646: typename boost::detail::sp_dereference::type boost::shared_ptr::operator*() const [with T = pcl::PointCloudpcl::PointXYZ; typename boost::detail::sp_dereference::type = pcl::PointCloudpcl::PointXYZ&]: Assertion `px != 0' failed. Aborted (core dumped)

I cant seem to fix this problem. please help

class Listener


    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_passthrough;

    void callback(const sensor_msgs::PointCloud2ConstPtr& kinect_output);

// end class

void Listener::callback(const sensor_msgs::PointCloud2ConstPtr& kinect_output)
    pcl::PCLPointCloud2::Ptr pc2 (new pcl::PCLPointCloud2());

    pcl_conversions::toPCL (*kinect_output, *pc2);
    pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ());
    pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
    sor.setInputCloud (pc2);
    sor.filter(*cloud_filtered);// filter the point cloud
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloudXYZ (new pcl::PointCloud<pcl::PointXYZ>);//object cloud for point cloud type XYZ
    //create passthrough filter object
    pcl::PassThrough<pcl::PointXYZ> pass;
    pass.setInputCloud (cloudXYZ);
    pass.setFilterLimits(0.5, 1.5);

int main (int argc, char **argv)
    ros::init (argc, argv, "PointCloud2_to_pointCloudXYZ");

    ros::NodeHandle nh;

    Listener listener;
    ros::Publisher pub = nh.advertise<pcl::PointCloud<pcl::PointXYZ> >("/filtered", 1000);
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
    cloud -> points = listener.cloud_passthrough->points;
    ros::Rate loop_rate(10);    
    ros::Subscriber sub = nh.subscribe <sensor_msgs::PointCloud2> ("/camera/depth/points",1000,&Listener::callback, &listener);
    while (ros::ok())
        pub.publish (cloud);
    }//end while loop   
    return 0;
}//end main

Originally posted by dmngu9 on ROS Answers with karma: 150 on 2015-03-27

Post score: 1

Original comments

Comment by dmngu9 on 2015-03-27:
Must be the intraprocesd in node. How can i go about it?


1 Answer 1


Rosanswers logo

Assertion 'px != 0' failed. means that you're using a boost::shared_ptr before it's initialized somewhere.

In particular, I notice that you're not initializing cloud_passthrough anywhere. You should probably write a constructor for your Listener class and initialize it there.

Originally posted by ahendrix with karma: 47576 on 2015-03-29

This answer was ACCEPTED on the original site

Post score: 9


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.