95 {
96
97 if (frame == nullptr) {
98 AERROR <<
"Input null frame ptr.";
99 return false;
100 }
101 if (frame->cloud == nullptr) {
102 AERROR <<
"Input null frame cloud.";
103 return false;
104 }
105 if (frame->cloud->size() == 0) {
106 AERROR <<
"Input none points.";
107 return false;
108 }
109
110
111 original_cloud_ = frame->cloud;
112 original_world_cloud_ = frame->world_cloud;
113 lidar_frame_ref_ = frame;
114
115
117
120 return false;
121 }
122
123 Timer timer;
124
125 int num_points;
126 cur_cloud_ptr_ = std::shared_ptr<base::PointFCloud>(
128
129
133 original_cloud_, downsample_beams_cloud_ptr,
135 cur_cloud_ptr_ = downsample_beams_cloud_ptr;
136 } else {
137 AWARN <<
"Down-sample beams factor must be >= 1. Cancel down-sampling."
138 " Current factor: "
140 }
141 }
142
143
145 DownSampleOptions down_sample_options;
146 ACHECK(down_sample_ !=
nullptr);
147 down_sample_->Process(down_sample_options, cur_cloud_ptr_);
148 }
149 downsample_time_ = timer.toc(true);
150
151 num_points = cur_cloud_ptr_->size();
152 AINFO <<
"num points before fusing: " << num_points;
153
154
155 cur_cloud_ptr_->mutable_points_timestamp()->assign(cur_cloud_ptr_->size(),
156 0.0);
159
160 while (!prev_world_clouds_.empty() &&
161 frame->timestamp - prev_world_clouds_.front()->get_timestamp() >
163 prev_world_clouds_.pop_front();
164 }
165
167 std::make_shared<base::PointDCloud>();
168 for (size_t i = 0; i < cur_cloud_ptr_->size(); ++i) {
169 auto& pt = cur_cloud_ptr_->at(i);
170 Eigen::Vector3d trans_point(pt.x, pt.y, pt.z);
173 world_point.x = trans_point(0);
174 world_point.y = trans_point(1);
175 world_point.z = trans_point(2);
176 world_point.intensity = pt.intensity;
177 cur_world_cloud_ptr->push_back(world_point);
178 }
179 cur_world_cloud_ptr->set_timestamp(frame->timestamp);
180
181
182 for (auto& prev_world_cloud_ptr : prev_world_clouds_) {
183 num_points += prev_world_cloud_ptr->size();
184 }
185 FuseCloud(cur_cloud_ptr_, prev_world_clouds_);
186
187
188 while (static_cast<int>(prev_world_clouds_.size()) >=
190 prev_world_clouds_.pop_front();
191 }
192 prev_world_clouds_.emplace_back(cur_world_cloud_ptr);
193 }
194 AINFO <<
"num points after fusing: " << num_points;
195 fuse_time_ = timer.toc(true);
196
197
200 std::vector<int> point_indices = GenerateIndices(0, num_points, true);
203 cur_cloud_ptr_ = shuffle_cloud_ptr;
204 }
205 shuffle_time_ = timer.toc(true);
206
207
208 float* points_array =
210 CloudToArray(cur_cloud_ptr_, points_array,
212 cloud_to_array_time_ = timer.toc(true);
213
214
215 std::vector<float> out_detections;
216 std::vector<int> out_labels;
217 point_pillars_ptr_->DoInference(points_array, num_points, &out_detections,
218 &out_labels);
219 inference_time_ = timer.toc(true);
220
221
222 GetObjects(&frame->segmented_objects, frame->lidar2world_pose,
223 &out_detections, &out_labels);
224 collect_time_ = timer.toc(true);
225
226 AINFO <<
"PointPillars: "
227 << "\n"
228 << "down sample: " << downsample_time_ << "\t"
229 << "fuse: " << fuse_time_ << "\t"
230 << "shuffle: " << shuffle_time_ << "\t"
231 << "cloud_to_array: " << cloud_to_array_time_ << "\t"
232 << "inference: " << inference_time_ << "\t"
233 << "collect: " << collect_time_;
234
235 delete[] points_array;
236 return true;
237}
bool DownSamplePointCloudBeams(base::PointFCloudPtr cloud_ptr, base::PointFCloudPtr out_cloud_ptr, int downsample_factor)
AttributePointCloud< PointF > PointFCloud
std::shared_ptr< PointDCloud > PointDCloudPtr
std::shared_ptr< PointFCloud > PointFCloudPtr
optional bool enable_downsample_beams
optional bool enable_fuse_frames
optional int32 max_num_points
optional int32 num_point_feature
optional bool enable_downsample_pointcloud
optional bool enable_shuffle_points
optional double fuse_time_interval
optional int32 downsample_beams_factor
optional double normalizing_factor
optional int32 num_fuse_frames
Eigen::Affine3d lidar2world_pose
std::vector< std::shared_ptr< base::Object > > segmented_objects
optional common::PointCloudPreProcess preprocess