udacity sensor fusion(1)Lidar Obstacle Detection学习记录

INTRODUCE TO LIDAR AND POINTS CLOUDS

10 The course starter code

告诉了这一部分代码的主要作用
在这里插入图片描述

13 The PCL Viewer

解释了PCL库中的VIEWER,在environment.cpp中,将初始化的viewer传引用到两个函数中

15 ~ 16

使用lidar.h中的structure

  1. 初始化struct pointor lidar
  2. 调用lidar->scan(),创建pcl::PointXYZ 类型的点云
  3. 调用PCL viewer可视化创建的点云

17 Templates and Different Point Cloud Data

  1. 介绍模板的概念:
    http://www.cplusplus.com/doc/oldtutorial/templates/
    Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type.

The format for declaring function templates with type parameters is:

template <class identifier> function_declaration;
template <typename identifier> function_declaration;

For example, to create a template function that returns the greater one of two objects we could use:

template <class myType>
myType GetMax (myType a, myType b) {
 return (a>b?a:b);
}

To use this function template we use the following format for the function call:

 function_name <type> (parameters);

For example, to call GetMax to compare two integer values of type int we can write:

int x,y;
GetMax <int> (x,y); // <int>中int就相当于myType,调用时要放在函数名之后

Point Cloud Segmentation

For the most part, any free space on the road is not an obstacle, and if the road is flat it’s fairly straightforward to pick out road points from non-road points. To do this we will use a method called Planar Segmentation which uses the RANSAC (random sample consensus) algorithm.

03 Point Processing

在Environment里面初始化一个ProcessPointClouds类对象
可以使用两种方式:heap 和 stack, 以及注意模板类方法的使用

    // TODO:: Create point processor
    // Template type is going to be a PCL point XYZ
    
    // ProcessPointClouds<pcl::PointXYZ> pointProcessor // instantiate on the stack
    ProcessPointClouds<pcl::PointXYZ>* pointProcessor = new ProcessPointClouds<pcl::PointXYZ>(); // instantiate on the heap | use open parentheses to instantiate it

04 Segmenting the Plane with PCL

// At the top of the function, you will notice a template parameter PointT. 
// You will be using this as a variable to represent any type of point cloud, 
// and it will come in handy later when you are processing point clouds with intensity values.
// SegmentPlane Function Signature
 std::pair<typename pcl::PointCloud<PointT>::Ptr, typename pcl::PointCloud<PointT>::Ptr> SegmentPlane(typename pcl::PointCloud<PointT>::Ptr cloud, int maxIterations, float distanceThreshold);
 
 // The function accepts a point cloud, max iterations, and distance tolerance as arguments. 
 // Segmentation uses an iterative process. More iterations have a chance of returning better results 
 // but take longer. The segmentation algorithm fits a plane to the points and uses the distance tolerance
 // to decide which points belong to that plane. A larger tolerance includes more points in the plane. 
// Extracting indices from a PointCloud
// http://pointclouds.org/documentation/tutorials/extract_indices.php#extract-indices

05 Separating Point Clouds

在这里插入图片描述

  1. 主要是完成ProcessPointClouds类模板中的两个模板函数
    SeparateClouds();// 分割后pcl extract点云提取参数设置

SegmentPlane(); // 分割pcl segment参数的设置

参考:
http://pointclouds.org/documentation/tutorials/extract_indices.php#extract-indices

06. RANSAC

RANSAC overview

One type of RANSAC version selects the smallest possible subset of points to fit. For a line, that would be two points, and for a plane three points. Then the number of inliers are counted, by iterating through every remaining point and calculating its distance to the model. The points that are within a certain distance to the model are counted as inliers. The iteration that has the highest number of inliers is then the best model. This will be the version that you will implement in this quiz.

RANSAC的其他损失函数:
Other methods of RANSAC could sample some percentage of the model points, for example 20% of the total points, and then fit a line to that. Then the error of that line is calculated, and the iteration with the lowest error is the best model. This method might have some advantages since not every point at each iteration needs to be considered. It’s good to experiment with different approaches and time results to see what works best.

07. Implementing RANSAC for Lines

quiz about RANSAC

08 Implementing RANSAC for Plane

Clustering Obstacles

The idea is you associate groups of points by how close together they are. To do a nearest neighbor search efficiently, you use a KD-Tree data structure which, on average, speeds up your look up time from O(n) to O(log(n)).

This is because the tree allows you to better break up your search space. By grouping points into regions in a KD-Tree, you can avoid calculating distance for possibly thousands of points just because you know they are not even considered in a close enough region.

Euclidean Clustering with PCL

  1. Any points within that distance will be grouped together. It also has min and max arguments for the number of points to represent as clusters.

  2. The idea is: if a cluster is really small, it’s probably just noise and we are not concerned with it.
    Also a max number of points allows us to better break up very large clusters.

  3. if a cluster is very large it might just be that many other clusters are overlapping, and a max tolerance can help us better resolve the object detections.

  4. The last argument to the euclidean cluster object is the Kd-Tree. The tree is created and built using the input cloud points, which in this case are going to be the obstacle cloud points.

03 Euclidean Cluster Extraction

http://pointclouds.org/documentation/tutorials/cluster_extraction.php

  1. 主要是完成ProcessPointClouds类模板中的一个模板函数
    Clustering() // 聚类参数的设置

04 Implementing KD-Tree

在这里插入图片描述
A KD-Tree is a binary tree that splits points between alternating axes. By separating space by splitting regions, nearest neighbor search can be made much faster when using an algorithm like euclidean clustering.

in the function insert which takes a 2D point represented by a vector containing two floats, and a point ID.
The ID is a way to uniquely identify points and a way to tell which index the point is referenced from on the
overall point cloud. 

there is a function for rendering the tree after points have been inserted into it. The image below shows line
separations, with blue lines splitting x regions and red lines splitting y regions. The image shows what the
tree looks like after all 11 points have been inserted, 

在这里插入图片描述

05-08 kdTREE 的quize

09 Bounding Box以及PCA Box的挑战

Working in real PCD

02. Load PCD

在这里插入图片描述

04 Downsampling

Michael:
we down-sample lidar data,
在这里插入图片描述
we convert the point into stixels,like what we do with the stereo cameras, stixels’ basiucally like a matchstick
so if you have the back of a vehicle, the stixels would be putting a bunch of matchsticks to hover the trunk or conver the vehicle, this give you two things:

  1. the number of matchsticks(each one say four inches wide 告诉你车辆宽度 | height of matchsticks告诉你车辆高度),但是你不需要stixel中间的数据,你只需要高度宽度,这样能减少数据

05. Filtering with PCL

在这里插入图片描述
voxel:it is a 3D pixel or called volume pixel 类似于我的世界, each of those blocks is actually a voxel

documentation from PCL for voxel grid filtering and region of interest.

http://pointclouds.org/documentation/tutorials/voxel_grid.php // voxel grid filtering
http://docs.pointclouds.org/trunk/classpcl_1_1_crop_box.html // region of interest.`在这里插入代码片`
主要补全ProcessPointClouds<PointT>::FilterCloud 类模板函数

07. Stream PCD

这一章有filter, segmentation, cluster的一些参数

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值