Question about ROS basics [closed]

asked 2020-05-05 10:50:58 -0500

harden gravatar image

updated 2020-05-06 20:01:34 -0500

Hi, I wrote a code about clustering some pointcloud but everytime I tried to run it it gives me this error :

clustering-3] process has died [pid 24822, exit code -11, cmd /home/name/catkin_ws/devel/lib/clustering/clustering_node __name:=clustering __log:=/home/name/.ros/log/a2aa252e-8ee4-11ea-ab03-5800e3afdc5d/clustering-3.log].

I thought at first that I have error in code but I tried to delete some basics line of code that it's surely correct and it worked. Is it possible that my subscriber can't run program fast enough and publish before another messages came. Because my algorithm is not very efficient, I think that complexity is O(n^2). Do you know how to take maybe every 10. messages in subscriber or something similar that could help? Sorry to bother, I'm new in ROS. Kind regards

p.s. I implement function Length of that return number of elements in array and funtions Rangequery that return me pointer of array with indexes (of first pointcloud) of closest neighbours of element My subscriber code is this :

void Cluster_class::DbScan(const sensor_msgs::PointCloud2 &msg ){  

    pcl::PCLPointCloud2 pcl_pc2;
    pcl_conversions::toPCL(msg, pcl_pc2);
    pcl::PointCloud<pcl::PointXYZI> cloud;
    pcl::fromPCLPointCloud2(pcl_pc2, cloud);

    boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI>> scan_cloud(new pcl::PointCloud<pcl::PointXYZI>);
    scan_cloud->height = 1;
    scan_cloud->is_dense = 1;
    scan_cloud->header.frame_id = msg.header.frame_id;

    number_of_points= msg.width;
    int number_of_clusters=0;

    for(int i=0; i<number_of_points; i++){   
    float coef1=0;
    float coef=1./(cloud[i].intensity*10);  
    float distance =Distance(cloud[i].x,cloud[i].y,cloud[i].z);

    if((coef<0.05)&(distance>0.2)){

        int *new_neighbors;
        int *neighbors=RangeQuery(cloud,0.3,cloud[i].x,cloud[i].y,cloud[i].z);

        if(Lenghtof(neighbors)>1){


        for(int j=0; j<Lenghtof(neighbors); j++){
            int help= *(neighbors + j);
            coef1=1./(cloud[help].intensity*10);


           if(coef1<0.05){
             new_neighbors=RangeQuery(cloud,0.3,cloud[neighbors[j]].x,cloud[neighbors[j]].y,cloud[neighbors[j]].z );


             if(Lenghtof(new_neighbors)>2){
             neighbors=Add_new(new_neighbors,neighbors);
             }
            }


        }



        }

        scan_cloud->points[number_of_clusters].x=centralize_x(cloud,neighbors);
        scan_cloud->points[number_of_clusters].y=centralize_y(cloud,neighbors);
        scan_cloud->points[number_of_clusters].y=centralize_z(cloud,neighbors); 
        number_of_clusters++;

        } 
    }  
    scan_cloud->width = number_of_clusters;
    scan_cloud->points.resize(scan_cloud->width * scan_cloud->height);
    pub.publish(scan_cloud);

}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by stevemacenski
close date 2020-05-06 20:37:31.941985

Comments

2

Compile with debug flags and find the error.

stevemacenski gravatar image stevemacenski  ( 2020-05-05 11:08:09 -0500 )edit

thank you, I found it with help of debug flags. Do you maybe know is there any way to pass velocity parametar for every point via pcl::PointCloud<pcl::pointxyzi> ?

harden gravatar image harden  ( 2020-05-06 19:53:33 -0500 )edit

You'd need a different pcl::Point template, you can easily create custom ones. I'd check on PCL docs for examples.

stevemacenski gravatar image stevemacenski  ( 2020-05-06 20:37:15 -0500 )edit

Closing because you found the issue, you're welcome to open a new on on the point thing, but on the PCL forums

stevemacenski gravatar image stevemacenski  ( 2020-05-06 20:37:56 -0500 )edit