-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Your Environment
- Operating System and version: UBUNTU 16.04
- Compiler: CUDA 9.2
- PCL Version: PCL 1.8.1
**CMAKE_LIST
find_package(PCL 1.8.1 REQUIRED)
FIND_PACKAGE(CUDA)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
INCLUDE(FindCUDA)
Context
I want to use Euclidean clustering using gpu. I've built the source and it will be catkin_make, but when I run rosrun, the following error will be displayed.
won@won-desktop:~$ rosrun pharos_laser_taek gpu_cluster
[ INFO] [1531073642.137339770]: started gpu_cluster.cpp
[ INFO] [1531073642.137372028]: SUBTOPIC :
[ INFO] [1531073642.137379877]: PUBTOPIC :
Error: an illegal memory access was encountered /home/won/Downloads/pcl-pcl-1.8.1/gpu/octree/src/cuda/octree_builder.cu:403
how fix it?
Expected Behavior
Current Behavior
Code to Reproduce
//
// Created by won on 28/6/18.
//
#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include <tf/transform_listener.h>
#include <sensor_msgs/LaserScan.h>
#include <geometry_msgs/PointStamped.h>
#include <laser_geometry2/laser_geometry.h>
#include <pcl/gpu/octree/octree.hpp>
//#include <pcl-1.8/pcl/cuda/point_cloud.h>
#include <pcl/gpu/segmentation/gpu_extract_clusters.h>
#include <pcl/gpu/segmentation/impl/gpu_extract_clusters.hpp> //요걸 넣어주니까 되는데 뭐냐?
#include <pcl_ros/point_cloud.h>
#include <pcl_ros/transforms.h>
#include <pcl/point_types.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/features/normal_3d.h>
#include <pcl/filters/statistical_outlier_removal.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/segmentation/extract_clusters.h>
#include <nav_msgs/Path.h>
///전역변수///
///------////
class velodyne_
{
public:
ros::NodeHandlePtr nh;
ros::NodeHandlePtr pnh;
velodyne_()
{
nh = ros::NodeHandlePtr(new ros::NodeHandle(""));
pnh = ros::NodeHandlePtr(new ros::NodeHandle("~"));
///서브스크라이브는 this 사용 publish는 메세지형식 이것만 잘 생각해놓기
get_topic = nh->subscribe("remove_ground", 10 , &velodyne_::GROUND_SEG_CB,this);
gpu_cluster = nh->advertise<sensor_msgs::PointCloud2>("gpu_clustered",10);
}
void GROUND_SEG_CB(const sensor_msgs::PointCloud2Ptr raw_input){
///CALLBACK 함수
pcl::PointCloud<pcl::PointXYZ>::Ptr raw_cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromROSMsg(*raw_input,*raw_cloud);
pcl::PointCloud<pcl::PointXYZI>::Ptr gpu_cloud (new pcl::PointCloud<pcl::PointXYZI>);///gpu클러스터링 통해서 나온거 넣는다.
pcl::PointCloud<pcl::PointXYZ>::Ptr sub_cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZI>::Ptr add_i_cloud (new pcl::PointCloud<pcl::PointXYZI>);
sensor_msgs::PointCloud2 clustering;
if(raw_cloud->points.size() == 0){
return;
}
///1tree사용
///2cluster넣기.
int minclustersize_ = 50;
int maxclustersize_= 3000;
float clustertorlenace_= 0.5;
pcl::gpu::Octree::PointCloud cloud_device;
cloud_device.upload(raw_cloud->points);
pcl::gpu::Octree::Ptr octree_device (new pcl::gpu::Octree);
octree_device->setCloud(cloud_device);
octree_device->build();
std::vector<pcl::PointIndices> cluster_indices_gpu;
pcl::gpu::EuclideanClusterExtraction gec;
gec.setClusterTolerance (clustertorlenace_);
gec.setMinClusterSize (minclustersize_);
gec.setMaxClusterSize (maxclustersize_);
gec.setSearchMethod (octree_device);
gec.setHostCloud(raw_cloud);
gec.extract(cluster_indices_gpu);
std::vector<pcl::PointCloud<pcl::PointXYZI> > clustered_obstacle_cloud_vec;
int INTENSITY = 10;
std::vector<pcl::PointIndices>::const_iterator it;
for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices_gpu.begin();
it != cluster_indices_gpu.end(); ++it) {
///그냥 int i=0~ 끝까지 돌리는것. 객채1 ~객채 2 객체 3 객체 4
sub_cloud->clear(); ///******************************
add_i_cloud->clear();
for (std::vector<int>::const_iterator pit = it->indices.begin(); pit != it->indices.end(); ++pit) {
//한객채 i
// input_ptr->points[*pit].intensity = Intensity_value; //한객체에 일정한 intensity값을 넣어준다.
sub_cloud->points.push_back(raw_cloud->points[*pit]); //그 객체를 클러스터에 넣는다.
/////한객체를 다 넣는것
}
sub_cloud->width = sub_cloud->points.size();
sub_cloud->height = 1;
sub_cloud->is_dense = true;
std::cout<<"worked"<<std::endl;
pcl::copyPointCloud(*sub_cloud,*add_i_cloud);
for(int i=0; i<add_i_cloud->points.size(); i++){
add_i_cloud->points[i].intensity=INTENSITY;
}///INTENSITY값을 입혀준다.
INTENSITY += 20;
if(INTENSITY>=250){
INTENSITY=10;
}
clustered_obstacle_cloud_vec.push_back(*add_i_cloud);
}///마지막 for
for(int i=0; i<clustered_obstacle_cloud_vec.size(); i++)
{
*gpu_cloud+=clustered_obstacle_cloud_vec.at(i);
}
pcl::toROSMsg(*gpu_cloud,clustering);
clustering.header.frame_id = "velodyne";
///가장 가까운 객체는 프레임 어디로?
gpu_cluster.publish(clustering);
}
protected:
ros::Subscriber get_topic;
ros::Publisher gpu_cluster;
};
int main(int argc, char **argv)
{
ros::init(argc, argv, "gpu_cluster"); //노드명 초기화
ROS_INFO("started gpu_cluster.cpp");
ROS_INFO("SUBTOPIC : ");
ROS_INFO("PUBTOPIC : ");
velodyne_ gpu_cl;
ros::spin();
}