ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
2016-08-31 08:59:19 -0500 | received badge | ● Enthusiast |
2016-08-29 12:48:48 -0500 | asked a question | How can I use the Euclidean Cluster Extraction PCL Method using ROS? Hi there, I am new here... So, I need to write a ROS Node to solve a problem using the Euclidean Cluster Extractionn PCL, but I don't know whats exactly is wrong. Please, help me to understand it. And thank you a lot for that! #include <ros ros.h=""> #include <nodelet nodelet.h=""> #include <sensor_msgs pointcloud2.h=""> #include <pcl_conversions pcl_conversions.h=""> #include <pcl point_cloud.h=""> #include <pcl point_types.h=""> #include <boost foreach.hpp=""> #include <sstream> #include "novinho_laser/Vai.h" #include <pcl modelcoefficients.h=""> #include <pcl point_types.h=""> #include <pcl io="" pcd_io.h=""> #include <pcl filters="" extract_indices.h=""> #include <pcl filters="" voxel_grid.h=""> #include <pcl features="" normal_3d.h=""> #include <pcl kdtree="" kdtree.h=""> #include <pcl sample_consensus="" method_types.h=""> #include <pcl sample_consensus="" model_types.h=""> #include <pcl segmentation="" sac_segmentation.h=""> #include <pcl segmentation="" extract_clusters.h=""> ros::Publisher pub; using namespace pcl; using namespace std; typedef pcl::PointXYZ PointT; typedef pcl::PointCloud<pointt> PointCloudT; void cloud_cb ( const sensor_msgs::PointCloud2 input ) { pcl::PCLPointCloud2 pcl_pc; pcl_conversions::toPCL ( input, pcl_pc ); pcl::PointCloud<pcl::pointxyz> cloud, cloud_f; pcl::fromPCLPointCloud2 ( pcl_pc, cloud ); //!< Create the filtering object: downsample the dataset using a leaf size of 1cm pcl::VoxelGrid<pcl::pointxyz> vg; pcl::PointCloud<pcl::pointxyz>::Ptr cloud_filtered ( new pcl::PointCloud<pcl::pointxyz> ); vg.setInputCloud ( cloud_f ); // ...cloud -> cloud_f vg.setLeafSize ( 0.01f, 0.01f, 0.01f ); vg.filter ( *cloud_filtered ); //!< Create the segmentation object for the planar model and set all the parameters pcl::SACSegmentation<pcl::pointxyz> seg; pcl::PointIndices::Ptr inliers ( new pcl::PointIndices ); pcl::ModelCoefficients::Ptr coefficients ( new pcl::ModelCoefficients ); pcl::PointCloud<pcl::pointxyz>::Ptr cloud_plane ( new pcl::PointCloud<pcl::pointxyz> ( ) ); seg.setOptimizeCoefficients ( true ); seg.setModelType ( pcl::SACMODEL_PLANE ); seg.setMethodType ( pcl::SAC_RANSAC ); seg.setMaxIterations ( 100 ); seg.setDistanceThreshold ( 0.02 ); int i = 0, nr_points = ( int ) cloud_filtered->points.size ( ); while ( cloud_filtered->points.size ( ) > 0.3 * nr_points ) { //!< Segment the largest planar component from the remaining cloud seg.setInputCloud ( cloud_filtered ); seg.segment ( *inliers, *coefficients ); if (inliers->indices.size ( ) == 0 ) break; } //!< Creating the KdTree object for the search method of the extraction pcl::search::KdTree<pcl::pointxyz>::Ptr tree ( new pcl::search::KdTree<pcl::pointxyz> ); tree->setInputCloud ( cloud_filtered ); std::vector<pcl::pointindices> cluster_indices; pcl::EuclideanClusterExtraction<pcl::pointxyz> ec; ec.setClusterTolerance ( 0.02 ); // 2cm ec.setMinClusterSize ( 100 ); ec.setMaxClusterSize ( 25000 ); ec.setSearchMethod ( tree ); ec.setInputCloud ( cloud_filtered ); ec.extract ( cluster_indices ); for ( std::vector<pcl::pointindices>::const_iterator it = cluster_indices.begin ( ); it != cluster_indices.end ( ); ++it ) { pcl::PointCloud<pcl::pointxyz>::Ptr cloud_cluster ( new pcl::PointCloud<pcl::pointxyz> ); for ( std::vector<int>::const_iterator pit = it->indices.begin ( ); pit != it->indices.end ( ); ++pit ) cloud_cluster->points.push_back ( cloud_filtered->points [ *pit ] ); cloud_cluster->width = cloud_cluster->points.size ( ); cloud_cluster->height = 1; cloud_cluster->is_dense = true; } float x = 0.0, y = 0.0, z = 1e6; unsigned int n = 0; //!< - Number of points observed (more) |
2016-04-04 12:34:29 -0500 | answered a question | Navigation of turtlebot (Moving 1m forward, 1m left) Hi, dylankc. Did you solve this problem?... If yes, how could you do that? Thanks |
2016-02-15 20:45:17 -0500 | received badge | ● Popular Question (source) |
2016-02-15 13:06:43 -0500 | commented question | Kd-tree to search on ROS Sorry, and thank you for your comment :) |
2016-02-15 12:58:28 -0500 | received badge | ● Editor (source) |
2016-02-15 12:24:49 -0500 | asked a question | Kd-tree to search on ROS Hi there! I'm sorry if the question is very simple, but it's the first time that I try to use ROS and PCL too. I'd like to adapt the code of this link: to use on ROS and visualize the result on Rviz. What I need to change of the code below?... |