29 namespace perception {
35 template <
typename Po
intT>
37 const PointT& center_pt,
float radius,
float neighbour_dist,
40 for (
size_t c = 0; c < cloud->width(); ++c) {
41 for (
size_t r = 0; r < cloud->height(); ++r) {
43 if (cloud->height() > 1) {
44 const PointT* tmp_pt_ptr = cloud->at(c, r);
45 if (tmp_pt_ptr ==
nullptr) {
48 tmp_pt = *(tmp_pt_ptr);
50 tmp_pt = cloud->at(c);
52 if (CalculateEuclidenDist<PointT>(tmp_pt, center_pt) < radius) {
53 if (down_cloud->size() == 0) {
54 down_cloud->push_back(tmp_pt);
56 if (CalculateEuclidenDist<PointT>(
57 tmp_pt, down_cloud->at(down_cloud->size() - 1)) >=
59 down_cloud->push_back(tmp_pt);
71 template <
typename Po
intT>
73 const PointT& center_pt,
int smp_ratio,
float radius,
int velodyne_model,
76 int smp_step = smp_ratio * velodyne_model;
77 down_cloud->resize(cloud->size() / smp_ratio + 1);
79 for (
size_t ori_ii = 0; ori_ii < cloud->size(); ori_ii += smp_step) {
80 for (
size_t jj = ori_ii;
81 jj < cloud->size() &&
static_cast<int>(jj - ori_ii) < velodyne_model;
83 const PointT& p = cloud->at(jj);
84 if (std::isnan(p.x) || std::isnan(p.y) || std::isnan(p.z)) {
87 float r = CalculateEuclidenDist2DXY<PointT>(center_pt, p);
91 down_cloud->at(jj).x = cloud->at(jj).x;
92 down_cloud->at(jj).y = cloud->at(jj).y;
93 down_cloud->at(jj).z = cloud->at(jj).z;
97 down_cloud->resize(ii);
103 template <
typename Po
intT>
105 const PointT& center_pt,
int org_num,
int smp_ratio,
float radius,
109 std::vector<std::pair<int, int>>* all_org_idx_ptr) {
110 int smp_height =
static_cast<int>(cloud->height()) / smp_ratio;
111 int smp_width = org_num;
112 if (smp_width < 1 || smp_width >= velodyne_model) {
113 AERROR <<
"org_num error!";
117 down_cloud->resize(smp_height * smp_width);
118 all_org_idx_ptr->resize(smp_height * smp_width);
119 for (
int hh = 0; hh < smp_height; ++hh) {
120 for (
int ww = 0; ww < smp_width; ++ww) {
121 int ori_hh = hh * smp_ratio;
122 const PointT* p_ptr = cloud->at(ww, ori_hh);
123 if (p_ptr ==
nullptr) {
126 const PointT& p = *(p_ptr);
127 if (std::isnan(p.x) || std::isnan(p.y) || std::isnan(p.z)) {
130 float r = CalculateEuclidenDist2DXY<PointT>(center_pt, p);
134 down_cloud->at(ii) = p;
135 all_org_idx_ptr->at(ii).first = hh;
136 all_org_idx_ptr->at(ii).second = ww;
141 down_cloud->resize(ii);
142 all_org_idx_ptr->resize(ii);
147 template <
typename Po
intT>
149 int org_num,
int smp_ratio,
float front_range,
float side_range,
153 std::vector<std::pair<int, int>>* all_org_idx_ptr) {
154 int smp_height =
static_cast<int>(cloud->height()) / smp_ratio;
155 int smp_width = org_num;
156 if (smp_width < 1 || smp_width >= velodyne_model) {
157 AERROR <<
"org_num error!";
161 down_cloud->resize(smp_height * smp_width);
162 all_org_idx_ptr->resize(smp_height * smp_width);
163 for (
int hh = 0; hh < smp_height; ++hh) {
164 for (
int ww = 0; ww < smp_width; ++ww) {
165 int ori_hh = hh * smp_ratio;
166 const PointT* p_ptr = cloud->at(ww, ori_hh);
167 if (p_ptr ==
nullptr) {
170 const PointT& p = *(p_ptr);
171 if (std::isnan(p.x) || std::isnan((p.y) || std::isnan(p.z))) {
174 if (fabs(p.x) > front_range || fabs(p.y) > side_range) {
177 down_cloud->at(ii) = p;
178 all_org_idx_ptr->at(ii).first = hh;
179 all_org_idx_ptr->at(ii).second = ww;
184 down_cloud->resize(ii);
185 all_org_idx_ptr->resize(ii);
190 template <
typename Po
intT>
192 float front_range,
float side_range,
double max_nei,
int velo_model,
195 if (static_cast<int>(cloud->width()) != velo_model) {
196 AERROR <<
"cloud->width (" << cloud->width() <<
") does not match " 197 <<
"velo_model (" << velo_model <<
")";
200 down_cloud->resize(cloud->size());
202 for (
size_t ww = 0; ww < cloud->width(); ++ww) {
207 for (
size_t hh = 0; hh < cloud->height(); ++hh) {
208 const PointT* p_ptr = cloud->at(ww, hh);
209 if (p_ptr ==
nullptr) {
212 const PointT& p = *(p_ptr);
213 if (std::isnan(p.x) || std::isnan(p.y) || std::isnan(p.z)) {
216 if (fabs(p.x) > front_range || fabs(p.y) > side_range) {
219 if (fabs(p.x - nei_pt.x) > max_nei || fabs(p.y - nei_pt.y) > max_nei) {
221 down_cloud->at(pt_num++) = p;
225 down_cloud->resize(pt_num);
void DownsamplingCircularOrgPartial(const PointT ¢er_pt, int org_num, int smp_ratio, float radius, int velodyne_model, const typename std::shared_ptr< const base::PointCloud< PointT >> cloud, typename std::shared_ptr< base::PointCloud< PointT >> down_cloud, std::vector< std::pair< int, int >> *all_org_idx_ptr)
Definition: downsampling.h:104
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void DownsamplingCircular(const PointT ¢er_pt, float radius, float neighbour_dist, typename std::shared_ptr< const base::PointCloud< PointT >> cloud, typename std::shared_ptr< base::PointCloud< PointT >> down_cloud)
Definition: downsampling.h:36
Definition: point_cloud.h:37
void DownsamplingRectangleOrgPartial(int org_num, int smp_ratio, float front_range, float side_range, int velodyne_model, typename std::shared_ptr< const base::PointCloud< PointT >> cloud, typename std::shared_ptr< base::PointCloud< PointT >> down_cloud, std::vector< std::pair< int, int >> *all_org_idx_ptr)
Definition: downsampling.h:148
void DownsamplingCircularOrgAll(const PointT ¢er_pt, int smp_ratio, float radius, int velodyne_model, typename std::shared_ptr< const base::PointCloud< PointT >> cloud, typename std::shared_ptr< base::PointCloud< PointT >> down_cloud)
Definition: downsampling.h:72
void DownsamplingRectangleNeighbour(float front_range, float side_range, double max_nei, int velo_model, typename std::shared_ptr< const base::PointCloud< PointT >> cloud, typename std::shared_ptr< base::PointCloud< PointT >> down_cloud)
Definition: downsampling.h:191
#define AERROR
Definition: log.h:44