資源簡介
使用PCL實現的歐幾里德聚類ROS節點,配合地面過濾可實現較為理想的激光雷達障礙物檢測,具體見博客鏈接:https://blog.csdn.net/AdamShan/article/details/83015570

代碼片段和文件信息
#include?“euclidean_cluster_core.h“
EuClusterCore::EuClusterCore(ros::NodeHandle?&nh)
{
????seg_distance_?=?{15?30?45?60};
????cluster_distance_?=?{0.5?1.0?1.5?2.0?2.5};
????sub_point_cloud_?=?nh.subscribe(“/filtered_points_no_ground“?5?&EuClusterCore::point_cb?this);
????pub_bounding_boxs_?=?nh.advertise(“/detected_bounding_boxs“?5);
????ros::spin();
}
EuClusterCore::~EuClusterCore()?{}
void?EuClusterCore::publish_cloud(const?ros::Publisher?&in_publisher
??????????????????????????????????const?pcl::PointCloud::Ptr?in_cloud_to_publish_ptr
??????????????????????????????????const?std_msgs::Header?&in_header)
{
????sensor_msgs::PointCloud2?cloud_msg;
????pcl::toROSMsg(*in_cloud_to_publish_ptr?cloud_msg);
????cloud_msg.header?=?in_header;
????in_publisher.publish(cloud_msg);
}
void?EuClusterCore::voxel_grid_filer(pcl::PointCloud::Ptr?in?pcl::PointCloud::Ptr?out?double?leaf_size)
{
????pcl::VoxelGrid?filter;
????filter.setInputCloud(in);
????filter.setLeafSize(leaf_size?leaf_size?leaf_size);
????filter.filter(*out);
}
void?EuClusterCore::cluster_segment(pcl::PointCloud::Ptr?in_pc
????????????????????????????????????double?in_max_cluster_distance?std::vector?&obj_list)
{
????pcl::search::KdTree::Ptr?tree(new?pcl::search::KdTree);
????//create?2d?pc
????pcl::PointCloud::Ptr?cloud_2d(new?pcl::PointCloud);
????pcl::copyPointCloud(*in_pc?*cloud_2d);
????//make?it?flat
????for?(size_t?i?=?0;?i?points.size();?i++)
????{
????????cloud_2d->points[i].z?=?0;
????}
????if?(cloud_2d->points.size()?>?0)
????????tree->setInputCloud(cloud_2d);
????std::vector?local_indices;
????pcl::EuclideanClusterExtraction?euclid;
????euclid.setInputCloud(cloud_2d);
????euclid.setClusterTolerance(in_max_cluster_distance);
????euclid.setMinClusterSize(MIN_CLUSTER_SIZE);
????euclid.setMaxClusterSize(MAX_CLUSTER_SIZE);
????euclid.setSearchMethod(tree);
????euclid.extract(local_indices);
????for?(size_t?i?=?0;?i?????{
????????//?the?structure?to?save?one?detected?object
????????Detected_Obj?obj_info;
????????float?min_x?=?std::numeric_limits::max();
????????float?max_x?=?-std::numeric_limits::max();
????????float?min_y?=?std::numeric_limits::max();
????????float?max_y?=?-std::numeric_limits::max();
????????float?min_z?=?std::numeric_limits::max();
????????float?max_z?=?-std::numeric_limits::max();
????????for?(auto?pit?=?local_indices[i].indices.begin();?pit?!=?local_indices[i].indices.end();?++pit)
????????{
????????????//fill?new?colored?cluster?point?by?point
????????????pcl::PointXYZ?p;
????????????p.x?=?in_pc->points[*pit].x;
????????????p.y?=?in_pc->points[*pit].y;
????????????p.z?=?in_pc->points[*pit].z;
????????????obj_info.centroid_.x?+=?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-10-08?08:18??euclidean_cluster\
?????文件?????????130??2018-10-08?08:18??euclidean_cluster\euclidean_cluster.launch
?????文件?????????630??2018-10-10?09:14??euclidean_cluster\CMakeLists.txt
?????文件?????????703??2018-10-10?09:15??euclidean_cluster\package.xm
?????目錄???????????0??2018-10-10?13:23??euclidean_cluster\.git\
?????文件?????????845??2018-10-08?08:09??euclidean_cluster\.git\index
?????文件??????????17??2018-09-29?12:40??euclidean_cluster\.git\COMMIT_EDITMSG
?????文件?????????276??2018-09-29?12:41??euclidean_cluster\.git\config
?????文件???????????0??2018-09-29?12:39??euclidean_cluster\.git\FETCH_HEAD
?????文件??????????23??2018-09-29?12:33??euclidean_cluster\.git\HEAD
?????文件??????????73??2018-09-29?12:33??euclidean_cluster\.git\desc
?????目錄???????????0??2018-10-08?08:11??euclidean_cluster\include\
?????文件????????2035??2018-10-10?12:13??euclidean_cluster\include\euclidean_cluster_core.h
?????目錄???????????0??2018-10-08?08:11??euclidean_cluster\src\
?????文件????????7853??2018-10-10?13:23??euclidean_cluster\src\euclidean_cluster_core.cpp
?????文件?????????226??2018-10-08?08:21??euclidean_cluster\src\euclidean_cluster_node.cpp
?????目錄???????????0??2018-09-25?08:16??euclidean_cluster\.vscode\
?????文件?????????766??2018-09-25?08:16??euclidean_cluster\.vscode\c_cpp_properties.json
?????文件?????????170??2018-09-25?08:16??euclidean_cluster\.vscode\settings.json
?????目錄???????????0??2018-09-29?12:41??euclidean_cluster\.git\refs\
?????目錄???????????0??2018-09-29?12:40??euclidean_cluster\.git\logs\
?????文件?????????165??2018-09-29?12:40??euclidean_cluster\.git\logs\HEAD
?????目錄???????????0??2018-09-29?12:40??euclidean_cluster\.git\ob
?????目錄???????????0??2018-09-29?12:33??euclidean_cluster\.git\branches\
?????目錄???????????0??2018-09-29?12:33??euclidean_cluster\.git\info\
?????文件?????????240??2018-09-29?12:33??euclidean_cluster\.git\info\exclude
?????目錄???????????0??2018-09-29?12:33??euclidean_cluster\.git\hooks\
?????文件?????????896??2018-09-29?12:33??euclidean_cluster\.git\hooks\commit-msg.sample
?????文件????????1348??2018-09-29?12:33??euclidean_cluster\.git\hooks\pre-push.sample
?????文件?????????424??2018-09-29?12:33??euclidean_cluster\.git\hooks\pre-applypatch.sample
?????文件????????3610??2018-09-29?12:33??euclidean_cluster\.git\hooks\update.sample
............此處省略45個文件信息
評論
共有 條評論